Skip to content

Commit 82ee1d9

Browse files
committed
Add pytensor linker matrix ("cvm", "numba") to tests
Remove useless os paramerizations and update codecov name
1 parent adb79be commit 82ee1d9

File tree

2 files changed

+45
-57
lines changed

2 files changed

+45
-57
lines changed

.github/workflows/tests.yml

Lines changed: 28 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ on:
88
branches:
99
- main
1010

11-
12-
1311
# Cancel running workflows for updated PRs
1412
# https://turso.tech/blog/simple-trick-to-save-environment-and-money-when-using-github-actions
1513
concurrency:
@@ -26,7 +24,6 @@ concurrency:
2624
# enforces that test run just once per OS / floatX setting.
2725

2826
jobs:
29-
3027
changes:
3128
name: "Check for changes"
3229
runs-on: ubuntu-latest
@@ -56,8 +53,7 @@ jobs:
5653
if: ${{ needs.changes.outputs.changes == 'true' }}
5754
strategy:
5855
matrix:
59-
os: [ubuntu-latest]
60-
floatx: [float64]
56+
linker: [cvm, numba]
6157
python-version: ["3.14"]
6258
test-subset:
6359
- |
@@ -145,10 +141,10 @@ jobs:
145141
tests/dims/test_model.py
146142
147143
fail-fast: false
148-
runs-on: ${{ matrix.os }}
144+
runs-on: ubuntu-latest
149145
env:
150146
TEST_SUBSET: ${{ matrix.test-subset }}
151-
PYTENSOR_FLAGS: floatX=${{ matrix.floatx }}
147+
PYTENSOR_FLAGS: linker=${{ matrix.linker }}
152148
defaults:
153149
run:
154150
shell: bash -leo pipefail {0}
@@ -175,18 +171,17 @@ jobs:
175171
- name: Upload coverage to Codecov
176172
uses: codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7 # v5.5.1
177173
with:
178-
token: ${{ secrets.CODECOV_TOKEN }} # use token for more robust uploads
174+
token: ${{ secrets.CODECOV_TOKEN }}
179175
env_vars: TEST_SUBSET
180-
name: ${{ matrix.os }} ${{ matrix.floatx }}
176+
name: Ubuntu py${{ matrix.python-version }} linker=${{ matrix.linker }}
181177
fail_ci_if_error: false
182178

183179
windows:
184180
needs: changes
185181
if: ${{ needs.changes.outputs.changes == 'true' }}
186182
strategy:
187183
matrix:
188-
os: [windows-latest]
189-
floatx: [float64]
184+
linker: [cvm, numba]
190185
python-version: ["3.11"]
191186
test-subset:
192187
- tests/variational/test_approximations.py tests/variational/test_callbacks.py tests/variational/test_inference.py tests/variational/test_opvi.py tests/test_initial_point.py
@@ -195,10 +190,10 @@ jobs:
195190
- tests/step_methods/test_metropolis.py tests/step_methods/test_slicer.py tests/step_methods/hmc/test_nuts.py tests/step_methods/test_compound.py tests/step_methods/hmc/test_hmc.py tests/step_methods/test_state.py
196191

197192
fail-fast: false
198-
runs-on: ${{ matrix.os }}
193+
runs-on: windows-latest
199194
env:
200195
TEST_SUBSET: ${{ matrix.test-subset }}
201-
PYTENSOR_FLAGS: floatX=${{ matrix.floatx }}
196+
PYTENSOR_FLAGS: linker=${{ matrix.linker }}
202197
defaults:
203198
run:
204199
shell: bash -leo pipefail {0}
@@ -225,18 +220,17 @@ jobs:
225220
- name: Upload coverage to Codecov
226221
uses: codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7 # v5.5.1
227222
with:
228-
token: ${{ secrets.CODECOV_TOKEN }} # use token for more robust uploads
223+
token: ${{ secrets.CODECOV_TOKEN }}
229224
env_vars: TEST_SUBSET
230-
name: ${{ matrix.os }} ${{ matrix.floatx }}
225+
name: Windows py${{ matrix.python-version }} linker=${{ matrix.linker }}
231226
fail_ci_if_error: false
232227

233228
macos:
234229
needs: changes
235230
if: ${{ needs.changes.outputs.changes == 'true' }}
236231
strategy:
237232
matrix:
238-
os: [macos-latest]
239-
floatx: [float64]
233+
linker: [cvm, numba]
240234
python-version: ["3.14"]
241235
test-subset:
242236
- |
@@ -253,10 +247,10 @@ jobs:
253247
tests/backends/test_zarr.py
254248
tests/variational/test_updates.py
255249
fail-fast: false
256-
runs-on: ${{ matrix.os }}
250+
runs-on: macos-latest
257251
env:
258252
TEST_SUBSET: ${{ matrix.test-subset }}
259-
PYTENSOR_FLAGS: floatX=${{ matrix.floatx }}
253+
PYTENSOR_FLAGS: linker=${{ matrix.linker }}
260254
defaults:
261255
run:
262256
shell: bash -leo pipefail {0}
@@ -285,16 +279,15 @@ jobs:
285279
with:
286280
token: ${{ secrets.CODECOV_TOKEN }} # use token for more robust uploads
287281
env_vars: TEST_SUBSET
288-
name: ${{ matrix.os }} ${{ matrix.floatx }}
282+
name: MacOS py${{ matrix.python-version }} linker=${{ matrix.linker }}
289283
fail_ci_if_error: false
290284

291285
alternative_backends:
292286
needs: changes
293287
if: ${{ needs.changes.outputs.changes == 'true' }}
294288
strategy:
295289
matrix:
296-
os: [ubuntu-latest]
297-
floatx: [float64]
290+
linker: [cvm, numba]
298291
# nutpie depends on PyMC, and it will require an extra release cycle to support
299292
# the next PyMC release and therefore Python 3.14.
300293
python-version: ["3.13"]
@@ -305,10 +298,10 @@ jobs:
305298
tests/sampling/test_mcmc_external.py
306299
307300
fail-fast: false
308-
runs-on: ${{ matrix.os }}
301+
runs-on: ubuntu-latest
309302
env:
310303
TEST_SUBSET: ${{ matrix.test-subset }}
311-
PYTENSOR_FLAGS: floatX=${{ matrix.floatx }}
304+
PYTENSOR_FLAGS: linker=${{ matrix.linker }}
312305
defaults:
313306
run:
314307
shell: bash -leo pipefail {0}
@@ -337,24 +330,24 @@ jobs:
337330
with:
338331
token: ${{ secrets.CODECOV_TOKEN }} # use token for more robust uploads
339332
env_vars: TEST_SUBSET
340-
name: Alternative backend tests - ${{ matrix.os }} ${{ matrix.floatx }}
333+
name: Alternative backends py${{ matrix.python-version }} linker=${{ matrix.linker }}
341334
fail_ci_if_error: false
342335

343336
float32:
344337
needs: changes
345338
if: ${{ needs.changes.outputs.changes == 'true' }}
346339
strategy:
347340
matrix:
341+
linker: [cvm, numba]
348342
os: [windows-latest]
349-
floatx: [float32]
350343
python-version: ["3.14"]
351344
test-subset:
352-
- tests/sampling/test_mcmc.py tests/ode/test_ode.py tests/ode/test_utils.py tests/distributions/test_transform.py
345+
- tests/sampling/test_mcmc.py tests/ode/test_ode.py tests/ode/test_utils.py tests/distributions/test_transform.py
353346
fail-fast: false
354347
runs-on: ${{ matrix.os }}
355348
env:
356349
TEST_SUBSET: ${{ matrix.test-subset }}
357-
PYTENSOR_FLAGS: floatX=${{ matrix.floatx }}
350+
PYTENSOR_FLAGS: floatX=float32
358351
defaults:
359352
run:
360353
shell: bash -leo pipefail {0}
@@ -383,19 +376,19 @@ jobs:
383376
with:
384377
token: ${{ secrets.CODECOV_TOKEN }} # use token for more robust uploads
385378
env_vars: TEST_SUBSET
386-
name: ${{ matrix.os }} ${{ matrix.floatx }}
379+
name: float32 ${{ matrix.os }} py${{ matrix.python-version }} linker=${{ matrix.linker }}
387380
fail_ci_if_error: false
388381

389382
all_tests:
390383
if: ${{ always() }}
391384
runs-on: ubuntu-latest
392-
needs: [ changes, ubuntu, windows, macos, alternative_backends, float32 ]
385+
needs: [changes, ubuntu, windows, macos, alternative_backends, float32]
393386
steps:
394387
- name: Check build matrix status
395388
if: ${{ needs.changes.outputs.changes == 'true' &&
396-
( needs.ubuntu.result != 'success' ||
397-
needs.windows.result != 'success' ||
398-
needs.macos.result != 'success' ||
399-
needs.alternative_backends.result != 'success' ||
400-
needs.float32.result != 'success' ) }}
389+
( needs.ubuntu.result != 'success' ||
390+
needs.windows.result != 'success' ||
391+
needs.macos.result != 'success' ||
392+
needs.alternative_backends.result != 'success' ||
393+
needs.float32.result != 'success' ) }}
401394
run: exit 1

scripts/check_all_tests_are_covered.py

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def find_testfiles():
3131

3232

3333
def from_yaml():
34-
"""Determine how often each test file is run per platform and floatX setting.
34+
"""Determine how often each test file is run per platform and linker setting.
3535
3636
An exception is raised if tests run multiple times with the same configuration.
3737
"""
@@ -41,48 +41,43 @@ def from_yaml():
4141
wfname = wf.rstrip(".yml")
4242
wfdef = yaml.safe_load(open(Path(".github", "workflows", wf)))
4343
for jobname, jobdef in wfdef["jobs"].items():
44+
if jobname in ("float32", "all_tests"):
45+
continue
46+
runs_on = jobdef.get("runs-on", "unknown")
47+
floatX = "float32" if jobname == "float32" else "float64"
4448
matrix = jobdef.get("strategy", {}).get("matrix", {})
4549
if matrix:
50+
# Some jobs are parametrized by os, for others it's fixed
51+
matrix.setdefault("os", [runs_on])
52+
matrix.setdefault("floatX", [floatX])
4653
matrices[(wfname, jobname)] = matrix
4754
else:
4855
_log.warning("No matrix in %s/%s", wf, jobname)
4956

50-
# Now create an empty DataFrame to count based on OS/floatX/testfile
57+
# Now create an empty DataFrame to count based on OS/linker/testfile
5158
all_os = []
52-
all_floatX = []
59+
all_linker = []
5360
for matrix in matrices.values():
5461
all_os += matrix["os"]
55-
all_floatX += matrix["floatx"]
62+
all_linker += matrix["linker"]
5663
all_os = tuple(sorted(set(all_os)))
57-
all_floatX = tuple(sorted(set(all_floatX)))
64+
all_linker = tuple(sorted(set(all_linker)))
5865
all_tests = find_testfiles()
5966

6067
df = pandas.DataFrame(
6168
columns=pandas.MultiIndex.from_product(
62-
[sorted(all_floatX), sorted(all_os)], names=["floatX", "os"]
69+
[sorted(all_linker), sorted(all_os)], names=["linker", "os"]
6370
),
6471
index=pandas.Index(sorted(all_tests), name="testfile"),
6572
)
6673
df.loc[:, :] = 0
6774

6875
# Count how often the testfiles are included in job definitions
6976
for matrix in matrices.values():
70-
for os_, floatX, subset in itertools.product(
71-
matrix["os"], matrix["floatx"], matrix["test-subset"]
77+
for os_, linker, subset in itertools.product(
78+
matrix["os"], matrix["linker"], matrix["test-subset"]
7279
):
7380
lines = [k for k in subset.split("\n") if k]
74-
if "windows" in os_:
75-
# Windows jobs need \ in line breaks within the test-subset!
76-
# The following checks that these trailing \ are present in
77-
# all items except the last.
78-
if lines and lines[-1].endswith(" \\"):
79-
raise Exception(
80-
f"Last entry '{lines}' in Windows test subset should end WITHOUT ' \\'."
81-
)
82-
for line in lines[:-1]:
83-
if not line.endswith(" \\"):
84-
raise Exception(f"Missing ' \\' after '{line}' in Windows test-subset.")
85-
lines = [line.rstrip(" \\") for line in lines]
8681

8782
# Unpack lines with >1 item
8883
testfiles = []
@@ -97,7 +92,7 @@ def from_yaml():
9792
included = all_tests - ignored
9893

9994
for testfile in included:
100-
df.loc[testfile, (floatX, os_)] += 1
95+
df.loc[testfile, (linker, os_)] += 1
10196

10297
ignored_by_all = set(df[df.eq(0).all(axis=1)].index)
10398
run_multiple_times = set(df[df.gt(1).any(axis=1)].index)
@@ -111,7 +106,7 @@ def from_yaml():
111106
)
112107
if run_multiple_times:
113108
raise AssertionError(
114-
f"{len(run_multiple_times)} tests are run multiple times with the same OS and floatX setting:\n{run_multiple_times}"
109+
f"{len(run_multiple_times)} tests are run multiple times with the same OS and pytensor flags:\n{run_multiple_times}"
115110
)
116111
return
117112

0 commit comments

Comments
 (0)