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.

ci(cua-s1): test Python 3.11 to 3.13 and macOS (#4202)

Francesco Bonacci64d12157c6dc
diff --git a/.github/workflows/ci-cua-s1.yml b/.github/workflows/ci-cua-s1.yml
index 905c4c6c37..6648da0219 100644
--- a/.github/workflows/ci-cua-s1.yml
+++ b/.github/workflows/ci-cua-s1.yml
@@ -17,9 +17,14 @@ permissions:
jobs:
test:
- name: Lint, test, and train smoke
+ name: Lint, test, and train smoke (Python ${{ matrix.python-version }})
runs-on: ubuntu-latest
timeout-minutes: 15
+ strategy:
+ fail-fast: false
+ matrix:
+ # Keep in sync with requires-python and the classifiers in pyproject.toml.
+ python-version: ["3.11", "3.12", "3.13"]
env:
CUA_TELEMETRY_ENABLED: "false"
HF_DATASETS_OFFLINE: "1"
@@ -38,7 +43,7 @@ jobs:
- name: Set up uv and Python
uses: astral-sh/setup-uv@d0cc045d04ccac9d8b7881df0226f9e82c39688e # v6
with:
- python-version: "3.12"
+ python-version: ${{ matrix.python-version }}
enable-cache: true
cache-dependency-glob: libs/cua-s1/python/uv.lock
@@ -142,3 +147,44 @@ jobs:
assert all((torchvision, PeftModel, modeling_qwen3_5, AutoModelForCausalLM, AutoModelForImageTextToText, AutoProcessor, AutoTokenizer))
PY
uv run --frozen --extra four-b --group test pytest -q tests/test_four_b.py
+
+ macos-unit:
+ # Apple silicon is the primary local inference platform for Cua-S1-4B
+ # (S1_DEVICE=mps). This job covers the offline unit suite and the four-b
+ # dependency resolution on macOS arm64; it does not download weights.
+ name: macOS unit (Python 3.12)
+ runs-on: macos-latest
+ timeout-minutes: 20
+ env:
+ CUA_TELEMETRY_ENABLED: "false"
+ HF_DATASETS_OFFLINE: "1"
+ HF_HUB_OFFLINE: "1"
+ PYTHONHASHSEED: "0"
+ TRANSFORMERS_OFFLINE: "1"
+ WANDB_MODE: disabled
+ defaults:
+ run:
+ working-directory: libs/cua-s1/python
+
+ steps:
+ - name: Check out Cua
+ uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
+
+ - name: Set up uv and Python
+ uses: astral-sh/setup-uv@d0cc045d04ccac9d8b7881df0226f9e82c39688e # v6
+ with:
+ python-version: "3.12"
+ enable-cache: true
+ cache-dependency-glob: libs/cua-s1/python/uv.lock
+
+ - name: Run unit tests with the four-b inference extra
+ run: |
+ uv sync --frozen --extra four-b --extra pdf --group test
+ uv run --frozen --extra four-b --extra pdf --group test python - <<'PY'
+ import torch
+ import transformers
+
+ assert transformers.__version__.startswith("5.")
+ print("torch", torch.__version__, "mps built:", torch.backends.mps.is_built())
+ PY
+ uv run --frozen --extra four-b --extra pdf --group test pytest -q
diff --git a/libs/cua-s1/python/tests/test_pdf.py b/libs/cua-s1/python/tests/test_pdf.py
index 4b20019d8f..e7361c0c80 100644
--- a/libs/cua-s1/python/tests/test_pdf.py
+++ b/libs/cua-s1/python/tests/test_pdf.py
@@ -88,6 +88,12 @@ def test_extract_entities_refuses_a_symlink_swap_before_open(monkeypatch, tmp_pa
path.symlink_to(outside)
return real_open(candidate, flags)
+ def must_not_parse(_stream):
+ raise AssertionError("a swapped path must be refused before PDF parsing starts")
+
+ # Stub pdfplumber so this guard is exercised without the optional `pdf`
+ # extra (for example in the `four-b`-only inference environment).
+ monkeypatch.setitem(sys.modules, "pdfplumber", SimpleNamespace(open=must_not_parse))
monkeypatch.setattr(os, "open", swap_then_open)
with pytest.raises(PdfError) as caught: