Skip to content

Commit ec1b598

Browse files
Split tests (#985)
* move ase tests to separate test run, use pytest-split on rest of tests, 3 runs per linux version * add test durations for split * update test split, run notebook test as separate test, update test time * move jupyter notebook test into ase * tweak some clean_dir to tmp_dir to prevent unncessary test file creation * reduce to 4 splits * go back to 3 splits * try to get better ci timing estimate per @janosh's suggestion * fix test split cmd * revert pytest split change for separate pr * sync with ase branch and add test split logic / times * tweak wf * change pytest split algo, see if 5 splits works better for balancing * change to 3 splits * change gruneisen test for time use - just make phonon maker cheaper * add ase to phonon supported codes, enforce string literal in BasePhononMaker * update timing for gruneisen * try to fix ci test wf * ci test wf * merge conflict fixes, try reorg tests * pcmt, other tweaks * remove lingering ase frechet filter remarks --------- Co-authored-by: Janosh Riebesell <janosh.riebesell@gmail.com>
1 parent a24649e commit ec1b598

File tree

5 files changed

+21
-9
lines changed

5 files changed

+21
-9
lines changed

.github/workflows/deploy.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ jobs:
2828
- name: Install dependencies
2929
run: |
3030
python -m pip install --upgrade pip
31-
# ase needed to get FrechetCellFilter used by ML force fields
32-
pip install git+https://gitlab.com/ase/ase
3331
pip install .[strict,docs]
3432
3533
- name: Build

.github/workflows/docs.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ jobs:
3333
- name: Install dependencies
3434
run: |
3535
python -m pip install --upgrade pip
36-
# ase needed to get FrechetCellFilter used by ML force fields
37-
pip install git+https://gitlab.com/ase/ase
3836
pip install .[strict,docs]
3937
4038
- name: Build

.github/workflows/testing.yml

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ jobs:
2323

2424
- uses: pre-commit/action@v3.0.0
2525

26-
test:
26+
test-non-ase:
27+
# prevent this action from running on forks
28+
if: github.repository == 'materialsproject/atomate2'
29+
2730
services:
2831
local_mongodb:
2932
image: mongo:4.0
@@ -37,6 +40,7 @@ jobs:
3740
strategy:
3841
matrix:
3942
python-version: ["3.10", "3.11", "3.12"]
43+
split: [1, 2, 3]
4044

4145
steps:
4246
- name: Check out repo
@@ -72,20 +76,30 @@ jobs:
7276
micromamba activate a2
7377
uv pip install --upgrade 'git+https://github.com/materialsproject/pymatgen@${{ github.event.client_payload.pymatgen_ref }}'
7478
75-
- name: Test
79+
- name: Test split ${{ matrix.split }}
7680
env:
7781
MP_API_KEY: ${{ secrets.MP_API_KEY }}
82+
83+
# regenerate durations file with `pytest --store-durations --durations-path tests/.pytest-split-durations`
84+
# Note the use of `--splitting-algorithm least_duration`.
85+
# This helps prevent a test split having no tests to run, and then the GH action failing, see:
86+
# https://github.com/jerry-git/pytest-split/issues/95
87+
# However this `splitting-algorithm` means that tests cannot depend sensitively on the order they're executed in.
7888
run: |
7989
micromamba activate a2
80-
pytest --ignore=tests/ase --cov=atomate2 --cov-report=xml
90+
pytest --splits 3 --group ${{ matrix.split }} --durations-path tests/.pytest-split-durations --splitting-algorithm least_duration --ignore=tests/ase --cov=atomate2 --cov-report=xml
8191
8292
- uses: codecov/codecov-action@v1
8393
if: matrix.python-version == '3.10' && github.repository == 'materialsproject/atomate2'
8494
with:
8595
token: ${{ secrets.CODECOV_TOKEN }}
96+
name: coverage${{ matrix.split }}
8697
file: ./coverage.xml
8798

8899
test-notebooks-and-ase:
100+
# prevent this action from running on forks
101+
if: github.repository == 'materialsproject/atomate2'
102+
89103
# It seems like anything torch-dependent and tblite can't be installed in the same environment
90104
# without the tblite tests failing in CI, see, e.g.:
91105
# https://github.com/tblite/tblite/issues/116
@@ -143,7 +157,7 @@ jobs:
143157
MP_API_KEY: ${{ secrets.MP_API_KEY }}
144158
run: |
145159
micromamba activate a2
146-
pytest --cov=atomate2 --cov-report=xml tests/ase
160+
pytest --splits 1 --group 1 --cov=atomate2 --cov-report=xml tests/ase
147161
148162
- uses: codecov/codecov-action@v1
149163
if: matrix.python-version == '3.10' && github.repository == 'materialsproject/atomate2'
@@ -172,7 +186,7 @@ jobs:
172186
run: sphinx-build docs docs_build
173187

174188
automerge:
175-
needs: [lint, test, docs]
189+
needs: [lint, test-non-ase, test-notebooks-and-ase, docs]
176190
runs-on: ubuntu-latest
177191

178192
permissions:

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ tests = [
8686
"nbmake==1.5.4",
8787
"pytest-cov==5.0.0",
8888
"pytest-mock==3.14.0",
89+
"pytest-split==0.9.0",
8990
"pytest==8.3.3",
9091
]
9192
strict = [

tests/.pytest-split-durations

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)