-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpyproject.toml
More file actions
181 lines (158 loc) · 6.05 KB
/
Copy pathpyproject.toml
File metadata and controls
181 lines (158 loc) · 6.05 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
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[project]
name = "sbh-simulator"
version = "0.1.0"
description = "Simulate serial blockface histology (SBH) illumination inhomogeneity"
readme = "README.md"
license = "GPL-3.0-or-later"
requires-python = ">=3.14"
authors = [
{ name = "The LINUM developers" },
]
maintainers = [
{ name = "Joël Lefebvre", email = "lefebvre.joel@uqam.ca" },
]
classifiers = [
"Development Status :: 3 - Alpha",
"Environment :: Console",
"Intended Audience :: Science/Research",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3.14",
"Topic :: Scientific/Engineering :: Image Processing",
"License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)",
]
dependencies = [
"numpy",
"matplotlib",
"SimpleITK",
]
[project.optional-dependencies]
training = [
"nibabel",
"torch",
"torchvision",
"lightning",
"wandb",
]
dev = [
"ruff>=0.11",
"ty>=0.0.27",
"pytest>=7.0.0",
"pytest-cov>=4.0.0",
"pre-commit>=4.5.1",
]
[dependency-groups]
[project.scripts]
sbh-simulate = "sbh_simulator.cli.simulate:main"
sbh-train = "sbh_simulator.cli.train:main"
sbh-vignette = "sbh_simulator.cli.vignette:main"
# ---------------------------------------------------------------------------
# uv
# ---------------------------------------------------------------------------
[tool.uv]
# Bake wheels for all target environments into the universal lock file so
# that the CUDA wheels (Linux-only) and CPU wheels (macOS / Windows) are
# each resolved to the correct variant on each platform.
required-environments = [
"sys_platform == 'linux'",
"sys_platform == 'darwin'",
"sys_platform == 'win32'",
]
# PyTorch ships its own package index; PyPI only has very old cp3xx wheels.
# The cpu index is the fallback for macOS / Windows (and Linux without the
# gpu extra). The cu132 index is only activated on Linux when --extra gpu.
[[tool.uv.index]]
name = "pytorch-cpu"
url = "https://download.pytorch.org/whl/cpu"
explicit = true
[[tool.uv.index]]
name = "pytorch-cu132"
url = "https://download.pytorch.org/whl/cu132"
explicit = true
[tool.uv.sources]
# Mutually exclusive platform markers keep these source entries conflict-free.
# Linux (typically a CUDA training server) → cu132 CUDA index.
# macOS / Windows (typically developer laptops) → CPU-only index.
torch = [
{ index = "pytorch-cu132", marker = "sys_platform == 'linux'" },
{ index = "pytorch-cpu", marker = "sys_platform != 'linux'" },
]
torchvision = [
{ index = "pytorch-cu132", marker = "sys_platform == 'linux'" },
{ index = "pytorch-cpu", marker = "sys_platform != 'linux'" },
]
# ---------------------------------------------------------------------------
# ruff
# ---------------------------------------------------------------------------
[tool.ruff]
target-version = "py314"
line-length = 127
fix = true
include = ["sbh_simulator*", "scripts*", "tests*"]
[tool.ruff.lint]
select = ["E", "F", "W", "I", "UP", "B", "RUF", "SIM", "C4", "PIE", "PTH",
"N", "PERF", "FLY", "G", "D", "ANN", "ARG", "ERA", "FURB"]
# N813: SimpleITK as sitk is the universal Python convention — excluded globally.
# ANN401: Any is legitimately unavoidable in a few callback/override signatures.
# Note: flake8-type-checking (TCH/TC) is intentionally not selected — under
# PEP 649 (Python 3.14 default), annotations are lazily evaluated, so gating
# typing-only imports inside TYPE_CHECKING blocks no longer reduces import cost.
ignore = ["N813", "ANN401"]
extend-select = ["D417"]
# Greek/mathematical glyphs are intentional in docstrings.
# σ (sigma) is standard statistical notation; replacing it with 'o' would reduce legibility.
allowed-confusables = ["σ"]
[tool.ruff.lint.pydocstyle]
# numpy-style docstrings across the whole codebase.
# This disables D203, D212, D215 (conflicting numpy-incompatible rules).
convention = "numpy"
[tool.ruff.lint.isort]
known-first-party = ["sbh_simulator"]
[tool.ruff.lint.per-file-ignores]
# Scientific codebase: CapWords arg/var names follow nn.Module type naming convention
"sbh_simulator/models.py" = ["N803", "N806"]
# Dev scripts keep exploratory notes, use print/plt freely, no docstrings required
"scripts/dev_*.py" = ["ERA", "D", "ANN"]
"scripts/fig_synthetic_vignettes.py" = ["D", "ANN"]
"scripts/illumination_extraction_inference.py" = ["D"]
# Test files: type annotations, docstrings, unused-arg checks, and naming conventions are not required
"tests/**" = ["ANN", "D", "ARG", "N", "ERA"]
[tool.ruff.format]
# Use default (black-compatible) formatting
# ---------------------------------------------------------------------------
# ty
# ---------------------------------------------------------------------------
[tool.ty.src]
include = ["sbh_simulator", "tests"]
[tool.ty.environment]
python-version = "3.14"
[tool.ty.rules]
# possibly-unresolved-reference defaults to "warn" in ty; raise it to "error"
# so that variables only assigned inside conditional branches are caught.
possibly-unresolved-reference = "error"
[tool.ty.analysis]
# Optional ML/GPU deps — dynamic attributes on torch modules, lightning hooks,
# and wandb loggers produce cascading false positives in ty.
# Using replace-imports-with-any so downstream attribute/subscript access
# on the imported module is typed as Any rather than causing cascading errors.
replace-imports-with-any = ["torch.**", "torchvision.**", "lightning.**", "wandb.**"]
# --- ty overrides ---
# Relax rules in test files
[[tool.ty.overrides]]
include = ["tests/**", "**/test_*.py", "**/conftest.py"]
[tool.ty.overrides.rules]
possibly-unresolved-reference = "ignore"
unresolved-attribute = "ignore"
invalid-assignment = "ignore"
# ---------------------------------------------------------------------------
# pytest
# ---------------------------------------------------------------------------
[tool.pytest.ini_options]
testpaths = ["tests"]
addopts = "--strict-markers --strict-config"
markers = [
"gpu: marks tests that require a CUDA-capable GPU (deselect with '-m not gpu')",
]