Skip to content

Commit

Permalink
Simplify / polish the test suite (#108)
Browse files Browse the repository at this point in the history
* Simplify / polish the test suite

Signed-off-by: Fabrice Normandin <[email protected]>

* Remove the "local integration tests" step

Signed-off-by: Fabrice Normandin <[email protected]>

* Remove all regression files from base project

This makes sense, since they might vary based on which GPU is used.

Signed-off-by: Fabrice Normandin <[email protected]>

* Run pytest and ignore missing regression files

Signed-off-by: Fabrice Normandin <[email protected]>

---------

Signed-off-by: Fabrice Normandin <[email protected]>
  • Loading branch information
lebrice authored Feb 11, 2025
1 parent 4aa8445 commit 69ed612
Show file tree
Hide file tree
Showing 69 changed files with 214 additions and 20,873 deletions.
76 changes: 38 additions & 38 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,44 +84,44 @@ jobs:
name: coverage-reports-unit-tests-${{ matrix.platform }}-${{ matrix.python-version }}
path: ./coverage.xml

local_integration_tests:
needs: [unit_tests, check_docs]
runs-on: self-hosted
timeout-minutes: 30
strategy:
max-parallel: 1
matrix:
python-version: ["3.10"]
steps:
- uses: actions/checkout@v4
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v3
with:
version: "latest"
enable-cache: false # no need, uses the local uv cache.
# https://github.com/astral-sh/setup-uv?tab=readme-ov-file#github-authentication-token
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Pin python-version ${{ matrix.python-version }}
run: uv python pin ${{ matrix.python-version }}

- name: Install dependencies
run: uv sync --all-extras --frozen

- name: Test with pytest
run: uv run pytest -v --cov=project --cov-report=xml --cov-append

- name: Test with pytest (only slow tests)
run: uv run pytest -v -m slow --slow --cov=project --cov-report=xml --cov-append

- name: Store coverage report as an artifact
uses: actions/upload-artifact@v4
with:
name: coverage-reports-integration-tests-${{ matrix.python-version }}
path: ./coverage.xml
# local_integration_tests:
# needs: [unit_tests, check_docs]
# runs-on: self-hosted
# timeout-minutes: 30
# strategy:
# max-parallel: 1
# matrix:
# python-version: ["3.10"]
# steps:
# - uses: actions/checkout@v4
# - name: Install the latest version of uv
# uses: astral-sh/setup-uv@v3
# with:
# version: "latest"
# enable-cache: false # no need, uses the local uv cache.
# # https://github.com/astral-sh/setup-uv?tab=readme-ov-file#github-authentication-token
# github-token: ${{ secrets.GITHUB_TOKEN }}

# - name: Pin python-version ${{ matrix.python-version }}
# run: uv python pin ${{ matrix.python-version }}

# - name: Install dependencies
# run: uv sync --all-extras --frozen

# - name: Test with pytest
# run: uv run pytest -v --cov=project --cov-report=xml --cov-append

# - name: Test with pytest (only slow tests)
# run: uv run pytest -v -m slow --slow --cov=project --cov-report=xml --cov-append

# - name: Store coverage report as an artifact
# uses: actions/upload-artifact@v4
# with:
# name: coverage-reports-integration-tests-${{ matrix.python-version }}
# path: ./coverage.xml

launch-slurm-actions-runner:
needs: [local_integration_tests]
needs: [unit_tests, check_docs]
runs-on: self-hosted
timeout-minutes: 5
strategy:
Expand Down Expand Up @@ -166,7 +166,7 @@ jobs:
- name: Show installed packages
run: uv pip list
- name: Test with pytest
run: uv run pytest -v --cov=project --cov-report=xml --cov-append
run: uv run pytest -v --gen-missing --cov=project --cov-report=xml --cov-append

# TODO: Disabling full regression tests on the cluster for now, because the worker is often
# interrupted and we want to avoid using the unkillable partition to not interrupt other's
Expand All @@ -182,7 +182,7 @@ jobs:

# https://about.codecov.io/blog/uploading-code-coverage-in-a-separate-job-on-github-actions/
upload-coverage-codecov:
needs: [local_integration_tests, slurm_integration_tests]
needs: [slurm_integration_tests]
runs-on: ubuntu-latest
name: Upload coverage reports to Codecov
timeout-minutes: 5
Expand Down
6 changes: 4 additions & 2 deletions project/algorithms/jax_image_classifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,10 @@ def shared_step(
# This is the same thing as the `ImageClassifier.shared_step`!
x, y = batch
assert not x.requires_grad
assert self.network is not None
logits = self.network(x)
# This calls self.forward, and is preferable to calling self.network directly, since it
# allows forward hooks to be called. This is useful for example when testing or debugging.
logits = self(x)

assert isinstance(logits, torch.Tensor)
# In this example we use a jax "encoder" network and a PyTorch loss function, but we could
# also just as easily have done the whole forward and backward pass in jax if we wanted to.
Expand Down
Loading

0 comments on commit 69ed612

Please sign in to comment.