From b149a06ab0e5b68615dbb8539fc9088ae44a4601 Mon Sep 17 00:00:00 2001 From: Sofiia Chorna Date: Wed, 8 Oct 2025 11:25:26 +0200 Subject: [PATCH 01/11] Change coverage configuration file --- .codecov.yml | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/.codecov.yml b/.codecov.yml index 6e139f8d45..c141750f2c 100644 --- a/.codecov.yml +++ b/.codecov.yml @@ -1,8 +1,20 @@ coverage: status: project: - default: + default: false + coverage: target: 88% + paths: + - "src/metatrain/utils/.*" + - "src/metatrain/cli/.*" + coverage_architectures: + paths: + - "src/metatrain/deprecated/.*" + - "src/metatrain/experimental/.*" + - "src/metatrain/gap/.*" + - "src/metatrain/pet/.*" + - "src/metatrain/soap_bpnn/.*" + - "src/metatrain/llpr/.*" patch: default: informational: true @@ -11,13 +23,6 @@ coverage: - "tests/.*" - "examples/.*" - "src/metatrain/utils/testing/.*" - # we don't check coverage for the architectures - - "src/metatrain/deprecated/.*" - - "src/metatrain/experimental/.*" - - "src/metatrain/gap/.*" - - "src/metatrain/pet/.*" - - "src/metatrain/soap_bpnn/.*" - - "src/metatrain/llpr/.*" # we don't currently run distributed tests on CI - "src/metatrain/utils/distributed/.*" From 6f6132554cc0f80ed79c9ebaeac6a8fffeef40ca Mon Sep 17 00:00:00 2001 From: Sofiia Chorna Date: Wed, 8 Oct 2025 11:55:13 +0200 Subject: [PATCH 02/11] Include pytest-cov to architecture tests --- tox.ini | 45 ++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 40 insertions(+), 5 deletions(-) diff --git a/tox.ini b/tox.ini index 8c5860ee6c..57cb307301 100644 --- a/tox.ini +++ b/tox.ini @@ -105,12 +105,19 @@ description = Run SOAP-BPNN tests with pytest passenv = * deps = pytest + pytest-cov spherical # tensor target tests cmake changedir = src/metatrain/soap_bpnn/tests/ +setenv = + COVERAGE_RUN = 1 commands = python -m pip install --no-build-isolation sphericart torch-spex>=0.1,<0.2 wigners cmake - pytest {posargs} + pytest \ + --cov=metatrain \ + --cov-append \ + --cov-report= \ + {posargs} [testenv:pet-tests] @@ -118,20 +125,34 @@ description = Run PET tests with pytest passenv = * deps = pytest + pytest-cov extras = pet changedir = src/metatrain/pet/tests/ +setenv = + COVERAGE_RUN = 1 commands = - pytest {posargs} + pytest \ + --cov=metatrain \ + --cov-append \ + --cov-report= \ + {posargs} [testenv:gap-tests] description = Run GAP tests with pytest passenv = * deps = pytest + pytest-cov extras = gap changedir = src/metatrain/gap/tests/ +setenv = + COVERAGE_RUN = 1 commands = - pytest {posargs} + pytest \ + --cov=metatrain \ + --cov-append \ + --cov-report= \ + {posargs} [testenv:nanopet-tests] description = Run NanoPET tests with pytest @@ -139,20 +160,34 @@ passenv = * deps = pytest spherical # for nanoPET spherical target + pytest-cov extras = nanopet changedir = src/metatrain/deprecated/nanopet/tests/ +setenv = + COVERAGE_RUN = 1 commands = - pytest {posargs} + pytest \ + --cov=metatrain \ + --cov-append \ + --cov-report= \ + {posargs} [testenv:llpr] description = Run LLPR tests with pytest passenv = * deps = pytest + pytest-cov extras = llpr changedir = src/metatrain/experimental/llpr/tests/ +setenv = + COVERAGE_RUN = 1 commands = - pytest {posargs} + pytest \ + --cov=metatrain \ + --cov-append \ + --cov-report= \ + {posargs} [testenv:docs] description = builds the documentation with sphinx From 48707f7ef6624d31b42b1a79ab074a7933b7ed63 Mon Sep 17 00:00:00 2001 From: Sofiia Chorna Date: Wed, 8 Oct 2025 11:56:35 +0200 Subject: [PATCH 03/11] Add llpr to envlist --- tox.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/tox.ini b/tox.ini index 57cb307301..971862aefd 100644 --- a/tox.ini +++ b/tox.ini @@ -10,6 +10,7 @@ envlist = soap-bpnn-tests pet-tests nanopet-tests + llpr [testenv] package = editable From ffe3471c14961f3918086d09a98e3755609e5428 Mon Sep 17 00:00:00 2001 From: Sofiia Chorna Date: Wed, 8 Oct 2025 12:04:42 +0200 Subject: [PATCH 04/11] Add architecture tests to github ci steps --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 6e98cbd68f..e4e00f47c8 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -41,7 +41,7 @@ jobs: - name: run Python tests and collect coverage run: | - tox -e tests + tox -e tests,gap-tests,soap-bpnn-tests,pet-tests,nanopet-tests,llpr coverage xml --data-file tests/.coverage env: # Use the CPU only version of torch when building/running the code From 1171997e0e979bd63df64295c775702eed0edb84 Mon Sep 17 00:00:00 2001 From: Sofiia Chorna Date: Wed, 8 Oct 2025 12:34:37 +0200 Subject: [PATCH 05/11] Add badge to doc --- docs/src/architectures/index.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/src/architectures/index.rst b/docs/src/architectures/index.rst index 26592310e8..f978eff2ab 100644 --- a/docs/src/architectures/index.rst +++ b/docs/src/architectures/index.rst @@ -3,6 +3,8 @@ Available Architectures ======================= +[![architecture coverage](https://codecov.io/gh/metatensor/metatrain/branch/main/graph/badge.svg?flag=coverage_architectures)](https://codecov.io/gh/metatensor/metatrain) + This is a list of all architectures available in ``metatrain``. .. toctree:: From e0d3c189bec9a96e6457264bfefff74b8eca3a72 Mon Sep 17 00:00:00 2001 From: Sofiia Chorna Date: Wed, 8 Oct 2025 13:22:24 +0200 Subject: [PATCH 06/11] Rename llpr to llpr-tests --- tox.ini | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tox.ini b/tox.ini index 971862aefd..09c0d7b0cc 100644 --- a/tox.ini +++ b/tox.ini @@ -10,7 +10,7 @@ envlist = soap-bpnn-tests pet-tests nanopet-tests - llpr + llpr-tests [testenv] package = editable @@ -173,7 +173,7 @@ commands = --cov-report= \ {posargs} -[testenv:llpr] +[testenv:llpr-tests] description = Run LLPR tests with pytest passenv = * deps = From d83af02b3b932146c58872b6777eee91fc8f6add Mon Sep 17 00:00:00 2001 From: Sofiia Chorna Date: Wed, 8 Oct 2025 13:41:01 +0200 Subject: [PATCH 07/11] Separate coverage configs and badges --- .codecov.yml | 13 ++++++++++--- docs/src/architectures/gap.rst | 2 ++ docs/src/architectures/index.rst | 2 -- docs/src/architectures/llpr.rst | 2 ++ docs/src/architectures/nanopet.rst | 2 ++ docs/src/architectures/pet.rst | 2 ++ docs/src/architectures/soap-bpnn.rst | 2 ++ 7 files changed, 20 insertions(+), 5 deletions(-) diff --git a/.codecov.yml b/.codecov.yml index c141750f2c..b3148f0fb1 100644 --- a/.codecov.yml +++ b/.codecov.yml @@ -7,14 +7,21 @@ coverage: paths: - "src/metatrain/utils/.*" - "src/metatrain/cli/.*" - coverage_architectures: + coverage_gap: paths: - - "src/metatrain/deprecated/.*" - - "src/metatrain/experimental/.*" - "src/metatrain/gap/.*" + coverage_pet: + paths: - "src/metatrain/pet/.*" + coverage_soap_bpnn: + paths: - "src/metatrain/soap_bpnn/.*" + coverage_llpr: + paths: - "src/metatrain/llpr/.*" + coverage_nanopet: + paths: + - "src/metatrain/deprecated/nanopet/.*" patch: default: informational: true diff --git a/docs/src/architectures/gap.rst b/docs/src/architectures/gap.rst index edd6afd05f..0dbcdcbb31 100644 --- a/docs/src/architectures/gap.rst +++ b/docs/src/architectures/gap.rst @@ -3,6 +3,8 @@ GAP === +[![GAP coverage](https://codecov.io/gh/metatensor/metatrain/branch/main/graph/badge.svg?flag=coverage_gap)](https://codecov.io/gh/metatensor/metatrain/tree/main/src/metatrain/gap) + This is an implementation of the sparse Gaussian Approximation Potential (GAP) :footcite:p:`bartok_representing_2013` using Smooth Overlap of Atomic Positions (SOAP) :footcite:p:`bartok_gaussian_2010` implemented in `featomic `_. diff --git a/docs/src/architectures/index.rst b/docs/src/architectures/index.rst index f978eff2ab..26592310e8 100644 --- a/docs/src/architectures/index.rst +++ b/docs/src/architectures/index.rst @@ -3,8 +3,6 @@ Available Architectures ======================= -[![architecture coverage](https://codecov.io/gh/metatensor/metatrain/branch/main/graph/badge.svg?flag=coverage_architectures)](https://codecov.io/gh/metatensor/metatrain) - This is a list of all architectures available in ``metatrain``. .. toctree:: diff --git a/docs/src/architectures/llpr.rst b/docs/src/architectures/llpr.rst index 4ba5a5a3b0..70ed20aba6 100644 --- a/docs/src/architectures/llpr.rst +++ b/docs/src/architectures/llpr.rst @@ -3,6 +3,8 @@ LLPR ==== +[![LLPR coverage](https://codecov.io/gh/metatensor/metatrain/branch/main/graph/badge.svg?flag=coverage_llpr)](https://codecov.io/gh/metatensor/metatrain/tree/main/src/metatrain/llpr) + The LLPR architecture is a "wrapper" architecture that enables cheap uncertainty quantification (UQ) via the last-layer prediction rigidity (LLPR) approach proposed by Bigi et al. :footcite:p:`bigi_mlst_2024` It is compatible with the following diff --git a/docs/src/architectures/nanopet.rst b/docs/src/architectures/nanopet.rst index 821c93a004..ab53a14a9c 100644 --- a/docs/src/architectures/nanopet.rst +++ b/docs/src/architectures/nanopet.rst @@ -3,6 +3,8 @@ NanoPET (deprecated) ====================== +[![NanoPET coverage](https://codecov.io/gh/metatensor/metatrain/branch/main/graph/badge.svg?flag=coverage_nanopet)](https://codecov.io/gh/metatensor/metatrain/tree/main/src/metatrain/deprecated/nanopet) + .. warning:: This is an **deprecated model**. You should not use it for anything important, and diff --git a/docs/src/architectures/pet.rst b/docs/src/architectures/pet.rst index ddf04a9879..1ba12c2b61 100644 --- a/docs/src/architectures/pet.rst +++ b/docs/src/architectures/pet.rst @@ -3,6 +3,8 @@ PET === +[![PET coverage](https://codecov.io/gh/metatensor/metatrain/branch/main/graph/badge.svg?flag=coverage_pet)](https://codecov.io/gh/metatensor/metatrain/tree/main/src/metatrain/pet) + PET is a cleaner, more user-friendly reimplementation of the original PET model :footcite:p:`pozdnyakov_smooth_2023`. It is designed for better modularity and maintainability, while preseving compatibility with the original diff --git a/docs/src/architectures/soap-bpnn.rst b/docs/src/architectures/soap-bpnn.rst index fd79440d31..f9977aa4cf 100644 --- a/docs/src/architectures/soap-bpnn.rst +++ b/docs/src/architectures/soap-bpnn.rst @@ -3,6 +3,8 @@ SOAP-BPNN ========= +[![SOAP-BPNN coverage](https://codecov.io/gh/metatensor/metatrain/branch/main/graph/badge.svg?flag=coverage_soap_bpnn)](https://codecov.io/gh/metatensor/metatrain/tree/main/src/metatrain/soap_bpnn) + This is a Behler-Parrinello type neural network :footcite:p:`behler_generalized_2007`, which, instead of their original atom-centered symmetry functions, we use the Smooth overlap of atomic positions (SOAP) :footcite:p:`bartok_representing_2013` as the atomic From 774b33bc2e8e672d9b10da9a047186ff896d9d45 Mon Sep 17 00:00:00 2001 From: Sofiia Chorna Date: Wed, 8 Oct 2025 14:19:56 +0200 Subject: [PATCH 08/11] Move coverage checks to architectures test workflow --- .github/workflows/architecture-tests.yml | 23 ++++++++++-- .github/workflows/tests.yml | 2 +- tox.ini | 46 ++++-------------------- 3 files changed, 27 insertions(+), 44 deletions(-) diff --git a/.github/workflows/architecture-tests.yml b/.github/workflows/architecture-tests.yml index 4f412c5f49..ca1fccd442 100644 --- a/.github/workflows/architecture-tests.yml +++ b/.github/workflows/architecture-tests.yml @@ -18,6 +18,12 @@ jobs: - llpr - pet - nanopet + codecov-flag: + - coverage_gap + - coverage_soap_bpnn + - coverage_llpr + - coverage_pet + - coverage_nanopet runs-on: ubuntu-22.04 @@ -28,10 +34,21 @@ jobs: uses: actions/setup-python@v6 with: python-version: "3.13" - - run: pip install tox + - run: pip install tox coverage[toml] - - name: run architecture tests - run: tox -e ${{ matrix.architecture-name }}-tests + - name: run architecture tests and generate coverage + run: | + coverage erase + coverage run --source src/metatrain \ + $(which tox) -e ${{ matrix.architecture-name }}-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@v5 + with: + fail_ci_if_error: false + files: .coverage + flags: ${{ matrix.codecov-flag }} + token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index e4e00f47c8..6e98cbd68f 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -41,7 +41,7 @@ jobs: - name: run Python tests and collect coverage run: | - tox -e tests,gap-tests,soap-bpnn-tests,pet-tests,nanopet-tests,llpr + tox -e tests coverage xml --data-file tests/.coverage env: # Use the CPU only version of torch when building/running the code diff --git a/tox.ini b/tox.ini index 09c0d7b0cc..4802d50c5e 100644 --- a/tox.ini +++ b/tox.ini @@ -106,19 +106,13 @@ description = Run SOAP-BPNN tests with pytest passenv = * deps = pytest - pytest-cov spherical # tensor target tests cmake changedir = src/metatrain/soap_bpnn/tests/ -setenv = - COVERAGE_RUN = 1 commands = python -m pip install --no-build-isolation sphericart torch-spex>=0.1,<0.2 wigners cmake - pytest \ - --cov=metatrain \ - --cov-append \ - --cov-report= \ - {posargs} + pytest {posargs} + [testenv:pet-tests] @@ -126,34 +120,20 @@ description = Run PET tests with pytest passenv = * deps = pytest - pytest-cov extras = pet changedir = src/metatrain/pet/tests/ -setenv = - COVERAGE_RUN = 1 commands = - pytest \ - --cov=metatrain \ - --cov-append \ - --cov-report= \ - {posargs} + pytest {posargs} [testenv:gap-tests] description = Run GAP tests with pytest passenv = * deps = pytest - pytest-cov extras = gap changedir = src/metatrain/gap/tests/ -setenv = - COVERAGE_RUN = 1 commands = - pytest \ - --cov=metatrain \ - --cov-append \ - --cov-report= \ - {posargs} + pytest {posargs} [testenv:nanopet-tests] description = Run NanoPET tests with pytest @@ -161,34 +141,20 @@ passenv = * deps = pytest spherical # for nanoPET spherical target - pytest-cov extras = nanopet changedir = src/metatrain/deprecated/nanopet/tests/ -setenv = - COVERAGE_RUN = 1 commands = - pytest \ - --cov=metatrain \ - --cov-append \ - --cov-report= \ - {posargs} + pytest {posargs} [testenv:llpr-tests] description = Run LLPR tests with pytest passenv = * deps = pytest - pytest-cov extras = llpr changedir = src/metatrain/experimental/llpr/tests/ -setenv = - COVERAGE_RUN = 1 commands = - pytest \ - --cov=metatrain \ - --cov-append \ - --cov-report= \ - {posargs} + pytest {posargs} [testenv:docs] description = builds the documentation with sphinx From cc16998774f067369cd9fa9a450dfdc117fc29a2 Mon Sep 17 00:00:00 2001 From: Sofiia Chorna Date: Wed, 8 Oct 2025 14:32:47 +0200 Subject: [PATCH 09/11] Fix path to llpr --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 4802d50c5e..230f03793c 100644 --- a/tox.ini +++ b/tox.ini @@ -152,7 +152,7 @@ passenv = * deps = pytest extras = llpr -changedir = src/metatrain/experimental/llpr/tests/ +changedir = src/metatrain/llpr/tests/ commands = pytest {posargs} From e96653a3e1ce0aaf3ad4e2ac37da3d57208a913f Mon Sep 17 00:00:00 2001 From: Sofiia Chorna Date: Wed, 8 Oct 2025 14:49:39 +0200 Subject: [PATCH 10/11] Fix codecov-flag duplications --- .github/workflows/architecture-tests.yml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/.github/workflows/architecture-tests.yml b/.github/workflows/architecture-tests.yml index ca1fccd442..e81e15aab9 100644 --- a/.github/workflows/architecture-tests.yml +++ b/.github/workflows/architecture-tests.yml @@ -18,12 +18,6 @@ jobs: - llpr - pet - nanopet - codecov-flag: - - coverage_gap - - coverage_soap_bpnn - - coverage_llpr - - coverage_pet - - coverage_nanopet runs-on: ubuntu-22.04 @@ -50,5 +44,5 @@ jobs: with: fail_ci_if_error: false files: .coverage - flags: ${{ matrix.codecov-flag }} + flags: coverage_${{ matrix.architecture-name }} token: ${{ secrets.CODECOV_TOKEN }} From 0f625a220b0924d93a267193adcf40bc6f7d5eac Mon Sep 17 00:00:00 2001 From: Sofiia Chorna Date: Wed, 8 Oct 2025 14:50:26 +0200 Subject: [PATCH 11/11] Delete additional spacing --- tox.ini | 2 -- 1 file changed, 2 deletions(-) diff --git a/tox.ini b/tox.ini index 230f03793c..91b78015b0 100644 --- a/tox.ini +++ b/tox.ini @@ -113,8 +113,6 @@ commands = python -m pip install --no-build-isolation sphericart torch-spex>=0.1,<0.2 wigners cmake pytest {posargs} - - [testenv:pet-tests] description = Run PET tests with pytest passenv = *