-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpyproject.toml
More file actions
507 lines (472 loc) · 17.7 KB
/
Copy pathpyproject.toml
File metadata and controls
507 lines (472 loc) · 17.7 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
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
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[project]
name = "raitap"
version = "0.14.0"
authors = [
{ name = "Stanislas Laurent", email = "lauresta@students.zhaw.ch" },
{ name = "Jonas Vonderhagen", email = "vondejon@students.zhaw.ch" },
{ name = "Philipp Denzel", email = "denp@zhaw.ch" },
{ name = "Oliver Forster", email = "foro@zhaw.ch" },
]
maintainers = [
{ name = "Stanislas Laurent", email = "lauresta@students.zhaw.ch" },
{ name = "Jonas Vonderhagen", email = "vondejon@students.zhaw.ch" },
{ name = "Philipp Denzel", email = "denp@zhaw.ch" },
{ name = "Oliver Forster", email = "foro@zhaw.ch" },
]
description = "Python library to assess the responsibility level of AI models for integration into MLOps workflows."
readme = "README.md"
license = { file = "LICENSE" }
# Hydra 1.3.2 is part of the published runtime and currently breaks on Python 3.14.
requires-python = ">=3.11,<3.14"
keywords = [
"artificial intelligence",
"deep learning",
"neural networks",
"technical assessment",
"responsible AI",
]
classifiers = [
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Typing :: Typed",
"Operating System :: OS Independent",
"Topic :: Scientific/Engineering :: Artificial Intelligence",
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
]
dependencies = [
# Core runtime.
# Upper bound on hydra-core / omegaconf: hydra-zen 0.16 reads the removed
# `omegaconf._utils.get_yaml_loader` symbol, which is gone in omegaconf 2.4
# (shipped as 2.4.0.devN). hydra-core 1.4.0.devN bundles the new omegaconf
# too. Cap both at <next-major until hydra-zen catches up. Defense-in-depth:
# the cap stops the broken pre-releases even if a downstream project relaxes
# pre-release handling. Consumers should scope pre-releases to triton-xpu
# (`triton-xpu>=3.0.0rc0`), not a global `prerelease = "allow"` — see
# docs/using-raitap/installing.
"hydra-core>=1.3.2,<1.4",
"omegaconf>=2.3,<2.4",
"hydra-zen>=0.13",
"numpy>=2.4.2",
"packaging>=23.0",
# Data and visualisation.
"matplotlib==3.10.*", # pinned: bumping invalidates committed pytest-mpl baselines (FreeType/Agg rendering)
"pandas>=2.0.0",
"pandas-stubs~=3.0.0",
"pillow>=12.2.0",
# Terminal output (cross-platform ANSI: handles Windows console via colorama-style shim).
"rich>=13.7.0",
]
[project.scripts]
raitap = "raitap.cli:main"
docs-preview = "raitap.docs_preview:main"
# `raitap-deps` removed: dep inference is now integrated into `raitap` itself.
# Use `raitap --dry-run` to preview the inferred install, `raitap --custom-deps`
# to bypass inference entirely.
[project.urls]
Documentation = "https://caiivs.github.io/raitap/"
Homepage = "https://caiivs.github.io/raitap/"
Repository = "https://github.com/CAIIVS/raitap/"
Issues = "https://github.com/CAIIVS/raitap/issues"
Source = "https://github.com/CAIIVS/raitap/"
[project.optional-dependencies]
# Backend module
torch-cpu = ["torch>=2.8.0,<2.9.0", "torchvision>=0.20.0,<0.24.0"]
torch-cuda = ["torch>=2.8.0,<2.9.0", "torchvision>=0.20.0,<0.24.0"]
torch-intel = [
# Intel XPU stays on torch>=2.10.0 (unchanged from main): the only torch in the
# 2.8 window on the xpu index is 2.8.0+xpu, whose pinned pytorch-triton-xpu==3.4.0
# is not published there, so the 2.8 floor is unresolvable for XPU. auto-LiRPA
# needs torch<2.9 and has no XPU support anyway, so it is declared mutually
# exclusive with the intel extras in [tool.uv] conflicts below.
"torch>=2.10.0; python_full_version < '3.14' and sys_platform != 'darwin'",
"torchvision>=0.20.0; python_full_version < '3.14' and sys_platform != 'darwin'",
# Pin triton-xpu>=3.0.0 — its only PyPI release (0.0.2) is yanked. The
# 3.x wheels live on the pytorch-intel index (routed via [tool.uv.sources]
# below) and are pulled in transitively by torch==*+xpu. See #110.
"triton-xpu>=3.0.0; python_full_version < '3.14' and sys_platform != 'darwin'",
]
# TODO remove bundled torch deps once ONNX no longer relies on torch tensors internally
onnx-cpu = [
"onnx>=1.21.0",
"onnxruntime>=1.24.4",
"torch>=2.8.0,<2.9.0",
"torchvision>=0.20.0,<0.24.0",
]
onnx-cuda = [
"onnx>=1.21.0",
"onnxruntime-gpu>=1.24.4",
"torch>=2.8.0,<2.9.0",
"torchvision>=0.20.0,<0.24.0",
]
onnx-intel = [
"onnx>=1.21.0; sys_platform != 'darwin'",
"onnxruntime-openvino>=1.24.1; sys_platform != 'darwin'",
"openvino>=2025.1.0; sys_platform == 'win32'",
# Intel XPU stays on torch>=2.10.0 — see the torch-intel comment above.
"torch>=2.10.0; python_full_version < '3.14' and sys_platform != 'darwin'",
"torchvision>=0.20.0; python_full_version < '3.14' and sys_platform != 'darwin'",
"triton-xpu>=3.0.0; python_full_version < '3.14' and sys_platform != 'darwin'",
]
# Transparency module
# opencv-python: SHAP modern-API image masker (inpaint/blur strategies); #267.
shap = ["shap>=0.46.0", "opencv-python>=4.9"]
captum = ["captum>=0.7.0"]
quantus = ["quantus>=0.5.3"]
transparency = ["raitap[shap,captum]"]
# Tree/tabular model backend (XGBoost) — enables shap.TreeExplainer end-to-end.
# Named per-library (like shap/captum); a `tree` umbrella can re-export this and
# future tree libs (LightGBM/sklearn) once they land. Kept out of the
# transparency umbrella: TreeExplainer needs both shap and xgboost.
# scikit-learn: XGBoostBackend loads via the sklearn-API ``XGBClassifier``, which
# imports scikit-learn — so the backend cannot load a model without it.
# torch: raitap's pipeline is torch-based (data tensors + the tree backend's
# numpy<->torch bridge), so a tree config needs torch even though XGBoost does the
# compute. Bundled here and routed to the CPU index in [tool.uv.sources] (like
# onnx-cpu bundles torch); XGBoost runs on CPU here, so the CPU build suffices and
# this extra stays hardware-variant-free.
xgboost = ["xgboost>=2.0", "scikit-learn>=1.3", "torch>=2.8.0,<2.9.0"]
# Text model backend (HuggingFace) — AutoModelForSequenceClassification +
# AutoTokenizer loading for the text input modality. Does not bundle torch:
# relies on whatever torch-* extra is already installed for the pipeline.
text = ["transformers>=4.40"]
# Robustness module
torchattacks = ["torchattacks>=3.5.1"]
foolbox = ["foolbox>=3.3.4", "numba>=0.59"]
# Average-case (statistical-sampling) adapter: the ImageNet-C common-corruption
# suite. Pure numpy/scipy/skimage/opencv — no torch, lazy-imported.
imagecorruptions = ["imagecorruptions>=1.1.2"]
# Marabou formal-verification adapter (Linux/macOS x86-64, Python 3.11 only).
# maraboupy 2.0.0 publishes cp311 wheels only — no cp312/cp313, no Windows.
# Marker below keeps ``uv sync`` working on other interpreters by silently
# skipping the extra. Not bundled into the ``robustness`` umbrella because
# installing Marabou adds a non-trivial native dep empirical-only users don't need.
marabou = [
"maraboupy>=2.0.0,<3.0; python_full_version < '3.12' and sys_platform != 'win32'",
"onnx>=1.15",
]
# auto-LiRPA certified-robustness adapter (sound, incomplete bound propagation).
# Resolved from GitHub master via [tool.uv.sources] below — auto-LiRPA has no
# PyPI release supporting torch 2.x (PyPI tops out at 0.3, torch<1.13). The
# requirement is listed by bare name (no `@ git+...`) so it stays PyPI-legal:
# a direct-URL Requires-Dist would make raitap's own wheel unpublishable. Not
# folded into the ``robustness`` umbrella for the same reason ``marabou`` isn't —
# a git-only dep makes ``pip install raitap[robustness]`` unresolvable for
# non-uv users, and bound-propagation verification is a niche opt-in.
auto-lirpa = ["auto-LiRPA"]
robustness = ["raitap[torchattacks,foolbox,marabou,imagecorruptions]"]
# Job launcher / batch scheduler support
launcher = ["hydra-submitit-launcher>=1.2.0"]
# Tracking module
mlflow = ["mlflow>=3.9.0"]
tracking = ["raitap[mlflow]"]
# Metrics module
metrics = ["torchmetrics>=1.8.2", "faster-coco-eval>=1.6.3"]
# Reporting module
pdf = ["borb==3.0.7"]
html = ["jinja2>=3.1"]
reporting = ["raitap[pdf,html]"]
[dependency-groups]
lint = ["ruff>=0.8.0", "pyright>=1.1.390"]
test = ["pytest>=9.0.3", "pytest-cov>=7.1.0", "pytest-mpl>=0.19.0"]
tooling = ["pre-commit>=4.0.0", "commitizen>=4.13.10"]
docs = [
"sphinx>=9.1.0; python_full_version >= '3.13'",
"myst-parser>=5.0.0; python_full_version >= '3.13'",
"furo>=2025.12.19; python_full_version >= '3.13'",
"sphinx-copybutton>=0.5.2; python_full_version >= '3.13'",
"sphinx-design>=0.6.1; python_full_version >= '3.13'",
"sphinx-autobuild>=2025.8.25; python_full_version >= '3.13'",
"sphinxcontrib-mermaid>=1.0.0; python_full_version >= '3.13'",
"sphinx-llms-txt>=0.2.0; python_full_version >= '3.13'",
"sphinx-sitemap>=2.6.0; python_full_version >= '3.13'",
]
dev = [
{ include-group = "lint" },
{ include-group = "test" },
{ include-group = "tooling" },
{ include-group = "docs" },
]
# uv dependency resolution rules.
[tool.uv]
# PyPI wheel for borb 3.0.x is invalid (duplicate ZIP entries); build from sdist instead.
no-binary-package = ["borb"]
override-dependencies = [
"numpy>=2.4",
"Pillow>=12.0",
"scikit-image>=0.26",
"blis>=1.0.2",
"thinc>=8.3.6,<9",
"spacy>=3.8.0",
# torchattacks 3.5.1 pins requests<2.26 which conflicts with sphinx 9.1+; relax.
"requests>=2.30.0",
# auto-LiRPA leaks test deps into install_requires and hard-pins
# ``pytest==8.1.1``, conflicting with raitap's ``pytest>=9.0.3`` dev group.
# Override the exact pin to raitap's floor (its other leaked test deps —
# pylint / pytest-order / pytest-mock — are open ranges and resolve cleanly).
"pytest>=9.0.3",
]
conflicts = [
[
{ extra = "torch-cpu" },
{ extra = "torch-cuda" },
{ extra = "torch-intel" },
],
[
{ extra = "onnx-cpu" },
{ extra = "onnx-cuda" },
{ extra = "onnx-intel" },
],
[
{ extra = "onnx-cpu" },
{ extra = "torch-cuda" },
],
[
{ extra = "onnx-cpu" },
{ extra = "torch-intel" },
],
[
{ extra = "onnx-cuda" },
{ extra = "torch-cpu" },
],
[
{ extra = "onnx-cuda" },
{ extra = "torch-intel" },
],
[
{ extra = "onnx-intel" },
{ extra = "torch-cpu" },
],
[
{ extra = "onnx-intel" },
{ extra = "torch-cuda" },
],
# xgboost bundles the CPU torch build (for the tensor pipeline), so it is
# mutually exclusive with any extra that pulls a cuda/xpu torch build.
[
{ extra = "xgboost" },
{ extra = "torch-cuda" },
],
[
{ extra = "xgboost" },
{ extra = "torch-intel" },
],
[
{ extra = "xgboost" },
{ extra = "onnx-cuda" },
],
[
{ extra = "xgboost" },
{ extra = "onnx-intel" },
],
# auto-LiRPA needs torch<2.9 but the Intel XPU extras require torch>=2.10.0
# (the 2.8 xpu wheel's triton dep is unpublished) — and auto-LiRPA has no XPU
# support regardless. Declare them mutually exclusive so uv never resolves the
# unsolvable "auto-lirpa + intel" fork.
[
{ extra = "auto-lirpa" },
{ extra = "torch-intel" },
],
[
{ extra = "auto-lirpa" },
{ extra = "onnx-intel" },
],
]
# Map runtime extras to the correct package indexes.
[tool.uv.sources]
# auto-LiRPA's torch-2.x support lives only on GitHub master (no PyPI release
# past 0.3 / torch<1.13). uv sources are NOT written into wheel metadata, so
# resolving from git here keeps the published raitap wheel PyPI-legal while the
# `auto-lirpa` extra installs the working version for dev/CI.
auto-LiRPA = { git = "https://github.com/Verified-Intelligence/auto_LiRPA" }
torch = [
{ index = "pytorch-cpu", extra = "torch-cpu" },
{ index = "pytorch-cpu", extra = "onnx-cpu" },
{ index = "pytorch-cpu", extra = "xgboost" },
{ index = "pytorch-cuda", extra = "torch-cuda" },
{ index = "pytorch-cuda", extra = "onnx-cuda" },
{ index = "pytorch-intel", extra = "torch-intel" },
{ index = "pytorch-intel", extra = "onnx-intel" },
]
torchvision = [
{ index = "pytorch-cpu", extra = "torch-cpu" },
{ index = "pytorch-cpu", extra = "onnx-cpu" },
{ index = "pytorch-cuda", extra = "torch-cuda" },
{ index = "pytorch-cuda", extra = "onnx-cuda" },
{ index = "pytorch-intel", extra = "torch-intel" },
{ index = "pytorch-intel", extra = "onnx-intel" },
]
# Route triton-xpu at the pytorch-intel index where the 3.x wheels live;
# PyPI only hosts the yanked 0.0.2. See #110.
triton-xpu = [
{ index = "pytorch-intel", extra = "torch-intel" },
{ index = "pytorch-intel", extra = "onnx-intel" },
]
# Explicit indexes used by runtime extras.
[[tool.uv.index]]
name = "pytorch-cpu"
url = "https://download.pytorch.org/whl/cpu"
explicit = true
[[tool.uv.index]]
name = "pytorch-cuda"
url = "https://download.pytorch.org/whl/cu126"
explicit = true
[[tool.uv.index]]
name = "pytorch-intel"
url = "https://download.pytorch.org/whl/xpu"
explicit = true
[tool.hatch.build.targets.wheel]
packages = ["src/raitap", "src/hydra_plugins"]
include = [
"src/raitap/py.typed",
"src/raitap/configs/**/*.yaml",
"src/raitap/configs/**/*.yml",
"src/raitap/reporting/templates/**/*",
"src/hydra_plugins/**/*.py",
]
exclude = ["src/raitap/**/test_*.py", "src/raitap/**/conftest.py", "src/raitap/tests/_fake_*plugin/**", "src/raitap/configs/zhaw/*.yaml", "src/raitap/configs/zhaw/*.yml"]
[tool.hatch.build.targets.wheel.force-include]
# Ship pyproject.toml inside the wheel so the auto-deps bootstrap can read
# raitap's own extras / conflicts / python pin from any install layout
# (dev checkout *and* PyPI wheel). Without this, the bootstrap-from-zero
# path in ``raitap.deps.bootstrap`` resolves ``_PYPROJECT`` to ``Lib/``
# under a wheel install and dies with a "No such file or directory" frame.
"pyproject.toml" = "raitap/_pyproject.toml"
[tool.hatch.build.targets.sdist]
# Keep PyPI sdist focused on installable library code; everything else
# (contributor-only assets, standalone example, docs) stays in the repo.
include = [
"src/raitap/**",
"src/hydra_plugins/**",
"pyproject.toml",
"README.md",
"LICENSE",
"CHANGELOG.md",
]
exclude = [
"src/raitap/**/test_*.py",
"src/raitap/**/conftest.py",
"src/raitap/tests/_fake_*plugin/**",
"src/raitap/configs/zhaw/*.yaml",
"src/raitap/configs/zhaw/*.yml",
"contributor-configs/**",
"example/**",
"docs/**",
"scripts/**",
"mlartifacts/**",
"mlflow*/**",
"outputs/**",
"tmp/**",
"conductor/**",
]
[tool.ruff]
line-length = 100
target-version = "py311"
extend-exclude = ["assets", "usecases", "outputs", "mlartifacts"]
[tool.ruff.lint]
select = [
"E",
"W",
"F",
"I",
"N",
"UP",
"B",
"C4", # flake8-comprehensions
"SIM",
"RUF",
"ANN001",
"ANN201",
"ANN202",
"TCH", # flake8-type-checking
"PYI",
"PGH003",
]
ignore = []
[tool.ruff.lint.per-file-ignores]
"__init__.py" = ["F401"] # Allow unused imports in __init__.py
[tool.ruff.format]
quote-style = "double"
indent-style = "space"
[tool.commitizen]
name = "cz_customize"
tag_format = "v$version"
version_scheme = "semver"
version_provider = "uv"
update_changelog_on_bump = false
major_version_zero = true
[tool.commitizen.customize]
schema = "<type>(<scope>): <subject>"
# If a scope is present, it must be one of the allowed values below.
schema_pattern = "^(feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert)(\\((transparency|tracking|metrics|docs|infra|deps|misc|config|model|data|reporting|robustness)\\))?(!)?:\\s.+$"
[tool.pyright]
include = ["src"]
exclude = [
"**/.*",
"**/.venv",
"**/__pycache__",
"**/node_modules",
"**/build",
"**/dist",
"assets",
"usecases",
"outputs",
"mlartifacts",
]
pythonVersion = "3.11"
typeCheckingMode = "standard"
reportMissingImports = true
reportMissingTypeStubs = false
reportUnusedImport = true
reportUnusedVariable = true
[tool.pytest.ini_options]
norecursedirs = ["assets", "usecases", "outputs", "mlartifacts", "src/raitap/tests/_fake_plugin", "src/raitap/tests/_fake_broken_plugin"]
testpaths = ["src"]
pythonpath = ["src"]
python_files = ["test_*.py"]
python_classes = ["Test*"]
python_functions = ["test_*"]
markers = [
"e2e: end-to-end tests that are resource-intensive; run once per PR, not on every commit",
"mpl: matplotlib baseline-regression tests that require committed reference images",
"runtime: runtime resolution and backend hardware-label tests for platform-specific CI selection",
"cuda: tests that require real CUDA hardware and run only on the GPU CI lane",
"slow: integration tests that download model weights; kept in Quality Gate but opt-out via -m 'not slow'",
"parity: assert raitap output equals a direct third-party-library call",
"visual: pytest-mpl pixel baseline regression of rendered figures",
"robustness: parity/e2e tests for the robustness (adversarial/formal) assessors",
"negative: tests asserting failure paths (missing baseline, invalid config, ...)",
]
addopts = ["-v", "--strict-markers", "--strict-config", "--tb=short"]
filterwarnings = [
# captum's "Input Tensor.*required_grads" is also silenced at runtime by the
# adapter (raitap.transparency.explainers.captum_explainer) — duplicated here
# because pytest resets the warnings filter between tests.
"ignore:Input Tensor.*required_grads:UserWarning",
# captum uses deprecated matplotlib cm.get_cmap; will be fixed upstream
"ignore:The get_cmap function was deprecated:matplotlib.MatplotlibDeprecationWarning",
# shap uses np.random.seed internally; will be fixed upstream
"ignore:The NumPy global RNG was seeded:FutureWarning",
# tight_layout incompatibility in ShapImageVisualiser; cosmetic only
"ignore:This figure includes Axes that are not compatible with tight_layout:UserWarning",
]
[tool.coverage.run]
source = ["src"]
omit = ["*/tests/*", "*/__pycache__/*", "*/.venv/*"]
[tool.coverage.report]
precision = 2
show_missing = true
skip_covered = false
exclude_lines = [
"pragma: no cover",
"def __repr__",
"raise AssertionError",
"raise NotImplementedError",
"if __name__ == .__main__.:",
"if TYPE_CHECKING:",
"@abstractmethod",
]