-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathtox.ini
More file actions
261 lines (246 loc) · 6.7 KB
/
tox.ini
File metadata and controls
261 lines (246 loc) · 6.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
[tox]
min_version = 4.0
requires =
tox>=4.31
tox-uv>=1.23
# these are the default environments, i.e. the list of tests running when you
# execute `tox` in the command-line without anything else
envlist =
lint
build
tests
gap-tests
soap-bpnn-tests
pet-tests
flashmd-tests
llpr-tests
classifier-tests
mace-tests
phace-tests
[testenv]
package = wheel
wheel_build_env = .pkg
passenv = *
setenv =
UV_EXTRA_INDEX_URL = {env:PIP_EXTRA_INDEX_URL:}
UV_INDEX_STRATEGY = unsafe-best-match
COVERAGE_FILE = {toxinidir}/.coverage
lint_folders =
"{toxinidir}/developer/" \
"{toxinidir}/examples/" \
"{toxinidir}/src/" \
"{toxinidir}/tests/" \
"{toxinidir}/docs/src/"
# We apply stricter checks on the main code, but not on tests, examples, or
# external architectures
lint_strict_folders =
"{toxinidir}/src/metatrain/cli" \
"{toxinidir}/src/metatrain/utils" \
"{toxinidir}/src/metatrain/llpr" \
"{toxinidir}/src/metatrain/pet" \
"{toxinidir}/src/metatrain/gap" \
"{toxinidir}/src/metatrain/soap_bpnn"
exclude_tests_regex = "(^|/)[^/]*test[^/]*$"
exclude_tests_glob = "**/*test*"
[testenv:lint]
description = Run linters and type checks
package = skip
deps =
ruff
mypy
sphinx-lint
yamlfix
pydoclint
commands =
ruff format --diff {[testenv]lint_folders}
ruff check {[testenv]lint_folders} {posargs}
python {toxinidir}/developer/jsonfix.py --check {[testenv]lint_folders}
yamlfix --check {[testenv]lint_folders} -e "**/outputs/**/*.yaml"
mypy {[testenv]lint_folders}
sphinx-lint \
--enable all \
--disable line-too-long \
-i "{toxinidir}/docs/src/generated_examples" \
{[testenv]lint_folders} "{toxinidir}/README.md"
# Stricter checks on the main code
# Check type annotations
mypy --exclude {[testenv]exclude_tests_regex} \
--disallow-untyped-defs \
{[testenv]lint_strict_folders}
# Check docstrings match with function signature
pydoclint \
--exclude {[testenv]exclude_tests_regex} \
{[testenv]lint_strict_folders}
[testenv:format]
description = Abuse tox to do actual formatting on all files.
package = skip
deps =
ruff
yamlfix
commands =
ruff format {[testenv]lint_folders}
ruff check --fix-only {[testenv]lint_folders} "{toxinidir}/README.md" {posargs}
python {toxinidir}/developer/jsonfix.py {[testenv]lint_folders}
yamlfix {[testenv]lint_folders} -e "**/outputs/**"
[testenv:tests]
description = Run basic package tests with pytest (not the architectures)
passenv = *
deps =
pytest
pytest-cov
pytest-xdist
spherical
torch-pme >= 0.3.2 # for long-range tests
wandb >= 0.23 # Lower versions emit warnings with pydantic>=2.12
cmake
changedir = tests
extras = # architectures used in the package tests
soap-bpnn
pet
setenv =
COVERAGE_RUN = 1
allowlist_externals =
bash
commands =
pytest \
--numprocesses=auto \
--cov=metatrain \
--cov-append \
--cov-report=term \
--import-mode=append \
{posargs}
[testenv:build]
description = builds the package and checks integrity
usedevelop = true
deps =
build
check-manifest
twine
allowlist_externals =
bash
commands_pre =
bash -c "rm -f dist/*.whl"
bash -c "rm -f dist/*.tar.gz"
# these files are created by other tests but make `check-manifest` fail
bash -c "find . -name 'model_0.ckpt' -delete"
commands =
python -m build
twine check dist/*.tar.gz dist/*.whl
check-manifest {toxinidir}
[testenv:soap-bpnn-tests]
description = Run SOAP-BPNN tests with pytest and collect coverage
passenv = *
deps =
pytest
pytest-cov
spherical # tensor target tests
cmake
extras = soap-bpnn
changedir = src/metatrain/soap_bpnn/tests/
commands =
pytest --cov=metatrain.soap_bpnn --cov-append --cov-report=term {posargs}
[testenv:pet-tests]
description = Run PET tests with pytest and collect coverage
passenv = *
deps =
pytest
pytest-cov
extras = pet
changedir = src/metatrain/pet/tests/
commands =
pytest --cov=metatrain.pet --cov-append --cov-report=term {posargs}
[testenv:gap-tests]
description = Run GAP tests with pytest and collect coverage
passenv = *
deps =
pytest
pytest-cov
extras = gap
changedir = src/metatrain/gap/tests/
commands =
pytest --cov=metatrain.gap --cov-append --cov-report=term {posargs}
[testenv:llpr-tests]
description = Run LLPR tests with pytest and collect coverage
passenv = *
deps =
pytest
pytest-cov
extras =
llpr
pet
changedir = src/metatrain/llpr/tests/
commands =
pytest --cov=metatrain.llpr --cov-append --cov-report=term {posargs}
[testenv:flashmd-tests]
description = Run FlashMD tests with pytest and collect coverage
passenv = *
deps =
pytest
pytest-cov
extras = flashmd
changedir = src/metatrain/experimental/flashmd/tests/
commands =
pytest --cov=metatrain.experimental.flashmd --cov-append --cov-report=term {posargs}
[testenv:phace-tests]
description = Run PhACE tests with pytest and collect coverage
passenv = *
deps =
pytest
pytest-cov
spherical # tensor target tests
extras = phace
changedir = src/metatrain/experimental/phace/tests/
commands =
pytest --cov=metatrain.experimental.phace --cov-append --cov-report=term {posargs}
[testenv:classifier-tests]
description = Run Classifier tests with pytest and collect coverage
passenv = *
deps =
pytest
pytest-cov
extras =
classifier
pet
changedir = src/metatrain/experimental/classifier/tests/
commands =
pytest --cov=metatrain.experimental.classifier --cov-append --cov-report=term {posargs}
[testenv:mace-tests]
description = Run MetaMACE tests with pytest and collect coverage
passenv = *
deps =
pytest
pytest-cov
spherical
extras = mace
changedir = src/metatrain/experimental/mace/tests/
commands =
pytest --cov=metatrain.experimental.mace --cov-append --cov-report=term {posargs}
[testenv:docs]
description = builds the documentation with sphinx
deps =
-r docs/requirements.txt
cmake
allowlist_externals =
bash
extras = # these architectures are used in the documentation
gap
pet
flashmd
soap-bpnn
mace
commands =
# Run all .sh files in the example folder (including subfolders)
bash -c "set -e && for f in $(find examples -name '*.sh'); do cd $(dirname $f); bash $(basename $f); cd -; done"
sphinx-build \
{posargs:-E} \
--builder html \
--doctree-dir docs/build/doctree \
--fail-on-warning \
docs/src docs/build/html
[testenv:check-cuda-available]
description = tests that CUDA is available
passenv = *
deps =
torch
commands =
python -c "import torch; assert(torch.cuda.is_available() and torch.version.cuda)"