Skip to content

Commit 8899bb7

Browse files
committed
Add SAM2 workflow step
1 parent 926d1dc commit 8899bb7

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

‎.github/workflows/test_and_deploy.yml‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,39 @@ jobs:
5656
python-version: ${{ matrix.python-version }}
5757
secret-codecov-token: ${{ secrets.CODECOV_TOKEN }}
5858

59+
# SAM2 is in the "masks" extra, which the test job does not install
60+
# (its build needs torch installed first), so the SAM2 tests are
61+
# skipped there. This job installs it and runs them.
62+
test_sam2:
63+
name: Run SAM2 tests
64+
needs: [linting, manifest]
65+
runs-on: ubuntu-latest
66+
env:
67+
# CPU-only torch wheels: much smaller than PyPI's default CUDA ones
68+
UV_TORCH_BACKEND: cpu
69+
steps:
70+
- uses: actions/checkout@v7
71+
- uses: astral-sh/setup-uv@v7
72+
with:
73+
python-version: "3.13"
74+
activate-environment: true
75+
# opencv needs these on Ubuntu, as in the test job
76+
- name: Install OpenGL libraries
77+
run: |
78+
sudo apt-get update
79+
sudo apt-get install libglapi-mesa libegl-mesa0 libegl1 libopengl0 libgl1
80+
# as in bash_scripts/run_mask_array.sh: install torch (and setuptools)
81+
# first, then build SAM2 against them without build isolation
82+
- name: Install crabs, then SAM2
83+
run: |
84+
uv pip install -e ".[dev]" setuptools
85+
uv pip install --no-build-isolation-package sam-2 -e ".[dev,masks]"
86+
- name: Run SAM2 tests
87+
run: |
88+
# fail here, rather than skip the tests, if SAM2 did not install
89+
python -c "import sam2"
90+
pytest tests/test_unit/test_mask_video.py -k matches_sam2_predict
91+
5992
build_sdist_wheels:
6093
name: Build source distribution
6194
needs: [test]

0 commit comments

Comments
 (0)