Просмотр исходного кода

move image agnostic util to shared runtime util (#2859)

Xingyao Wang 1 год назад
Родитель
Сommit
f2e92b2db7

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

@@ -16,10 +16,10 @@ from opendevin.core.config import config
 from opendevin.core.const.guide_url import TROUBLESHOOTING_URL
 from opendevin.core.logger import opendevin_logger as logger
 from opendevin.core.schema import CancellableStream
-from opendevin.runtime.docker.image_agnostic_util import get_od_sandbox_image
 from opendevin.runtime.plugins import AgentSkillsRequirement, JupyterRequirement
 from opendevin.runtime.sandbox import Sandbox
 from opendevin.runtime.utils import find_available_tcp_port
+from opendevin.runtime.utils.image_agnostic import get_od_sandbox_image
 
 
 class SSHExecCancellableStream(CancellableStream):

+ 3 - 1
opendevin/runtime/docker/image_agnostic_util.py → opendevin/runtime/utils/image_agnostic.py

@@ -49,7 +49,9 @@ def _build_sandbox_image(
                 file.write(dockerfile_content)
 
             api_client = docker_client.api
-            build_logs = api_client.build(path=temp_dir, tag=target_image_name, rm=True, decode=True)
+            build_logs = api_client.build(
+                path=temp_dir, tag=target_image_name, rm=True, decode=True
+            )
 
             for log in build_logs:
                 if 'stream' in log:

+ 3 - 3
tests/unit/test_image_agnostic_util.py

@@ -1,6 +1,6 @@
 from unittest.mock import MagicMock, patch
 
-from opendevin.runtime.docker.image_agnostic_util import (
+from opendevin.runtime.utils.image_agnostic import (
     _get_new_image_name,
     generate_dockerfile_content,
     get_od_sandbox_image,
@@ -31,8 +31,8 @@ def test_get_new_image_name():
     assert new_image_name == 'od_sandbox:ubuntu__latest'
 
 
-@patch('opendevin.runtime.docker.image_agnostic_util._build_sandbox_image')
-@patch('opendevin.runtime.docker.image_agnostic_util.docker.DockerClient')
+@patch('opendevin.runtime.utils.image_agnostic._build_sandbox_image')
+@patch('opendevin.runtime.utils.image_agnostic.docker.DockerClient')
 def test_get_od_sandbox_image(mock_docker_client, mock_build_sandbox_image):
     base_image = 'debian:11'
     mock_docker_client.images.list.return_value = [