Skip to content

armgit / cua

Public Imported from GitHub
0

Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.

add restart_vm to all providers

Dillon DuPont86a339d1cd5a
diff --git a/examples/cloud_api_examples.py b/examples/cloud_api_examples.py
index 4fc71770b2..88b1ea66ed 100644
--- a/examples/cloud_api_examples.py
+++ b/examples/cloud_api_examples.py
@@ -57,14 +57,14 @@ async def main() -> None:
# )
# # To probe a VM's status via its public hostname (if you know the name):
- name = "m-linux-96lcxd2c2k"
- info = await provider.get_vm(name)
- print("get_vm info:\n",
- f"name: {info['name']}\n",
- f"status: {info['status']}\n", # running
- f"api_url: {info.get('api_url')}\n",
- f"os_type: {info.get('os_type')}\n",
- )
+ # name = "m-linux-96lcxd2c2k"
+ # info = await provider.get_vm(name)
+ # print("get_vm info:\n",
+ # f"name: {info['name']}\n",
+ # f"status: {info['status']}\n", # running
+ # f"api_url: {info.get('api_url')}\n",
+ # f"os_type: {info.get('os_type')}\n",
+ # )
if __name__ == "__main__":
asyncio.run(main())
diff --git a/libs/python/computer/computer/providers/docker/provider.py b/libs/python/computer/computer/providers/docker/provider.py
index 82ad411ce8..481bffaabf 100644
--- a/libs/python/computer/computer/providers/docker/provider.py
+++ b/libs/python/computer/computer/providers/docker/provider.py
@@ -405,6 +405,9 @@ class DockerProvider(BaseVMProvider):
"provider": "docker"
}
+ async def restart_vm(self, name: str, storage: Optional[str] = None) -> Dict[str, Any]:
+ raise NotImplementedError("DockerProvider does not support restarting VMs.")
+
async def update_vm(self, name: str, update_opts: Dict[str, Any], storage: Optional[str] = None) -> Dict[str, Any]:
"""Update VM configuration.
diff --git a/libs/python/computer/computer/providers/lume/provider.py b/libs/python/computer/computer/providers/lume/provider.py
index 5816e53e82..d651d2eb5b 100644
--- a/libs/python/computer/computer/providers/lume/provider.py
+++ b/libs/python/computer/computer/providers/lume/provider.py
@@ -486,6 +486,9 @@ class LumeProvider(BaseVMProvider):
"""Update VM configuration."""
return self._lume_api_update(name, update_opts, debug=self.verbose)
+ async def restart_vm(self, name: str, storage: Optional[str] = None) -> Dict[str, Any]:
+ raise NotImplementedError("LumeProvider does not support restarting VMs.")
+
async def get_ip(self, name: str, storage: Optional[str] = None, retry_delay: int = 2) -> str:
"""Get the IP address of a VM, waiting indefinitely until it's available.
diff --git a/libs/python/computer/computer/providers/lumier/provider.py b/libs/python/computer/computer/providers/lumier/provider.py
index 67f348be6c..9b3e8c4d37 100644
--- a/libs/python/computer/computer/providers/lumier/provider.py
+++ b/libs/python/computer/computer/providers/lumier/provider.py
@@ -836,6 +836,9 @@ class LumierProvider(BaseVMProvider):
logger.error(error_msg)
return error_msg
+ async def restart_vm(self, name: str, storage: Optional[str] = None) -> Dict[str, Any]:
+ raise NotImplementedError("LumierProvider does not support restarting VMs.")
+
async def get_ip(self, name: str, storage: Optional[str] = None, retry_delay: int = 2) -> str:
"""Get the IP address of a VM, waiting indefinitely until it's available.
diff --git a/libs/python/computer/computer/providers/winsandbox/provider.py b/libs/python/computer/computer/providers/winsandbox/provider.py
index e072d900a3..1c9aec3cb0 100644
--- a/libs/python/computer/computer/providers/winsandbox/provider.py
+++ b/libs/python/computer/computer/providers/winsandbox/provider.py
@@ -390,6 +390,9 @@ class WinSandboxProvider(BaseVMProvider):
"error": "Windows Sandbox does not support runtime configuration updates. "
"Please stop and restart the sandbox with new configuration."
}
+
+ async def restart_vm(self, name: str, storage: Optional[str] = None) -> Dict[str, Any]:
+ raise NotImplementedError("WinSandboxProvider does not support restarting VMs.")
async def get_ip(self, name: str, storage: Optional[str] = None, retry_delay: int = 2) -> str:
"""Get the IP address of a VM, waiting indefinitely until it's available.