Update Docker image link

This commit is contained in:
FredWuCZ
2024-10-17 14:55:20 +08:00
parent 6e75e37eb0
commit ec3671ae01
2 changed files with 16 additions and 5 deletions

View File

@@ -27,7 +27,7 @@ MAX_RETRY_TIMES = 10
RETRY_INTERVAL = 5
UBUNTU_X86_URL = "https://huggingface.co/datasets/xlangai/ubuntu_osworld/resolve/main/Ubuntu.qcow2"
WINDOWS_X86_URL = r"https://huggingface.co/datasets/xlangai/windows_osworld/resolve/main/Windows-10-x64.qcow2"
WINDOWS_X86_URL = "https://huggingface.co/datasets/xlangai/windows_osworld/resolve/main/Windows-10-x64.qcow2.zip"
VMS_DIR = "./docker_vm_data"
# Determine the platform and CPU architecture to decide the correct VM image to download
@@ -95,6 +95,12 @@ def _download_vm(vms_dir: str):
logger.info("Download succeeds.")
break # Download completed successfully
# Unzip the downloaded file
logger.info("Unzipping the downloaded file...☕️")
with zipfile.ZipFile(downloaded_file_path, 'r') as zip_ref:
zip_ref.extractall(vms_dir)
logger.info("Files have been successfully extracted to the directory: " + str(vms_dir))
class DockerVMManager(VMManager):
def __init__(self, registry_path=""):
pass
@@ -124,6 +130,8 @@ class DockerVMManager(VMManager):
elif os_type == "Windows":
URL = WINDOWS_X86_URL
DOWNLOADED_FILE_NAME = URL.split('/')[-1]
if DOWNLOADED_FILE_NAME.endswith(".zip"):
DOWNLOADED_FILE_NAME = DOWNLOADED_FILE_NAME[:-4]
if not os.path.exists(os.path.join(VMS_DIR, DOWNLOADED_FILE_NAME)):
_download_vm(VMS_DIR)
return os.path.join(VMS_DIR, DOWNLOADED_FILE_NAME)

View File

@@ -18,10 +18,9 @@ RETRY_INTERVAL = 1
class DockerProvider(Provider):
def __init__(self, region: str):
self.client = docker.from_env()
self.vnc_port = self._get_available_port(8006)
self.server_port = self._get_available_port(5000)
# self.remote_debugging_port = self._get_available_port(1337)
self.chromium_port = self._get_available_port(9222)
self.server_port = None
self.vnc_port = None
self.chromium_port = None
self.environment = {"DISK_SIZE": "32G", "RAM_SIZE": "4G", "CPU_CORES": "4"} # Modify if needed
@staticmethod
@@ -32,6 +31,10 @@ class DockerProvider(Provider):
port += 1
def start_emulator(self, path_to_vm: str, headless: bool, os_type: str):
self.vnc_port = self._get_available_port(8006)
self.server_port = self._get_available_port(5000)
# self.remote_debugging_port = self._get_available_port(1337)
self.chromium_port = self._get_available_port(9222)
logger.info(f"Occupying ports: {self.vnc_port}, {self.server_port}, {self.chromium_port}")
self.container = self.client.containers.run("happysixd/osworld-docker", environment=self.environment, cap_add=["NET_ADMIN"], devices=["/dev/kvm"], volumes={os.path.abspath(path_to_vm): {"bind": "/System.qcow2", "mode": "ro"}}, ports={8006: self.vnc_port, 5000: self.server_port, 9222: self.chromium_port}, detach=True)
def download_screenshot(ip, port):