|
56 | 56 | python-version: ${{ matrix.python-version }} |
57 | 57 | secret-codecov-token: ${{ secrets.CODECOV_TOKEN }} |
58 | 58 |
|
| 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 | +
|
59 | 92 | build_sdist_wheels: |
60 | 93 | name: Build source distribution |
61 | 94 | needs: [test] |
|
0 commit comments