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.

Added reference documentation for: libs/python/computer-server/computer_server/diorama/diorama_computer.py

Andrei Onel4d6e611d73ac
diff --git a/libs/python/computer-server/computer_server/diorama/diorama_computer.py b/libs/python/computer-server/computer_server/diorama/diorama_computer.py
index 4fc37b3f17..c00bd86fbd 100644
--- a/libs/python/computer-server/computer_server/diorama/diorama_computer.py
+++ b/libs/python/computer-server/computer_server/diorama/diorama_computer.py
@@ -6,11 +6,26 @@ class DioramaComputer:
Implements _initialized, run(), and __aenter__ for agent compatibility.
"""
def __init__(self, diorama):
+ """
+ Initialize the DioramaComputer with a diorama instance.
+
+ Args:
+ diorama: The diorama instance to wrap with a computer-like interface.
+ """
self.diorama = diorama
self.interface = self.diorama.interface
self._initialized = False
async def __aenter__(self):
+ """
+ Async context manager entry method for compatibility with ComputerAgent.
+
+ Ensures an event loop is running and marks the instance as initialized.
+ Creates a new event loop if none is currently running.
+
+ Returns:
+ DioramaComputer: The initialized instance.
+ """
# Ensure the event loop is running (for compatibility)
try:
asyncio.get_running_loop()
@@ -20,6 +35,15 @@ class DioramaComputer:
return self
async def run(self):
+ """
+ Run method stub for compatibility with ComputerAgent interface.
+
+ Ensures the instance is initialized before returning. If not already
+ initialized, calls __aenter__ to perform initialization.
+
+ Returns:
+ DioramaComputer: The initialized instance.
+ """
# This is a stub for compatibility
if not self._initialized:
await self.__aenter__()