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.

fix(cua-bench): --with flag silently skips reinstall when package version matches (#1235)

ddupont3c43de050fa4
diff --git a/libs/cua-bench/cua_bench/cli/commands/run.py b/libs/cua-bench/cua_bench/cli/commands/run.py
index 573eee3970..6c4fa55f59 100644
--- a/libs/cua-bench/cua_bench/cli/commands/run.py
+++ b/libs/cua-bench/cua_bench/cli/commands/run.py
@@ -1093,6 +1093,7 @@ async def _cmd_run_task_async(args) -> int:
stream_agent_logs=True, # Stream logs to run.log
provider_type=provider_type, # Pass detected provider type
dev_paths=getattr(args, "dev_paths", None),
+ verbose=getattr(args, "verbose", False),
)
if result.success:
@@ -1324,6 +1325,14 @@ async def _cmd_run_task_detached(args) -> int:
if provider_type in ("simulated", "webtop"):
cmd.extend(["--provider-type", "simulated"])
+ # Forward --with paths to subprocess
+ for dev_path in getattr(args, "dev_paths", None) or []:
+ cmd.extend(["--with", dev_path])
+
+ # Forward --verbose
+ if getattr(args, "verbose", False):
+ cmd.append("--verbose")
+
# Start background process
# Set environment variables for UTF-8 encoding on Windows
# This prevents UnicodeEncodeError with the banner
diff --git a/libs/cua-bench/cua_bench/cli/main.py b/libs/cua-bench/cua_bench/cli/main.py
index 15a4f93559..426a72982c 100644
--- a/libs/cua-bench/cua_bench/cli/main.py
+++ b/libs/cua-bench/cua_bench/cli/main.py
@@ -140,6 +140,11 @@ def main():
metavar="PATH",
help="Mount and pip install a local package into the agent container (can be repeated)",
)
+ parser.add_argument(
+ "--verbose",
+ action="store_true",
+ help="Print full docker command and pip install output (useful for debugging --with)",
+ )
# cb run task <path>
run_task_parser = run_subparsers.add_parser(
diff --git a/libs/cua-bench/cua_bench/runner/task_runner.py b/libs/cua-bench/cua_bench/runner/task_runner.py
index 36a8657dc1..ff97e3587f 100644
--- a/libs/cua-bench/cua_bench/runner/task_runner.py
+++ b/libs/cua-bench/cua_bench/runner/task_runner.py
@@ -212,6 +212,8 @@ class TaskRunner:
provider_type: Optional[str] = None,
# Dev mode: list of local package paths to mount and install
dev_paths: Optional[List[str]] = None,
+ # Verbose mode: print full docker command and pip install output
+ verbose: bool = False,
) -> TaskResult:
"""Run a task with 2-container architecture.
@@ -322,6 +324,7 @@ class TaskRunner:
output_dir=output_dir,
is_simulated=is_simulated,
dev_paths=dev_paths,
+ verbose=verbose,
)
# 3.5. Start streaming agent logs to file if requested
@@ -785,6 +788,7 @@ class TaskRunner:
output_dir: Optional[str],
is_simulated: bool = False,
dev_paths: Optional[List[str]] = None,
+ verbose: bool = False,
) -> ContainerInfo:
"""Start the agent container.
@@ -881,9 +885,17 @@ class TaskRunner:
abs_path = Path(dev_path).absolute()
container_path = f"/app/dev_{i}"
volumes.append(f"{abs_path}:{container_path}:ro")
- # Copy to tmp first since pip needs a writable source dir to build
+ # Copy to tmp first since pip needs a writable source dir to build.
+ # Use --force-reinstall so the local version always replaces an
+ # already-installed package of the same version (e.g. the one
+ # baked into the Docker image). --no-deps skips re-downloading
+ # transitive dependencies that are already present.
+ if verbose:
+ pip_cmd = f"pip install --force-reinstall --no-deps /tmp/dev_{i}"
+ else:
+ pip_cmd = f"pip install --force-reinstall --no-deps /tmp/dev_{i} 2>&1 | tail -1"
install_parts.append(
- f"(cp -r {container_path} /tmp/dev_{i} && pip install /tmp/dev_{i} 2>&1 | tail -1)"
+ f"(echo '[--with] installing {dev_path}' && cp -r {container_path} /tmp/dev_{i} && {pip_cmd})"
)
dev_install_cmd = " && ".join(install_parts) + " && "
@@ -914,6 +926,10 @@ class TaskRunner:
original_cmd = " ".join(command)
command = ["bash", "-c", f"{dev_install_cmd}{original_cmd}"]
+ if verbose:
+ print(f"[--verbose] agent container command: {command}")
+ print(f"[--verbose] volumes: {volumes}")
+
# Start container (not detached - we want to wait for it)
return await start_container(
image=image,