Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-enable testing on macos-latest #361

Merged
merged 37 commits into from
Mar 28, 2025
Merged
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
1261a5d
put osx back in matrix for test workflow
ejm714 Mar 19, 2025
c673552
run test workflow is test workflow yml file changes
ejm714 Mar 19, 2025
242e096
cache weights on mac too
ejm714 Mar 19, 2025
c15af6a
set env variable to address mps error
ejm714 Mar 19, 2025
b80142f
test macos-13 since supposedly latest does not have access to mps har…
ejm714 Mar 19, 2025
b315e05
test forcing cpu for macos
ejm714 Mar 19, 2025
0057e94
code quality
ejm714 Mar 19, 2025
ad82276
attempt mps fallback
ejm714 Mar 19, 2025
d52086c
support gpus as cli arg for predict; force cpu for macos runner
ejm714 Mar 19, 2025
6202666
remove unused env var + code improvements
ejm714 Mar 19, 2025
6f6222f
debug
ejm714 Mar 19, 2025
ad29423
run tests without parallelism
ejm714 Mar 20, 2025
d37cd4e
temporarily hard code in training
ejm714 Mar 20, 2025
2b870ef
clear cache manually
ejm714 Mar 20, 2025
2db3e76
only clear cache if mps backend is available
ejm714 Mar 20, 2025
6bdb329
use cpu for megadetector; hard code temporarily in predict
ejm714 Mar 21, 2025
c6364e9
clean up; set on other detector; set env in workflow
ejm714 Mar 21, 2025
60b81ab
fix env; test PYTORCH_ENABLE_MPS_FALLBACK
ejm714 Mar 21, 2025
7a2b70b
experiment
ejm714 Mar 21, 2025
468e87b
remove unneeded env var
ejm714 Mar 21, 2025
7a2171c
code review comments
ejm714 Mar 21, 2025
5b3d236
attempt to only run macos on workflow trigger or scheduled run
ejm714 Mar 21, 2025
6f5b5ab
fixes
ejm714 Mar 21, 2025
dfd9fe9
fix logic
ejm714 Mar 21, 2025
a17612f
set up input for manual trigger
ejm714 Mar 21, 2025
0eccc7d
test strategy
ejm714 Mar 21, 2025
c41c59e
things are getting complicated
ejm714 Mar 22, 2025
7918ab7
fix yaml
ejm714 Mar 22, 2025
d51ac25
github copilot suggestions
ejm714 Mar 22, 2025
8dd45f0
remove brackets
ejm714 Mar 22, 2025
f05de32
put things in quotes
ejm714 Mar 22, 2025
eb447b4
change quotation
ejm714 Mar 22, 2025
08df002
Set up os matrix job
jayqi Mar 28, 2025
831bb22
Set python-version to create a venv
jayqi Mar 28, 2025
05a0279
Add quotes
jayqi Mar 28, 2025
99ec352
Actually fix quotes
jayqi Mar 28, 2025
6521438
Fix python version matrix
jayqi Mar 28, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 67 additions & 17 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -5,15 +5,28 @@ on:
branches: [master]
paths:
- "zamba/**"
- "pyproject.toml"
- ".github/workflows/tests.yml"
pull_request:
branches:
- master
paths:
- "zamba/**"
- "pyproject.toml"
- ".github/workflows/tests.yml"
schedule:
# Run every Sunday
- cron: '0 0 * * 0'
workflow_dispatch:
inputs:
chosen-os:
description: 'OS to run on'
required: true
type: choice
default: ubuntu-latest
options:
- ubuntu-latest
- macos-latest

env:
MODEL_CACHE_DIR: ${{ github.workspace }}/.zamba-weights
@@ -22,14 +35,16 @@ jobs:
code-quality:
name: Code Quality
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up Python and uv
uses: drivendataorg/setup-python-uv-action@v1
- uses: astral-sh/setup-uv@v5
with:
python-version: 3.11
python-version: "3.11"
enable-cache: true
cache-suffix: "lint"
cache-dependency-glob: |
requirements-dev/lint.txt

- name: Install dependencies
run: |
@@ -39,17 +54,46 @@ jobs:
run: |
make lint


set-up-os-matrix:
name: "Set up OS matrix"
needs: code-quality
runs-on: ubuntu-latest
outputs:
os_matrix: ${{ steps.step.outputs.os_matrix }}
steps:
- name: Set up OS matrix
id: step
run: |
if [[ ${{ github.event_name }} = 'schedule' ]]; then
MATRIX='["ubuntu-latest", "macos-latest"]'
elif [[ ${{ github.event_name }} = 'workflow_dispatch' ]]; then
MATRIX='["${{ inputs.chosen-os }}"]'
else
MATRIX='["ubuntu-latest"]'
fi
echo "$MATRIX"
echo "os_matrix=$MATRIX" >> "$GITHUB_OUTPUT"


cache-model-weights:
name: Download or use cached model weights
runs-on: ubuntu-latest
needs: set-up-os-matrix
strategy:
matrix:
os: ${{ fromJson(needs.set-up-os-matrix.outputs.os_matrix) }}
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v4

- name: Set up Python and uv
uses: drivendataorg/setup-python-uv-action@v1
- uses: astral-sh/setup-uv@v5
with:
python-version: 3.11
python-version: "3.11"
enable-cache: true
cache-suffix: "cache-weights"
cache-dependency-glob: |
pyproject.toml

- name: Install dependencies
run: |
@@ -67,14 +111,14 @@ jobs:

tests:
name: Test suite (${{ matrix.os }}, Python ${{ matrix.python-version }})
needs: [code-quality, cache-model-weights]
runs-on: ${{ matrix.os }}
needs: [set-up-os-matrix, cache-model-weights]
env:
DISTUTILS_USE_SDK: 1 # for MSVC compiler
strategy:
matrix:
os: [ubuntu-latest]
os: ${{ fromJson(needs.set-up-os-matrix.outputs.os_matrix) }}
python-version: [3.11, 3.12]
runs-on: ${{ matrix.os }}

steps:
- if: matrix.os == 'ubuntu-latest'
@@ -118,10 +162,13 @@ jobs:
- name: Configure Windows compilers
uses: ilammy/msvc-dev-cmd@v1

- name: Set up Python and uv
uses: drivendataorg/setup-python-uv-action@v1
- uses: astral-sh/setup-uv@v5
with:
python-version: ${{ matrix.python-version }}
enable-cache: true
cache-suffix: "tests-${{ matrix.python-version }}"
cache-dependency-glob: |
pyproject.toml

- name: Install dependencies
run: |
@@ -150,7 +197,7 @@ jobs:
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.xml
fail_ci_if_error: true
fail_ci_if_error: ${{ (github.event_name == 'push' && true) || (github.event_name == 'pull_request' && true) || false }}

test-install:
name: Test install from built distributions
@@ -185,10 +232,13 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}
version: "4.4"

- name: Set up Python and uv
uses: drivendataorg/setup-python-uv-action@v1
- uses: astral-sh/setup-uv@v5
with:
python-version: ${{ matrix.python-version }}
enable-cache: true
cache-suffix: "test-install-${{ matrix.python-version }}"
cache-dependency-glob: |
pyproject.toml

- name: Build package
run: |
@@ -213,7 +263,7 @@ jobs:

notify:
name: Notify failed build
needs: [code-quality, tests, test-install]
needs: [code-quality, set-up-os-matrix, tests, test-install]
if: failure() && (github.event_name == 'push' || github.event_name == 'schedule')
runs-on: ubuntu-latest
steps:
2 changes: 1 addition & 1 deletion tests/test_cli.py
Original file line number Diff line number Diff line change
@@ -191,7 +191,7 @@ def test_actual_prediction_on_single_video(tmp_path, model): # noqa: F811


def test_actual_prediction_on_images(tmp_path, mocker): # noqa: F811
"""Tests experimental feature of predicting on images."""
"""Test predicting on images."""
shutil.copytree(ASSETS_DIR / "images", tmp_path / "images")
data_dir = tmp_path / "images"

4 changes: 3 additions & 1 deletion zamba/images/data.py
Original file line number Diff line number Diff line change
@@ -111,7 +111,9 @@ def preprocess_annotations(self, annotations: pd.DataFrame) -> pd.DataFrame:
annotations = pd.DataFrame(processed_annotations)
else:
processed_annotations = []
detector = run_detector.load_detector("MDV5A")
detector = run_detector.load_detector(
"MDV5A", force_cpu=(os.getenv("RUNNER_OS") == "macOS")
)
for _, row in tqdm(
annotations.iterrows(),
total=len(annotations),
2 changes: 1 addition & 1 deletion zamba/images/manager.py
Original file line number Diff line number Diff line change
@@ -56,7 +56,7 @@ def predict(config: ImageClassificationPredictConfig) -> None:
]
)
logger.info("Loading models")
detector = run_detector.load_detector("MDV5A")
detector = run_detector.load_detector("MDV5A", force_cpu=(os.getenv("RUNNER_OS") == "macOS"))
classifier_module = instantiate_model(
checkpoint=config.checkpoint,
)