-
Notifications
You must be signed in to change notification settings - Fork 5
333 lines (274 loc) · 16.8 KB
/
ci.yaml
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
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
name: CI
on:
push:
branches:
- main
pull_request:
schedule:
- cron: '5 0 * * *'
jobs:
ruff:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Ruff check
run: |
python -m pip install ruff
ruff check
typos:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: crate-ci/typos@master
examples:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
python-version: ['3.10', '3.11', '3.12', '3.13', '3.x']
os: [ubuntu-latest, macos-13]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }} on ${{ matrix.os }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install prerequisites
run: |
[[ $(uname) == "Darwin" ]] && brew install open-mpi
[[ $(uname) == "Linux" ]] && sudo apt-get update && sudo apt-get install -y mpich libmpich-dev
pip install wheel matplotlib mpi4py psutil
pip install -e .
- name: Run and test examples
run: |
set -x
python examples/log.py
runalyzer-gather summary.sqlite log.sqlite
runalyzer -m summary.sqlite -c 'dbplot(q("select $t_sim, $t_step"))'
# Perform some simple tests on the output file
## Check for warnings and logging
runalyzer summary.sqlite -c 'db.print_cursor(db.q("select * from warnings"))'
runalyzer summary.sqlite -c 'db.print_cursor(db.q("select * from warnings"))' | grep "test warning"
runalyzer summary.sqlite -c 'db.print_cursor(db.q("select * from logging"))'
runalyzer summary.sqlite -c 'db.print_cursor(db.q("select * from logging"))' | grep WARNING
## Check that t_log is within [0, 2]
runalyzer -m summary.sqlite -c 'assert all([0 < r[0] < 2 for r in q("select $t_log.max")])'
## Check that gathered and auto-gathered are equivalent for t_log non-mpi case
manual_gather=$(runalyzer summary.sqlite -c 'db.print_cursor(db.q("select $t_log.max"))')
auto_gather=$(runalyzer log.sqlite -c 'db.print_cursor(db.q("select $t_log.max"))' | grep -v Creating)
if [[ $auto_gather == $manual_gather ]]; then echo "t_log values match"; else exit 1; fi
## Check that t_init is within [0, 20], and that there is only one value
runalyzer -m summary.sqlite -c 'assert all([0 < r[0] < 20 for r in q("select $t_init.max")])'
runalyzer -m summary.sqlite -c 'assert len([r[0] for r in q("select $t_init.max")]) == 1'
## Check that gathered and auto-gathered are equivalent for t_sim non-mpi case
manual_gather=$(runalyzer summary.sqlite -c 'db.print_cursor(db.q("select $t_init.max"))')
auto_gather=$(runalyzer log.sqlite -c 'db.print_cursor(db.q("select $t_init.max"))' | grep -v Creating)
if [[ $auto_gather == $manual_gather ]]; then echo "t_init values match"; else exit 1; fi
# Allow oversubscription of ranks to cores with Open MPI
export OMPI_MCA_rmaps_base_oversubscribe=1
export RDMAV_FORK_SAFE=1
mpirun --map-by :OVERSUBSCRIBE -n 4 python -m mpi4py examples/log-mpi.py
rm summary.sqlite
runalyzer-gather summary.sqlite mpi-log*.sqlite
runalyzer -m summary.sqlite -c 'dbplot(q("select $t_sim.max, $t_step.max"))'
# Perform some simple tests on the output file
## Check for warnings and logging
runalyzer summary.sqlite -c 'db.print_cursor(db.q("select * from warnings"))'
runalyzer summary.sqlite -c 'db.print_cursor(db.q("select * from warnings"))' | grep "test warning"
runalyzer summary.sqlite -c 'db.print_cursor(db.q("select * from logging"))'
runalyzer summary.sqlite -c 'db.print_cursor(db.q("select * from logging"))' | grep WARNING
## Check that t_log is within [0, 2]
runalyzer -m summary.sqlite -c 'assert all([0 < r[0] < 2 for r in q("select $t_log.max")])'
## Check that gathered and auto-gathered are equivalent for t_log mpi case
manual_gather=$(runalyzer summary.sqlite -c 'db.print_cursor(db.q("select $t_log.max"))')
auto_gather=$(runalyzer mpi-log*.sqlite -c 'db.print_cursor(db.q("select $t_log.max"))' | grep -v Creating)
if [[ $auto_gather == $manual_gather ]]; then echo "t_log values match"; else exit 1; fi
## Check that t_init is within [0, 20], and that there is only one value
runalyzer -m summary.sqlite -c 'assert all([0 < r[0] < 20 for r in q("select $t_init.max")])'
runalyzer -m summary.sqlite -c 'assert len([r[0] for r in q("select $t_init.max")]) == 1'
## Check that gathered and auto-gathered are equivalent for t_init mpi case
manual_gather=$(runalyzer summary.sqlite -c 'db.print_cursor(db.q("select $t_init.max"))')
auto_gather=$(runalyzer mpi-log*.sqlite -c 'db.print_cursor(db.q("select $t_init.max"))' | grep -v Creating)
if [[ $auto_gather == $manual_gather ]]; then echo "t_init values match"; else exit 1; fi
## Gather and autogather multiple runs together and compare output
runalyzer-gather summary_multirun.sqlite mpi-log*.sqlite log.sqlite
manual_gather=$(runalyzer summary_multirun.sqlite -c 'db.print_cursor(db.q("select $t_log.max"))')
auto_gather=$(runalyzer mpi-log*.sqlite log.sqlite -c 'db.print_cursor(db.q("select $t_log.max"))' | grep -v Creating)
if [[ $auto_gather == $manual_gather ]]; then echo "t_log values match"; else exit 1; fi
manual_gather=$(runalyzer summary_multirun.sqlite -c 'db.print_cursor(db.q("select $t_init.max"))')
auto_gather=$(runalyzer mpi-log*.sqlite log.sqlite -c 'db.print_cursor(db.q("select $t_init.max"))' | grep -v Creating)
if [[ $auto_gather == $manual_gather ]]; then echo "t_init values match"; else exit 1; fi
# ensure that gathering gathered files raises exception
set +e
runalyzer summary.sqlite summary_multirun.sqlite -c 'db.print_cursor(db.q("select $t_log.max"))'
if [ $? -eq 0 ]; then echo "Exception was not raised when gathering gathered files"; exit 1; else echo "Exception was raised"; fi
set -e
- name: Test signal handling
run: |
set -x
# {{{ test SIGTERM handling
set +e
python examples/log.py & pid=$!
sleep 2; kill $pid
wait $pid
ret=$?
set -e
[[ $ret -eq 15 ]] || { echo "Expected return code 15, got $ret"; exit 1; }
len=$(runalyzer log.sqlite -c 'print(len(db.q("select $t_log.max").fetchall()))' | tail -1)
[[ $len -ge 10 ]] || { echo "Expected at least 10 t_log values, got $len"; exit 1; }
# }}}
docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: "Main Script"
run: |
curl -L -O https://tiker.net/ci-support-v0
. ci-support-v0
build_py_project_in_venv
build_docs
mypy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: "Main Script"
run: |
set -x
sudo apt-get update && sudo apt-get install -y libopenmpi-dev
curl -L -O -k https://gitlab.tiker.net/inducer/ci-support/raw/main/prepare-and-run-mypy.sh
export EXTRA_INSTALL="pytools numpy types-psutil pymbolic mpi4py matplotlib"
. ./prepare-and-run-mypy.sh python3
pytest:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Run tests
run: |
set -x
sudo apt-get update && sudo apt-get install -y libopenmpi-dev
pip install -e .
python -m pip install pytest pymbolic psutil matplotlib mpi4py
# run current test coverage
python -m pytest --durations=5 --tb=native -rxsw test/
coverage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Compare coverage with 'main' branch
run: |
set -x
sudo apt-get update && sudo apt-get install -y libopenmpi-dev
pip install -e .
python -m pip install pytest pytest-cov pymbolic psutil matplotlib mpi4py
# run current test coverage
python -m pytest --durations=0 --tb=native -rxsw --cov-report term --cov-report json:new_cov.json --cov=logpyle test/
# get main's test coverage
pip uninstall logpyle -y
cd ..
git clone https://github.com/illinois-ceesd/logpyle.git logpyle_main
cd logpyle_main
pip install -e .
python -m pytest --durations=0 --tb=native -rxsw --cov-report term --cov-report json:old_cov.json --cov=logpyle test/
# ensure that coverage can only increase
cd test
ls -l ..
python -c 'from conftest import assert_cov; assert_cov("../old_cov.json", "../../logpyle/new_cov.json")'
htmlalyzer:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Run
run: |
pip install -e .
python -m pip install pymbolic psutil matplotlib
# open default html
htmlalyzer
# open html after being built
htmlalyzer -b
upgrade-db:
name: Upgrade-Database
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Upgrade v2 to v3
run: |
pip install -e .
# test ungathered_v2 default name
upgrade-db .github/workflows/log_ungathered_v2.sqlite
# utilize nogather flag to ensure schema is from modification
# instead of gathering, which builds schema v3
runalyzer .github/workflows/log_ungathered_v2_upgrade.sqlite -c 'db.print_cursor(db.q("select * from warnings"))' --nogather
runalyzer .github/workflows/log_ungathered_v2_upgrade.sqlite -c 'print([l[0] for l in q("select * from warnings").description])' --nogather
runalyzer .github/workflows/log_ungathered_v2_upgrade.sqlite -c 'print([l[0] for l in q("select * from logging").description])' --nogather
runalyzer .github/workflows/log_ungathered_v2_upgrade.sqlite -c 'assert "unixtime" in [l[0] for l in q("select * from warnings").description]' --nogather
runalyzer .github/workflows/log_ungathered_v2_upgrade.sqlite -c 'assert "rank" in [l[0] for l in q("select * from warnings").description]' --nogather
runalyzer .github/workflows/log_ungathered_v2_upgrade.sqlite -c 'assert [l[0] for l in q("select schema_version")][0] == 3'
# test gathered_v2 default name
upgrade-db .github/workflows/log_gathered_v2.sqlite
runalyzer .github/workflows/log_gathered_v2_upgrade.sqlite -c 'db.print_cursor(db.q("select * from warnings"))' --nogather
runalyzer .github/workflows/log_gathered_v2_upgrade.sqlite -c 'print([l[0] for l in q("select * from warnings").description])' --nogather
runalyzer .github/workflows/log_gathered_v2_upgrade.sqlite -c 'print([l[0] for l in q("select * from logging").description])' --nogather
runalyzer .github/workflows/log_gathered_v2_upgrade.sqlite -c 'assert "unixtime" in [l[0] for l in q("select * from warnings").description]' --nogather
runalyzer .github/workflows/log_gathered_v2_upgrade.sqlite -c 'assert "rank" in [l[0] for l in q("select * from warnings").description]' --nogather
runalyzer .github/workflows/log_gathered_v2_upgrade.sqlite -c 'assert [l[0] for l in q("select schema_version")][0] == 3'
# test gathered custom name
upgrade-db .github/workflows/log_gathered_v2.sqlite --suffix '_new'
runalyzer .github/workflows/log_gathered_v2_new.sqlite -c 'db.print_cursor(db.q("select * from warnings"))' --nogather
runalyzer .github/workflows/log_gathered_v2_new.sqlite -c 'print([l[0] for l in q("select * from warnings").description])' --nogather
runalyzer .github/workflows/log_gathered_v2_new.sqlite -c 'print([l[0] for l in q("select * from logging").description])' --nogather
runalyzer .github/workflows/log_gathered_v2_new.sqlite -c 'assert "unixtime" in [l[0] for l in q("select * from warnings").description]' --nogather
runalyzer .github/workflows/log_gathered_v2_new.sqlite -c 'assert "rank" in [l[0] for l in q("select * from warnings").description]' --nogather
runalyzer .github/workflows/log_gathered_v2_new.sqlite -c 'assert [l[0] for l in q("select schema_version")][0] == 3'
- name: Upgrade v3 to v3
# Tests upgrades on current version for stability and allows users
# to blindly upgrade databases safely
run: |
pip install -e .
# test ungathered_v3 default name
upgrade-db .github/workflows/log_ungathered_v3.sqlite
# utilize nogather flag to ensure schema is from modification
# instead of gathering, which builds schema v3
runalyzer .github/workflows/log_ungathered_v3_upgrade.sqlite -c 'db.print_cursor(db.q("select * from warnings"))' --nogather
runalyzer .github/workflows/log_ungathered_v3_upgrade.sqlite -c 'print([l[0] for l in q("select * from warnings").description])' --nogather
runalyzer .github/workflows/log_ungathered_v3_upgrade.sqlite -c 'print([l[0] for l in q("select * from logging").description])' --nogather
runalyzer .github/workflows/log_ungathered_v3_upgrade.sqlite -c 'assert "unixtime" in [l[0] for l in q("select * from warnings").description]' --nogather
runalyzer .github/workflows/log_ungathered_v3_upgrade.sqlite -c 'assert "rank" in [l[0] for l in q("select * from warnings").description]' --nogather
runalyzer .github/workflows/log_ungathered_v3_upgrade.sqlite -c 'assert [l[0] for l in q("select schema_version")][0] == 3'
# test gathered_v3 default name
upgrade-db .github/workflows/log_gathered_v3.sqlite
runalyzer .github/workflows/log_gathered_v3_upgrade.sqlite -c 'db.print_cursor(db.q("select * from warnings"))' --nogather
runalyzer .github/workflows/log_gathered_v3_upgrade.sqlite -c 'print([l[0] for l in q("select * from warnings").description])' --nogather
runalyzer .github/workflows/log_gathered_v3_upgrade.sqlite -c 'print([l[0] for l in q("select * from logging").description])' --nogather
runalyzer .github/workflows/log_gathered_v3_upgrade.sqlite -c 'assert "unixtime" in [l[0] for l in q("select * from warnings").description]' --nogather
runalyzer .github/workflows/log_gathered_v3_upgrade.sqlite -c 'assert "rank" in [l[0] for l in q("select * from warnings").description]' --nogather
runalyzer .github/workflows/log_gathered_v3_upgrade.sqlite -c 'assert [l[0] for l in q("select schema_version")][0] == 3'
# test gathered custom name
upgrade-db .github/workflows/log_gathered_v3.sqlite --suffix '_new'
runalyzer .github/workflows/log_gathered_v3_new.sqlite -c 'db.print_cursor(db.q("select * from warnings"))' --nogather
runalyzer .github/workflows/log_gathered_v3_new.sqlite -c 'print([l[0] for l in q("select * from warnings").description])' --nogather
runalyzer .github/workflows/log_gathered_v3_new.sqlite -c 'print([l[0] for l in q("select * from logging").description])' --nogather
runalyzer .github/workflows/log_gathered_v3_new.sqlite -c 'assert "unixtime" in [l[0] for l in q("select * from warnings").description]' --nogather
runalyzer .github/workflows/log_gathered_v3_new.sqlite -c 'assert "rank" in [l[0] for l in q("select * from warnings").description]' --nogather
runalyzer .github/workflows/log_gathered_v3_new.sqlite -c 'assert [l[0] for l in q("select schema_version")][0] == 3'