Skip to content

Commit

Permalink
Add coverage for Python torch bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
PicoCentauri committed Sep 21, 2023
1 parent 55ad1f1 commit d8930ac
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
1 change: 1 addition & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ fixes:
# map coverage collected inside tox virtual environments
# to the source dir in git
- ".tox/all-deps/lib/*/site-packages/::python/"
- ".tox/torch-tests/lib/*/site-packages/::python/"
9 changes: 7 additions & 2 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,15 @@ jobs:
lcov --remove coverage.info '/usr/*' "$(pwd)/rascaline-c-api/tests/*" "$(pwd)/rascaline-c-api/examples/*" --output-file coverage.info
- name: collect Python coverage
run: tox -e all-deps
run: |
tox -e all-deps
tox -e torch-tests
env:
# Use the CPU only version of torch when building/running the code
PIP_EXTRA_INDEX_URL: https://download.pytorch.org/whl/cpu

- name: upload to codecov.io
uses: codecov/codecov-action@v3
with:
fail_ci_if_error: true
files: target/tarpaulin/cobertura.xml,.tox/coverage.xml,coverage.info
files: target/tarpaulin/cobertura.xml,.tox/coverage-all-deps.xml,.tox/coverage-torch-tests.xml,coverage.info
6 changes: 4 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ metatensor-torch-requirement =
metatensor-torch @ https://github.com/lab-cosmo/metatensor/archive/2248a3c.zip\#subdirectory=python/metatensor-torch

build-single-wheel = --no-deps --no-build-isolation --check-build-dependencies
test_option = --cov={env_site_packages_dir}/metatensor --cov-report xml:{tox_root}/.tox/coverage-{env_name}.xml --import-mode=append

commands =
# error if the user gives a wrong testenv name in `tox -e`
Expand Down Expand Up @@ -55,7 +56,7 @@ deps =
pytest-cov

commands =
pytest --cov={env_site_packages_dir}/rascaline --cov-report xml:.tox/coverage.xml --import-mode=append {posargs}
pytest {[testenv]test_option} {posargs}


[testenv:min-deps]
Expand All @@ -73,6 +74,7 @@ deps =
{[testenv]metatensor-torch-requirement}

pytest
pytest-cov
numpy
torch
ase
Expand All @@ -85,7 +87,7 @@ commands =
# install rascaline-torch
pip install . {[testenv]build-single-wheel} --force-reinstall
# run the unit tests
pytest --import-mode=append --assert=plain {posargs}
pytest {[testenv]test_option} --assert=plain {posargs}

[testenv:docs]
deps =
Expand Down

0 comments on commit d8930ac

Please sign in to comment.