Spaces:
Build error
Build error
File size: 1,668 Bytes
51ff9e5 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
from openhands.core.config import OpenHandsConfig
from openhands.runtime.plugins import PluginRequirement
DEFAULT_PYTHON_PREFIX = [
'/openhands/micromamba/bin/micromamba',
'run',
'-n',
'openhands',
'poetry',
'run',
]
DEFAULT_MAIN_MODULE = 'openhands.runtime.action_execution_server'
def get_action_execution_server_startup_command(
server_port: int,
plugins: list[PluginRequirement],
app_config: OpenHandsConfig,
python_prefix: list[str] = DEFAULT_PYTHON_PREFIX,
override_user_id: int | None = None,
override_username: str | None = None,
main_module: str = DEFAULT_MAIN_MODULE,
) -> list[str]:
sandbox_config = app_config.sandbox
# Plugin args
plugin_args = []
if plugins is not None and len(plugins) > 0:
plugin_args = ['--plugins'] + [plugin.name for plugin in plugins]
# Browsergym stuffs
browsergym_args = []
if sandbox_config.browsergym_eval_env is not None:
browsergym_args = [
'--browsergym-eval-env'
] + sandbox_config.browsergym_eval_env.split(' ')
username = override_username or (
'openhands' if app_config.run_as_openhands else 'root'
)
user_id = override_user_id or (
sandbox_config.user_id if app_config.run_as_openhands else 0
)
base_cmd = [
*python_prefix,
'python',
'-u',
'-m',
main_module,
str(server_port),
'--working-dir',
app_config.workspace_mount_path_in_sandbox,
*plugin_args,
'--username',
username,
'--user-id',
str(user_id),
*browsergym_args,
]
return base_cmd
|