Skip to content

Commit

Permalink
(fix) Revert All-Hands-AI#3233; more logging in runtimes (All-Hands-A…
Browse files Browse the repository at this point in the history
…I#3236)

* ServerRuntime: config copy in init

* revert All-Hands-AI#3233 but more logging

* get_box_classes: reset order back to previous version

* 3 logging commands switched to debug (were info)

* runtimes debug output of config on initialization

* removed unneeded logger message from _init_container
  • Loading branch information
tobitege authored Aug 4, 2024
1 parent 6a12a9f commit abec52a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 14 deletions.
5 changes: 1 addition & 4 deletions opendevin/runtime/client/runtime.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import asyncio
import copy
import os
import tempfile
import uuid
Expand Down Expand Up @@ -50,7 +49,6 @@ def __init__(
plugins: list[PluginRequirement] | None = None,
container_image: str | None = None,
):
self.config = copy.deepcopy(config)
super().__init__(
config, event_stream, sid, plugins
) # will initialize the event stream
Expand All @@ -72,6 +70,7 @@ def __init__(

self.container = None
self.action_semaphore = asyncio.Semaphore(1) # Ensure one action at a time
logger.debug(f'EventStreamRuntime `{sid}` config:\n{self.config}')

async def ainit(self, env_vars: dict[str, str] | None = None):
if self.config.sandbox.od_runtime_extra_deps:
Expand Down Expand Up @@ -151,8 +150,6 @@ async def _init_container(
)
volumes = None

logger.info(f'run_as_devin: `{self.config.run_as_devin}`')

if self.config.sandbox.browsergym_eval_env is not None:
browsergym_arg = (
f'--browsergym-eval-env {self.config.sandbox.browsergym_eval_env}'
Expand Down
1 change: 1 addition & 0 deletions opendevin/runtime/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ def __init__(
self.config = copy.deepcopy(config)
self.DEFAULT_ENV_VARS = _default_env_vars(config.sandbox)
atexit.register(self.close_sync)
logger.debug(f'Runtime `{sid}` config:\n{self.config}')

async def ainit(self, env_vars: dict[str, str] | None = None) -> None:
"""
Expand Down
1 change: 1 addition & 0 deletions opendevin/runtime/server/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def __init__(
self.sandbox = sandbox
self._is_external_sandbox = True
self.browser: BrowserEnv | None = None
logger.debug(f'ServerRuntime `{sid}` config:\n{self.config}')

def create_sandbox(self, sid: str = 'default', box_type: str = 'ssh') -> Sandbox:
if box_type == 'local':
Expand Down
25 changes: 15 additions & 10 deletions tests/unit/test_runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -962,13 +962,16 @@ async def _test_ipython_agentskills_fileop_pwd_impl(


@pytest.mark.asyncio
async def test_ipython_agentskills_fileop_pwd(temp_dir, box_class, enable_auto_lint):
async def test_ipython_agentskills_fileop_pwd(
temp_dir, box_class, run_as_devin, enable_auto_lint
):
"""Make sure that cd in bash also update the current working directory in ipython."""

runtime = await _load_runtime(
temp_dir, box_class, enable_auto_lint=enable_auto_lint
temp_dir, box_class, run_as_devin, enable_auto_lint=enable_auto_lint
)
await _test_ipython_agentskills_fileop_pwd_impl(runtime, enable_auto_lint)

await runtime.close()
await asyncio.sleep(1)

Expand Down Expand Up @@ -1039,29 +1042,31 @@ async def test_ipython_agentskills_fileop_pwd_with_userdir(temp_dir, box_class):
await asyncio.sleep(1)


@pytest.mark.skipif(
TEST_RUNTIME.lower() == 'eventstream',
reason='Skip this if we want to test EventStreamRuntime',
)
@pytest.mark.skipif(
os.environ.get('TEST_IN_CI', 'false').lower() == 'true',
# FIXME: There's some weird issue with the CI environment.
reason='Skip this if in CI.',
)
@pytest.mark.asyncio
async def test_ipython_agentskills_fileop_pwd_agnostic_sandbox(
temp_dir, enable_auto_lint, container_image
temp_dir, box_class, run_as_devin, enable_auto_lint, container_image
):
"""Make sure that cd in bash also update the current working directory in ipython."""
"""Make sure that cd in bash also updates the current working directory in iPython."""

# NOTE: we only test for ServerRuntime, since EventStreamRuntime
# is image agnostic by design.
if box_class != 'server':
pytest.skip('Skip this if box_class is not server')

runtime = await _load_runtime(
temp_dir,
# NOTE: we only test for ServerRuntime, since EventStreamRuntime is image agnostic by design.
ServerRuntime,
box_class,
run_as_devin,
enable_auto_lint=enable_auto_lint,
container_image=container_image,
)
await _test_ipython_agentskills_fileop_pwd_impl(runtime, enable_auto_lint)

await runtime.close()
await asyncio.sleep(1)

Expand Down

0 comments on commit abec52a

Please sign in to comment.