Răsfoiți Sursa

fix docker leak (#4970)

Robert Brennan 1 an în urmă
părinte
comite
f55ddbed0e

+ 1 - 1
openhands/controller/agent_controller.py

@@ -42,7 +42,7 @@ from openhands.events.observation import (
 )
 from openhands.events.serialization.event import truncate_content
 from openhands.llm.llm import LLM
-from openhands.runtime.utils.shutdown_listener import should_continue
+from openhands.utils.shutdown_listener import should_continue
 
 # note: RESUME is only available on web GUI
 TRAFFIC_CONTROL_REMINDER = (

+ 1 - 1
openhands/events/stream.py

@@ -9,9 +9,9 @@ from openhands.core.logger import openhands_logger as logger
 from openhands.core.utils import json
 from openhands.events.event import Event, EventSource
 from openhands.events.serialization.event import event_from_dict, event_to_dict
-from openhands.runtime.utils.shutdown_listener import should_continue
 from openhands.storage import FileStore
 from openhands.utils.async_utils import call_sync_from_async
+from openhands.utils.shutdown_listener import should_continue
 
 
 class EventStreamSubscriber(str, Enum):

+ 1 - 1
openhands/llm/async_llm.py

@@ -7,7 +7,7 @@ from litellm import acompletion as litellm_acompletion
 from openhands.core.exceptions import UserCancelledError
 from openhands.core.logger import openhands_logger as logger
 from openhands.llm.llm import LLM, LLM_RETRY_EXCEPTIONS
-from openhands.runtime.utils.shutdown_listener import should_continue
+from openhands.utils.shutdown_listener import should_continue
 
 
 class AsyncLLM(LLM):

+ 11 - 13
openhands/runtime/__init__.py

@@ -1,31 +1,25 @@
 from openhands.core.logger import openhands_logger as logger
 from openhands.runtime.impl.e2b.sandbox import E2BBox
+from openhands.runtime.impl.eventstream.eventstream_runtime import (
+    EventStreamRuntime,
+)
+from openhands.runtime.impl.modal.modal_runtime import ModalRuntime
+from openhands.runtime.impl.remote.remote_runtime import RemoteRuntime
+from openhands.runtime.impl.runloop.runloop_runtime import RunloopRuntime
 
 
 def get_runtime_cls(name: str):
     # Local imports to avoid circular imports
     if name == 'eventstream':
-        from openhands.runtime.impl.eventstream.eventstream_runtime import (
-            EventStreamRuntime,
-        )
-
         return EventStreamRuntime
     elif name == 'e2b':
-        from openhands.runtime.impl.e2b.e2b_runtime import E2BRuntime
-
-        return E2BRuntime
+        return E2BBox
     elif name == 'remote':
-        from openhands.runtime.impl.remote.remote_runtime import RemoteRuntime
-
         return RemoteRuntime
     elif name == 'modal':
         logger.debug('Using ModalRuntime')
-        from openhands.runtime.impl.modal.modal_runtime import ModalRuntime
-
         return ModalRuntime
     elif name == 'runloop':
-        from openhands.runtime.impl.runloop.runloop_runtime import RunloopRuntime
-
         return RunloopRuntime
     else:
         raise ValueError(f'Runtime {name} not supported')
@@ -33,5 +27,9 @@ def get_runtime_cls(name: str):
 
 __all__ = [
     'E2BBox',
+    'RemoteRuntime',
+    'ModalRuntime',
+    'RunloopRuntime',
+    'EventStreamRuntime',
     'get_runtime_cls',
 ]

+ 1 - 1
openhands/runtime/browser/browser_env.py

@@ -16,7 +16,7 @@ from PIL import Image
 
 from openhands.core.exceptions import BrowserInitException
 from openhands.core.logger import openhands_logger as logger
-from openhands.runtime.utils.shutdown_listener import should_continue, should_exit
+from openhands.utils.shutdown_listener import should_continue, should_exit
 from openhands.utils.tenacity_stop import stop_if_should_exit
 
 BROWSER_EVAL_GET_GOAL_ACTION = 'GET_EVAL_GOAL'

+ 1 - 1
openhands/runtime/builder/remote.py

@@ -8,7 +8,7 @@ import requests
 from openhands.core.logger import openhands_logger as logger
 from openhands.runtime.builder import RuntimeBuilder
 from openhands.runtime.utils.request import send_request
-from openhands.runtime.utils.shutdown_listener import (
+from openhands.utils.shutdown_listener import (
     should_continue,
     sleep_if_should_continue,
 )

+ 1 - 1
openhands/runtime/plugins/jupyter/__init__.py

@@ -8,7 +8,7 @@ from openhands.events.observation import IPythonRunCellObservation
 from openhands.runtime.plugins.jupyter.execute_server import JupyterKernel
 from openhands.runtime.plugins.requirement import Plugin, PluginRequirement
 from openhands.runtime.utils import find_available_tcp_port
-from openhands.runtime.utils.shutdown_listener import should_continue
+from openhands.utils.shutdown_listener import should_continue
 
 
 @dataclass

+ 1 - 1
openhands/runtime/utils/tenacity_stop.py

@@ -1,7 +1,7 @@
 from tenacity import RetryCallState
 from tenacity.stop import stop_base
 
-from openhands.runtime.utils.shutdown_listener import should_exit
+from openhands.utils.shutdown_listener import should_exit
 
 
 class stop_if_should_exit(stop_base):

+ 1 - 1
openhands/server/mock/listen.py

@@ -3,7 +3,7 @@ from fastapi import FastAPI, WebSocket
 
 from openhands.core.logger import openhands_logger as logger
 from openhands.core.schema import ActionType
-from openhands.runtime.utils.shutdown_listener import should_continue
+from openhands.utils.shutdown_listener import should_continue
 
 app = FastAPI()
 

+ 1 - 1
openhands/server/session/session.py

@@ -21,9 +21,9 @@ from openhands.events.observation.error import ErrorObservation
 from openhands.events.serialization import event_from_dict, event_to_dict
 from openhands.events.stream import EventStreamSubscriber
 from openhands.llm.llm import LLM
-from openhands.runtime.utils.shutdown_listener import should_continue
 from openhands.server.session.agent_session import AgentSession
 from openhands.storage.files import FileStore
+from openhands.utils.shutdown_listener import should_continue
 
 
 class Session:

+ 0 - 0
openhands/runtime/utils/shutdown_listener.py → openhands/utils/shutdown_listener.py


+ 1 - 1
openhands/utils/tenacity_stop.py

@@ -1,7 +1,7 @@
 from tenacity import RetryCallState
 from tenacity.stop import stop_base
 
-from openhands.runtime.utils.shutdown_listener import should_exit
+from openhands.utils.shutdown_listener import should_exit
 
 
 class stop_if_should_exit(stop_base):