Skip to content

πŸ™Œ OpenHands: AI-Driven Development

chores: open the websockets ports for port mapping and remove chores. (#2864)

Yufan Songf0bc231f3e93
diff --git a/opendevin/runtime/client/client.py b/opendevin/runtime/client/client.py
index cdaac87dbc..3311033f7c 100644
--- a/opendevin/runtime/client/client.py
+++ b/opendevin/runtime/client/client.py
@@ -32,6 +32,8 @@ class RuntimeClient():
def __init__(self) -> None:
self.init_shell()
+ # TODO: code will block at init_websocket, maybe we can open a subprocess to run websocket forever
+ # In case we need to run other code after init_websocket
self.init_websocket()
def init_websocket(self) -> None:
@@ -179,11 +181,10 @@ class RuntimeClient():
output, exit_code = self.execute(
'source /opendevin/bash.bashrc && source ~/.bashrc'
)
- print("Yufan:",exit_code, output)
- # if exit_code != 0:
- # raise RuntimeError(
- # f'Failed to source /opendevin/bash.bashrc and ~/.bashrc with exit code {exit_code} and output: {output}'
- # )
+ if exit_code != 0:
+ raise RuntimeError(
+ f'Failed to source /opendevin/bash.bashrc and ~/.bashrc with exit code {exit_code} and output: {output}'
+ )
print('Sourced /opendevin/bash.bashrc and ~/.bashrc successfully')
diff --git a/opendevin/runtime/client/runtime.py b/opendevin/runtime/client/runtime.py
index d55bbf9f87..4f651e33a1 100644
--- a/opendevin/runtime/client/runtime.py
+++ b/opendevin/runtime/client/runtime.py
@@ -88,11 +88,12 @@ class EventStreamRuntime(Runtime):
self.container = self.docker_client.containers.run(
self.container_image,
command='tail -f /dev/null',
- # TODO: test it in mac and linux
+ # TODO: test the port mapping in mac and linux
# network_mode='host',
working_dir=self.sandbox_workspace_dir,
name=self.container_name,
detach=True,
+ ports={'8080/tcp': 8080},
volumes={mount_dir: {'bind': self.sandbox_workspace_dir, 'mode': 'rw'}},
)
print('Container started')