மனோஜ்குமார் பழனிச்சாமி 1 жил өмнө
parent
commit
cfae6821fa

+ 1 - 1
opendevin/runtime/docker/exec_box.py

@@ -107,7 +107,7 @@ class DockerExecBox(Sandbox):
     def __init__(
         self,
         container_image: str | None = None,
-        timeout: int = 120,
+        timeout: int = config.sandbox_timeout,
         sid: str | None = None,
     ):
         # Initialize docker client. Throws an exception if Docker is not reachable.

+ 1 - 1
opendevin/runtime/docker/local_box.py

@@ -26,7 +26,7 @@ from opendevin.runtime.sandbox import Sandbox
 
 
 class LocalBox(Sandbox):
-    def __init__(self, timeout: int = 120):
+    def __init__(self, timeout: int = config.sandbox_timeout):
         os.makedirs(config.workspace_base, exist_ok=True)
         self.timeout = timeout
         self.background_commands: dict[int, Process] = {}

+ 2 - 6
opendevin/runtime/docker/ssh_box.py

@@ -199,7 +199,7 @@ class DockerSSHBox(Sandbox):
     def __init__(
         self,
         container_image: str | None = None,
-        timeout: int = 120,
+        timeout: int = config.sandbox_timeout,
         sid: str | None = None,
     ):
         logger.info(
@@ -219,10 +219,6 @@ class DockerSSHBox(Sandbox):
             sid + str(uuid.uuid4()) if sid is not None else str(uuid.uuid4())
         )
 
-        # TODO: this timeout is actually essential - need a better way to set it
-        # if it is too short, the container may still waiting for previous
-        # command to finish (e.g. apt-get update)
-        # if it is too long, the user may have to wait for a unnecessary long time
         self.timeout = timeout
         self.container_image = (
             config.sandbox_container_image
@@ -432,7 +428,7 @@ class DockerSSHBox(Sandbox):
     def execute(
         self, cmd: str, stream: bool = False, timeout: int | None = None
     ) -> tuple[int, str | CancellableStream]:
-        timeout = timeout if timeout is not None else self.timeout
+        timeout = timeout or self.timeout
         commands = split_bash_commands(cmd)
         if len(commands) > 1:
             all_output = ''

+ 1 - 1
opendevin/runtime/e2b/sandbox.py

@@ -24,7 +24,7 @@ class E2BBox(Sandbox):
     def __init__(
         self,
         template: str = 'open-devin',
-        timeout: int = 120,
+        timeout: int = config.sandbox_timeout,
     ):
         self.sandbox = E2BSandbox(
             api_key=config.e2b_api_key,

+ 4 - 4
opendevin/runtime/runtime.py

@@ -36,13 +36,13 @@ from opendevin.storage import FileStore, InMemoryFileStore
 
 def create_sandbox(sid: str = 'default', sandbox_type: str = 'exec') -> Sandbox:
     if sandbox_type == 'exec':
-        return DockerExecBox(sid=sid, timeout=config.sandbox_timeout)
+        return DockerExecBox(sid=sid)
     elif sandbox_type == 'local':
-        return LocalBox(timeout=config.sandbox_timeout)
+        return LocalBox()
     elif sandbox_type == 'ssh':
-        return DockerSSHBox(sid=sid, timeout=config.sandbox_timeout)
+        return DockerSSHBox(sid=sid)
     elif sandbox_type == 'e2b':
-        return E2BBox(timeout=config.sandbox_timeout)
+        return E2BBox()
     else:
         raise ValueError(f'Invalid sandbox type: {sandbox_type}')