-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathtox.ini
More file actions
142 lines (130 loc) · 6.02 KB
/
Copy pathtox.ini
File metadata and controls
142 lines (130 loc) · 6.02 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
[tox]
requires = tox>=4.24.0
env_list = lint, py311, py312, py313, long, endpoint-import-smoke
labels =
# Friendly aliases for envs that don't share their name. Multi-env aggregates
# also live here (`full`). 1-to-1 aliases like `serial = serial` aren't needed
# — `tox -e <env>` is equivalent and clearer.
quick = py313
smoke = endpoint-import-smoke
full = lint, py311, py312, py313, medium, long, endpoint-import-smoke
[testenv]
# Default: parallel via pytest-xdist, file-level distribution.
# -n auto picks worker count from CPU cores (clamped sanely by xdist).
# --dist=loadfile keeps all tests in one file on the same worker so intra-file
# ordering / shared fixtures are preserved. Cross-file parallelism is where
# the speedup comes from — and where the risk lives. If you hit cross-file
# AWS-resource collisions (same endpoint name, same Parameter Store key, etc.),
# either lower -n, fix the test to use a unique resource, or drop the offender
# into a serial group, or use `tox -e serial` to revert to one-at-a-time.
# Drop -x because failures in one worker don't reach others — letting all
# workers finish gives a fuller picture.
description = Run unit tests in parallel (file-level distribution)
basepython = python3.12
# AWS_* / WORKBENCH_* pass through so both CI (OIDC env credentials + secret
# overrides) and local runs (AWS_PROFILE) reach the tests.
passenv =
WORKBENCH_*
AWS_*
CI
setenv =
PLOTLY_RENDERER = {env:PLOTLY_RENDERER:browser}
deps =
pytest
pytest-sugar
pytest-xdist
coverage
pytest-cov
.[all]
commands = pytest --assert=plain -n auto --dist=loadfile --durations=0 -m "not medium and not long and not corner_case" {posargs:tests}
[testenv:serial]
description = Run unit tests serially (escape hatch when parallel run hits a resource collision).
# Useful for debugging cross-file races — if `tox` (parallel) flakes intermittently
# and `tox -e serial` passes deterministically, the offender is a shared AWS
# resource between two test files.
basepython = python3.13
deps = {[testenv]deps}
commands = pytest --assert=plain -x -m "not medium and not long and not corner_case" {posargs:tests}
[testenv:verbose]
description = Run tests serially with verbose logging
deps = {[testenv]deps}
commands = pytest --assert=plain -x -m "not medium and not long and not corner_case" -s {posargs:tests}
[testenv:medium]
description = Run medium-tier tests (heavier validation studies, e.g. 3D endpoint comparisons)
deps = {[testenv]deps}
commands = pytest --assert=plain -n 4 --dist=loadfile --durations=0 -m "medium" {posargs:tests}
[testenv:py311]
description = Run tests with Python 3.11 (parallel)
basepython = python3.11
deps = {[testenv]deps}
[testenv:py312]
description = Run tests with Python 3.12 (parallel)
basepython = python3.12
deps = {[testenv]deps}
[testenv:py313]
description = Run tests with Python 3.13 (parallel)
basepython = python3.13
deps = {[testenv]deps}
[testenv:long]
# Parallel via pytest-xdist with file-level distribution (--dist=loadfile keeps
# each file's tests on one worker, preserving intra-file create->use->delete
# ordering; cross-file parallelism is where the speedup comes from). Capped at
# -n 4 to bound concurrent SageMaker endpoint deploys against account instance
# quotas. Drop -x because a failure in one worker doesn't reach the others, so
# letting all workers finish gives a fuller picture.
description = Run long-duration tests (parallel, file-level distribution)
setenv = WORKBENCH_DEBUG = True
commands = pytest --assert=plain -n 4 --dist=loadfile -v -s -m "long" {posargs:tests}
[testenv:lint]
description = Run linters
# Newest supported interpreter so black's AST check matches its py313 target.
basepython = python3.13
skip_install = true
deps =
black>=22.12
flake8
commands =
black --line-length=120 {posargs:.}
flake8 --exclude='*generated*,.tox/*'
[testenv:format]
description = Run formatters
skip_install = true
deps = black>=22.12
commands = black --line-length=120 {posargs:.}
[testenv:endpoint-import-smoke]
description = Verify the workbench.endpoints contract: every module imports without heavy extras.
# Contract: `workbench.endpoints.*` is THE import surface for model scripts
# running inside SageMaker endpoint containers. Every module under
# workbench/endpoints/ must be importable against the leanest endpoint dep
# manifest in the stack (ci/endpoint_smoke_requirements.txt — the
# intersection of every deployed endpoint container's requirements). If a
# refactor moves a heavy transitive import (sagemaker, aiobotocore, dash,
# cleanlab, umap-learn, matplotlib, mordred, ipython, networkx, xgboost,
# ...) into the import chain of any workbench.endpoints submodule, this
# job fails — telling us before an endpoint deploy does.
#
# This test enumerates the directory dynamically — adding a new module under
# workbench/endpoints/ automatically extends the contract. To exempt a module
# from the contract, it must not live under workbench/endpoints/.
basepython = python3.12
skip_install = true
# Override [testenv].deps (which installs `.[all]` — the full heavy tree). That
# would pollute this deliberately-lean env and defeat the contract. This env is
# built ONLY from the lean smoke requirements + workbench --no-deps (mirroring
# .github/workflows/endpoint-import-smoke.yml).
deps =
commands_pre =
pip install -r {toxinidir}/ci/endpoint_smoke_requirements.txt
pip install --no-deps {toxinidir}
commands = python {toxinidir}/ci/endpoint_import_smoke.py
[testenv:template-import-check]
description = Enforce the template import invariant: no top-level workbench.training imports.
# workbench.training modules carry training-only deps (ray/optuna) absent from
# endpoint images. A template may import them only inside __main__ (deferred),
# never at module scope — else the endpoint crashes at load. Static, no install.
basepython = python3.13
skip_install = true
# Override [testenv].deps (`.[all]`) — this check is a stdlib-only line scan; it
# needs nothing installed.
deps =
commands = python {toxinidir}/ci/template_import_check.py