-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathtox.ini
More file actions
208 lines (181 loc) · 6.5 KB
/
Copy pathtox.ini
File metadata and controls
208 lines (181 loc) · 6.5 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
[tox]
min_version = 4
envlist = trainingdata, py, bandit, ruff_reformat, ruff_check, inference_CI, inference_multi_CI #, mypy, ruff_checkformat, prospector
skip_missing_interpreters = true
[testenv]; This is called py in envlist
description = Run pytest, coverage.
deps =
coverage
pytest
anemoi-datasets @ git+https://github.com/metno/anemoi-datasets.git@13397aa
anemoi-models @ git+https://github.com/metno/anemoi-models.git@80c9fbf
allowlist_externals =
ln
commands_pre =
# Link training data
ln -sf {toxworkdir}/bris_random_data.zarr {envtmpdir}/
commands =
coverage run --source=bris -m pytest
coverage report --omit='.tox/*'
parallel_show_output = true
[testenv:trainingdata]
description = Download synthetic data for use in other tests. Will download 80 MB from github. Result is placed in .tox/bris_random_data.zarr
; override default:
deps =
skip_install = true
change_dir = {envtmpdir}
allowlist_externals =
cp
wget
unzip
; override default:
commands_pre =
commands =
# Copy already downloaded data to the temp directory, if they exist.
- cp {toxworkdir}/main.zip {envtmpdir}/
# Download the data from github, if needed.
wget --no-clobber https://github.com/metno/bris-test-data/archive/refs/heads/main.zip
# Store downloaded data, so we don't have to download it again next run.
cp -af {envtmpdir}/main.zip {toxworkdir}/main.zip
# Unpack and move data to correct location.
unzip -qq {envtmpdir}/main.zip -d {envtmpdir}/
cp -af {envtmpdir}/bris-test-data-main/bris_random_data.zarr {toxworkdir}/
[testenv:bandit]
description = Check for security issues (ignoring asserts for now).
deps =
bandit[toml]
skip_install = true
; override default:
commands_pre =
commands = bandit --recursive --configfile pyproject.toml --exclude data bris
[testenv:ruff_checkformat]
description = Run ruff format and complain, without changing anything.
deps = ruff
skip_install = true
; override default:
commands_pre =
commands = ruff format --config pyproject.toml --check --diff
parallel_show_output = true
[testenv:ruff_reformat]
description = Reformat code with ruff format (similar to black).
deps = ruff
skip_install = true
; override default:
commands_pre =
commands = ruff format --config pyproject.toml
[testenv:ruff_check]
description = Run ruff check, a linter. Auto-fix only isort, see pyproject.toml.
deps = ruff
skip_install = true
; override default:
commands_pre =
commands = ruff check --config pyproject.toml --fix --exit-non-zero-on-fix
[testenv:inference]
description = Run inference on data from "trainingdata". Requires 'tox -e trainingdata' to have run successfully. Result end up in .tox/inference/tmp/. No usable data is generated.
; override default:
deps =
anemoi-datasets @ git+https://github.com/metno/anemoi-datasets.git@13397aa
anemoi-models @ git+https://github.com/metno/anemoi-models.git@80c9fbf
depends =
trainingdata
training
change_dir = {envtmpdir}
allowlist_externals =
cp
ln
find
commands_pre =
# Copy config file to temp directory.
cp -vf {toxinidir}/config/tox_test_inference.yaml {envtmpdir}/
# Find and copy checkpont from training to temp directory. There may be more than one, but that won't matter.
find {envtmpdir}/../../training/tmp/training-output/checkpoint -name inference-last.ckpt -exec cp -vf '{}' {envtmpdir}/ \;
# Link data from other tox environment.
ln -sf {toxworkdir}/bris_random_data.zarr {envtmpdir}/
commands = bris --config tox_test_inference.yaml
; Make sure output was created
commands_post =
find ./tox_test_inference.nc
[testenv:inference_CI]
description = Run inference using checkpoint from "trainingdata". Only for CI testing.
; override default:
deps =
depends = trainingdata
change_dir = {envtmpdir}
allowlist_externals =
cp
ln
find
commands_pre =
# Copy config file to temp directory.
cp -vf {toxinidir}/config/tox_test_inference.yaml {envtmpdir}/
# Copy checkpont from tests directory.
cp -vf ../../../tests/files/checkpoint.ckpt {envtmpdir}/inference-last.ckpt
# Link data from other tox environment.
ln -sf {toxworkdir}/bris_random_data.zarr {envtmpdir}/
pip install anemoi-models==0.4.2 # Override anemoi-models to match train environment
commands = bris --config tox_test_inference.yaml
commands_post =
; Make sure output was created, and delete it.
find ./tox_test_inference.nc -delete
[testenv:inference_multi_CI]
description = Run inference with MultiEncDecPredictor. Only for CI testing.
deps =
anemoi-datasets @ git+https://github.com/metno/anemoi-datasets.git@13397aa
anemoi-models @ git+https://github.com/metno/anemoi-models.git@80c9fbf
; @ git+https://github.com/metno/anemoi-models.git
depends = trainingdata
change_dir = {envtmpdir}
allowlist_externals =
cp
ln
find
commands_pre =
# Copy config file to temp directory.
cp -vf {toxinidir}/config/tox_test_inference_multi.yaml {envtmpdir}/
# Copy checkpont from tests directory.
cp ../../../tests/files/multiencdec.ckpt {envtmpdir}/inference-multi.ckpt
# Link data from other tox environment.
ln -sf {toxworkdir}/bris_random_data.zarr {envtmpdir}/
commands = bris --config tox_test_inference_multi.yaml
commands_post =
; Make sure output was created, and delete it.
find ./tox_test_inference.nc ./tox_test_inference_dec1.nc -delete
[testenv:prospector]
description = Run static analysis using prospector, dont fail on errors.
ignore_outcome = true
deps = prospector
; override default:
commands_pre =
commands = prospector --no-autodetect \
--test-warnings \
--die-on-tool-error \
{toxinidir}/bris
[testenv:mypy]
description = Check typing with mypy, dont fail on errors.
ignore_outcome = true
deps =
mypy
types-PyYAML
skip_install = false # Otherwise mypy will check outdated code
; override default:
commands_pre =
commands = mypy --config-file pyproject.toml bris
[testenv:training]
description = Run a test training on synthetic data. Slow! Will take about 5 minutes. Result end up in .tox/training/tmp/training-output.
depends = trainingdata
deps =
anemoi-training==0.3.3
anemoi-graphs==0.4.4
anemoi-models==0.4.1
skip_install = true
set_env = ANEMOI_BASE_SEED=1234
change_dir = {envtmpdir}
allowlist_externals =
cp
ln
commands_pre =
# Copy config file to the temp directory.
cp -vf {toxinidir}/config/tox_test_train.yaml {envtmpdir}/
# Link training data
ln -sf {toxworkdir}/bris_random_data.zarr {envtmpdir}/
commands = anemoi-training train --config-name tox_test_train