Revert "Fix passing environment" (#8612)

This commit is contained in:
Robert Brennan 2025-05-21 10:32:47 -04:00 committed by GitHub
parent c353fb6e7e
commit 37e9933092
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 17 additions and 34 deletions

View File

@ -135,10 +135,6 @@ class Runtime(FileEditRuntimeMixin):
atexit.register(self.close)
self.initial_env_vars = _default_env_vars(config.sandbox)
# also update with runtime_startup_env_vars
self.initial_env_vars.update(self.config.sandbox.runtime_startup_env_vars)
if env_vars is not None:
self.initial_env_vars.update(env_vars)

View File

@ -23,7 +23,7 @@ from openhands.runtime.impl.action_execution.action_execution_client import (
from openhands.runtime.impl.docker.containers import stop_all_containers
from openhands.runtime.plugins import PluginRequirement
from openhands.runtime.utils import find_available_tcp_port
from openhands.runtime.utils.command import DEFAULT_MAIN_MODULE, get_action_execution_server_startup_command
from openhands.runtime.utils.command import get_action_execution_server_startup_command
from openhands.runtime.utils.log_streamer import LogStreamer
from openhands.runtime.utils.runtime_build import build_runtime_image
from openhands.utils.async_utils import call_sync_from_async
@ -80,7 +80,6 @@ class DockerRuntime(ActionExecutionClient):
status_callback: Callable | None = None,
attach_to_existing: bool = False,
headless_mode: bool = True,
main_module: str = DEFAULT_MAIN_MODULE,
):
if not DockerRuntime._shutdown_listener_id:
DockerRuntime._shutdown_listener_id = add_shutdown_listener(
@ -110,7 +109,6 @@ class DockerRuntime(ActionExecutionClient):
self.runtime_container_image = self.config.sandbox.runtime_container_image
self.container_name = CONTAINER_NAME_PREFIX + sid
self.container: Container | None = None
self.main_module = main_module
self.runtime_builder = DockerRuntimeBuilder(self.docker_client)
@ -311,15 +309,16 @@ class DockerRuntime(ActionExecutionClient):
)
# Combine environment variables
environment = dict(**self.initial_env_vars)
environment.update({
environment = {
'port': str(self._container_port),
'PYTHONUNBUFFERED': '1',
'VSCODE_PORT': str(self._vscode_port),
'PIP_BREAK_SYSTEM_PACKAGES': '1',
})
}
if self.config.debug or DEBUG:
environment['DEBUG'] = 'true'
# also update with runtime_startup_env_vars
environment.update(self.config.sandbox.runtime_startup_env_vars)
self.log('debug', f'Workspace Base: {self.config.workspace_base}')
@ -337,7 +336,11 @@ class DockerRuntime(ActionExecutionClient):
f'Sandbox workspace: {self.config.workspace_mount_path_in_sandbox}',
)
command = self.get_action_execution_server_startup_command()
command = get_action_execution_server_startup_command(
server_port=self._container_port,
plugins=self.plugins,
app_config=self.config,
)
try:
self.container = self.docker_client.containers.run(
@ -531,11 +534,3 @@ class DockerRuntime(ActionExecutionClient):
pass
finally:
docker_client.close()
def get_action_execution_server_startup_command(self):
return get_action_execution_server_startup_command(
server_port=self._container_port,
plugins=self.plugins,
app_config=self.config,
main_module=self.main_module,
)

View File

@ -24,7 +24,7 @@ from openhands.runtime.impl.action_execution.action_execution_client import (
ActionExecutionClient,
)
from openhands.runtime.plugins import PluginRequirement
from openhands.runtime.utils.command import DEFAULT_MAIN_MODULE, get_action_execution_server_startup_command
from openhands.runtime.utils.command import get_action_execution_server_startup_command
from openhands.runtime.utils.request import send_request
from openhands.runtime.utils.runtime_build import build_runtime_image
from openhands.utils.async_utils import call_sync_from_async
@ -54,7 +54,6 @@ class RemoteRuntime(ActionExecutionClient):
headless_mode: bool = True,
user_id: str | None = None,
git_provider_tokens: PROVIDER_TOKEN_TYPE | None = None,
main_module: str = DEFAULT_MAIN_MODULE,
) -> None:
super().__init__(
config,
@ -86,7 +85,6 @@ class RemoteRuntime(ActionExecutionClient):
)
assert self.config.sandbox.remote_runtime_class in (None, 'sysbox', 'gvisor')
self.main_module = main_module
self.runtime_builder = RemoteRuntimeBuilder(
self.config.sandbox.remote_runtime_api_url,
@ -233,7 +231,11 @@ class RemoteRuntime(ActionExecutionClient):
def _start_runtime(self) -> None:
# Prepare the request body for the /start endpoint
command = self.get_action_execution_server_startup_command()
command = get_action_execution_server_startup_command(
server_port=self.port,
plugins=self.plugins,
app_config=self.config,
)
environment: dict[str, str] = {}
if self.config.debug or os.environ.get('DEBUG', 'false').lower() == 'true':
environment['DEBUG'] = 'true'
@ -490,11 +492,3 @@ class RemoteRuntime(ActionExecutionClient):
def _stop_if_closed(self, retry_state: RetryCallState) -> bool:
return self._runtime_closed
def get_action_execution_server_startup_command(self):
return get_action_execution_server_startup_command(
server_port=self.port,
plugins=self.plugins,
app_config=self.config,
main_module=self.main_module,
)

View File

@ -9,7 +9,6 @@ DEFAULT_PYTHON_PREFIX = [
'poetry',
'run',
]
DEFAULT_MAIN_MODULE = 'openhands.runtime.action_execution_server'
def get_action_execution_server_startup_command(
@ -19,7 +18,6 @@ def get_action_execution_server_startup_command(
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
@ -47,7 +45,7 @@ def get_action_execution_server_startup_command(
'python',
'-u',
'-m',
main_module,
'openhands.runtime.action_execution_server',
str(server_port),
'--working-dir',
app_config.workspace_mount_path_in_sandbox,