Skip to content

Commit

Permalink
[Arch] Implement EventStream Runtime Client with Jupyter Support usin…
Browse files Browse the repository at this point in the history
…g Agnostic Sandbox (All-Hands-AI#2879)

* support loading a particular runtime class via config.runtime (default to server to not break things)

* move image agnostic util to shared runtime util

* move dependency

* include poetry.lock in sdist

* accept port as arg for client

* make client start server with specified port

* update image agnostic utility for eventstream runtime

* make client and runtime working with REST API

* rename execute_server

* add plugin to initialize stuff inside es-runtime;
cleanup runtime methods to delegate everything to container

* remove redundant ls -alh

* fix jupyter

* improve logging in agnostic sandbox

* improve logging of test function

* add read & edit

* update agnostic sandbox

* support setting work dir at start

* fix file read/write test

* fix unit test

* update tescase

* Fix unit test again

* fix unit test again again
  • Loading branch information
xingyaoww authored Jul 11, 2024
1 parent 43c3e90 commit e45d46c
Show file tree
Hide file tree
Showing 16 changed files with 1,897 additions and 405 deletions.
5 changes: 3 additions & 2 deletions opendevin/core/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
from opendevin.events.event import Event
from opendevin.events.observation import AgentStateChangedObservation
from opendevin.llm.llm import LLM
from opendevin.runtime import get_runtime_cls
from opendevin.runtime.sandbox import Sandbox
from opendevin.runtime.server.runtime import ServerRuntime


def read_task_from_file(file_path: str) -> str:
Expand Down Expand Up @@ -79,7 +79,8 @@ async def run_agent_controller(
)

# runtime and tools
runtime = ServerRuntime(event_stream=event_stream, sandbox=sandbox)
runtime_cls = get_runtime_cls(config.runtime)
runtime = runtime_cls(event_stream=event_stream, sandbox=sandbox)
runtime.init_sandbox_plugins(controller.agent.sandbox_plugins)
runtime.init_runtime_tools(
controller.agent.runtime_tools,
Expand Down
32 changes: 31 additions & 1 deletion opendevin/runtime/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,36 @@
from typing import TYPE_CHECKING, Type

from .docker.local_box import LocalBox
from .docker.ssh_box import DockerSSHBox
from .e2b.sandbox import E2BBox
from .sandbox import Sandbox

__all__ = ['Sandbox', 'DockerSSHBox', 'E2BBox', 'LocalBox']
if TYPE_CHECKING:
from .runtime import Runtime


def get_runtime_cls(name: str) -> Type['Runtime']:
# Local imports to avoid circular imports
if name == 'server':
from .server.runtime import ServerRuntime

return ServerRuntime
elif name == 'client':
from .client.runtime import EventStreamRuntime

return EventStreamRuntime
elif name == 'e2b':
from .e2b.runtime import E2BRuntime

return E2BRuntime
else:
raise ValueError(f'Runtime {name} not supported')


__all__ = [
'DockerSSHBox',
'E2BBox',
'LocalBox',
'Sandbox',
'get_runtime_cls',
]
Loading

0 comments on commit e45d46c

Please sign in to comment.