-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathtox.ini
More file actions
298 lines (233 loc) · 9.78 KB
/
tox.ini
File metadata and controls
298 lines (233 loc) · 9.78 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
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
[tox]
# https://github.com/tox-dev/tox/issues/3238
requires = tox >=4.39
# 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
torch-tests-cxx
torch-install-tests-cxx
torch-tests
docs-tests
ase-tests
torchsim-tests
[testenv]
passenv = *
setenv =
# Do not use the user PYTHONPATH, tox is handling everything
PYTHONPATH=
# store code coverage in a per-env file, so different envs don't override each other
COVERAGE_FILE={env_dir}/.coverage
package = skip
lint_folders = "{toxinidir}/python" "{toxinidir}/setup.py"
build_single_wheel = --no-deps --no-build-isolation --check-build-dependencies
install_lj_tests = pip install {[testenv]build_single_wheel} git+https://github.com/metatensor/lj-test@2f74cf8
packaging_deps =
setuptools >= 77
packaging >=26
cmake
# for metatomic-lj-test
setuptools-scm
pip
testing_deps =
pytest
pytest-cov
metatensor_deps =
metatensor-torch >=0.8.0,<0.9
metatensor-operations >=0.4.0,<0.5
################################################################################
##### C++ tests setup #####
################################################################################
[testenv:torch-tests-cxx]
description = Run the C++ tests for metatomic-torch
deps =
cmake
{[testenv]metatensor_deps}
torch=={env:METATOMIC_TESTS_TORCH_VERSION:2.11}.*
commands =
# configure cmake
cmake -B {env_dir}/build metatomic-torch \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DCMAKE_PREFIX_PATH={env_site_packages_dir}/metatensor/;\
{env_site_packages_dir}/torch/;\
{env_site_packages_dir}/metatensor/torch/torch-{env:METATOMIC_TESTS_TORCH_VERSION:2.11}/ \
-DMETATOMIC_TORCH_TESTS=ON
# build code with cmake
cmake --build {env_dir}/build --config Debug --parallel
# run all tests
ctest --test-dir {env_dir}/build --build-config Debug --output-on-failure
[testenv:torch-install-tests-cxx]
description = Run the C++ tests for metatomic-torch
deps =
cmake
{[testenv]metatensor_deps}
torch=={env:METATOMIC_TESTS_TORCH_VERSION:2.11}.*
commands =
# configure, build and install metatomic-torch
cmake -B {env_dir}/build-metatomic-torch metatomic-torch \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_INSTALL_PREFIX={env_dir}/usr/ \
-DCMAKE_PREFIX_PATH={env_site_packages_dir}/metatensor/;\
{env_site_packages_dir}/torch/;\
{env_site_packages_dir}/metatensor/torch/torch-{env:METATOMIC_TESTS_TORCH_VERSION:2.11}/ \
-DCMAKE_BUILD_WITH_INSTALL_RPATH=ON \
-DCMAKE_INSTALL_RPATH_USE_LINK_PATH=ON
cmake --build {env_dir}/build-metatomic-torch --config Debug --parallel --target install
# try to use the installed metatomic-torch from another CMake project
cmake -B {env_dir}/build-find-package metatomic-torch/tests/cmake-project \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_PREFIX_PATH={env_site_packages_dir}/metatensor/;\
{env_site_packages_dir}/torch/;\
{env_site_packages_dir}/metatensor/torch/torch-{env:METATOMIC_TESTS_TORCH_VERSION:2.11}/;\
{env_dir}/usr/ \
-DUSE_CMAKE_SUBDIRECTORY=OFF
cmake --build {env_dir}/build-find-package --config Debug --parallel
ctest --test-dir {env_dir}/build-find-package --build-config Debug --output-on-failure
# Same, but using metatomic-torch as a CMake subdirectory
cmake -B {env_dir}/build-subdirectory metatomic-torch/tests/cmake-project \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_PREFIX_PATH={env_site_packages_dir}/metatensor/;\
{env_site_packages_dir}/torch/;\
{env_site_packages_dir}/metatensor/torch/torch-{env:METATOMIC_TESTS_TORCH_VERSION:2.11}/ \
-DUSE_CMAKE_SUBDIRECTORY=ON
cmake --build {env_dir}/build-subdirectory --config Debug --parallel
ctest --test-dir {env_dir}/build-subdirectory --build-config Debug --output-on-failure
################################################################################
##### Python tests setup #####
################################################################################
[testenv:torch-tests]
description = Run the tests of the metatomic-torch Python package
deps =
{[testenv]testing_deps}
{[testenv]packaging_deps}
{[testenv]metatensor_deps}
torch=={env:METATOMIC_TESTS_TORCH_VERSION:2.11}.*
numpy
vesin >=0.5.5,<0.6
vesin-torch >=0.5.5,<0.6
ase
changedir = python/metatomic_torch
commands =
pip install {[testenv]build_single_wheel} .
pip install {[testenv]build_single_wheel} ../metatomic_ase
# use the reference LJ implementation for tests
{[testenv]install_lj_tests}
# Make torch.autograd.gradcheck works with pytest
python {toxinidir}/scripts/pytest-dont-rewrite-torch.py
pytest --cov={env_site_packages_dir}/metatomic --cov-report= --import-mode=append {posargs}
[testenv:docs-tests]
description = Run the doctests defined in any metatomic package
deps =
{[testenv]testing_deps}
{[testenv]packaging_deps}
{[testenv]metatensor_deps}
torch=={env:METATOMIC_TESTS_TORCH_VERSION:2.11}.*
numpy
vesin >=0.5.5,<0.6
ase
commands =
pip install {[testenv]build_single_wheel} python/metatomic_torch
pip install {[testenv]build_single_wheel} python/metatomic_ase
pytest --doctest-modules --pyargs metatomic
################################################################################
##### Engine integration tests #####
################################################################################
[testenv:ase-tests]
description = Run the tests of the metatomic-ase Python package
deps =
{[testenv]testing_deps}
{[testenv]packaging_deps}
{[testenv]metatensor_deps}
torch=={env:METATOMIC_TESTS_TORCH_VERSION:2.11}.*
numpy
ase
vesin >=0.5.5,<0.6
nvalchemi-toolkit-ops >=0.3.0,<0.4
# for symmetrized calculator
scipy
spglib
# for heat flux tests
vesin-torch
changedir = python/metatomic_ase
commands =
pip install {[testenv]build_single_wheel} .
pip install {[testenv]build_single_wheel} ../metatomic_torch
# use the reference LJ implementation for tests
{[testenv]install_lj_tests}
pytest --cov={env_site_packages_dir}/metatomic_ase \
--cov={env_site_packages_dir}/metatomic \
--cov-report= \
--import-mode=append \
{posargs}
[testenv:torchsim-tests]
description = Run the tests of the metatomic-torchsim Python package
deps =
{[testenv]testing_deps}
{[testenv]packaging_deps}
{[testenv]metatensor_deps}
torch=={env:METATOMIC_TESTS_TORCH_VERSION:2.11}.*
numpy
vesin >=0.5.5,<0.6
ase
torch-sim-atomistic
nvalchemi-toolkit-ops >=0.3.0,<0.4
changedir = python/metatomic_torchsim
commands =
pip install {[testenv]build_single_wheel} .
pip install {[testenv]build_single_wheel} ../metatomic_torch
# use the reference LJ implementation for tests
{[testenv]install_lj_tests}
pytest --cov={env_site_packages_dir}/metatomic_torchsim --cov-report= --import-mode=append {posargs}
################################################################################
##### Linter and formatter setup #####
################################################################################
[testenv:lint]
description = Run linters and type checks
deps =
ruff
commands =
ruff format --diff {[testenv]lint_folders}
ruff check {[testenv]lint_folders}
[testenv:format]
description = Abuse tox to do actual formatting on all files.
deps =
ruff
commands =
ruff format {[testenv]lint_folders}
ruff check --fix-only {[testenv]lint_folders}
################################################################################
##### Documentation building #####
################################################################################
[testenv:docs]
description = build the documentation with sphinx
setenv =
# build the docs against the CPU only version of torch
PIP_EXTRA_INDEX_URL=https://download.pytorch.org/whl/cpu {env:PIP_EXTRA_INDEX_URL:}
deps =
{[testenv]metatensor_deps}
{[testenv]packaging_deps}
{[testenv]testing_deps}
sphinx == 7.4.*
sphinx-toggleprompt # hide the prompt (>>>) in python doctests
sphinx-gallery # convert python files into nice documentation
sphinx-sitemap # automatically generates sitemap
pygments # syntax highlighting
breathe # C and C++ => sphinx through doxygen
furo # sphinx theme
myst_parser # include markdown documents in sphinx
sphinx-design # helpers for nicer docs website (tabs, grids, cards, …)
sphinxcontrib-details-directive # hide some information by default in HTML
setuptools <82 # required for sphinxcontrib-details-directive
# required for autodoc
torch=={env:METATOMIC_TESTS_TORCH_VERSION:2.11}.*
torch-sim-atomistic >=0.5,<0.6
# required for examples
ase
vesin >=0.5.5,<0.6
chemiscope
commands =
pip install {[testenv]build_single_wheel} python/metatomic_torch
pip install {[testenv]build_single_wheel} python/metatomic_ase
pip install {[testenv]build_single_wheel} python/metatomic_torchsim
sphinx-build -d docs/build/doctrees -W -b html docs/src docs/build/html