Skip to content

Commit

Permalink
tests: add pytest testmon plugin to speed up CI (#1402)
Browse files Browse the repository at this point in the history
* add pytest testmon plugin

* test changes to check testmon

* allow testmon and markers

* further improvements for uv and testmon

* add test comment

* fix caching, test changes in mcmc posterior

* fix uv setup

* fix uv setup

* fix uv setup

* fix uv setup

* another fix

* remove pip from ci

* undo changes to test testmon

* load testmon cache first

* restore old testmon setup

* reorder jobs

* test comment

* back to uv pip

* test change

* seems to be working 🎉
  • Loading branch information
janfb authored Feb 25, 2025
1 parent 49e091f commit e063c58
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
19 changes: 17 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,24 @@ jobs:
uv pip install torch --extra-index-url https://download.pytorch.org/whl/cpu
uv pip install -e .[dev]
- name: Cache uv dependencies
uses: actions/cache@v4
with:
path: ~/.cache/uv
key: uv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('pyproject.toml') }}
restore-keys: |
uv-${{ runner.os }}-${{ matrix.python-version }}-
- name: Cache testmon data
uses: actions/cache@v4
with:
path: .testmondata
key: testmon-${{ runner.os }}-${{ matrix.python-version }}-${{ github.ref }}
restore-keys: |
testmon-${{ runner.os }}-${{ matrix.python-version }}-
- name: Run the fast CPU tests with coverage
run: |
uv run pytest -v -x -n auto -m "not slow and not gpu" --cov=sbi --cov-report=xml tests/
run: uv run pytest --testmon-forceselect -v -n auto -m "not slow and not gpu" --cov=sbi --cov-report=xml tests/

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ dev = [
# Test
"pytest",
"pytest-cov",
"pytest-testmon",
"pytest-xdist",
"torchtestcase",
]
Expand Down
1 change: 0 additions & 1 deletion sbi/neural_nets/net_builders/mnle.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ def build_mnle(

# Set up a flow for modelling the continuous data, conditioned on the discrete data.
continuous_net = model_builders[flow_model](
# TODO: add support for optional log-transform in flow builders.
batch_x=(
torch.log(cont_x) if log_transform_x else cont_x
), # log transform manually.
Expand Down

0 comments on commit e063c58

Please sign in to comment.