Repository navigation
Expand file tree
/
Copy pathpyproject.toml
More file actions
317 lines (284 loc) · 11.9 KB
/
Copy pathpyproject.toml
File metadata and controls
317 lines (284 loc) · 11.9 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
[build-system]
requires = [
"setuptools>=61.2",
"setuptools_scm[toml]>=7"
]
build-backend = "setuptools.build_meta"
[tool.setuptools]
include-package-data = true
zip-safe = false
license-files = [
"LICENSE",
]
py-modules = []
[tool.setuptools.package-dir]
"" = "workflow/src"
[tool.setuptools.packages.find]
where = ["workflow/src"]
[tool.setuptools_scm]
write_to = "workflow/src/legendsimflow/_version.py"
[project]
name = "legend_simflow"
description = "Python package for processing LEGEND simulations"
authors = [
{name = "Luigi Pertoldi", email = "gipert@pm.me"},
]
maintainers = [
{name = "The LEGEND Collaboration"},
]
classifiers = [
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
"Operating System :: MacOS",
"Operating System :: POSIX",
"Operating System :: Unix",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Topic :: Scientific/Engineering",
]
readme = "README.md"
requires-python = ">=3.11"
dynamic = ["version"]
dependencies = [
"awkward",
"dbetto >=1.4.1",
"h5py",
"hist",
"legend-dataflow-scripts >=0.3.3,<0.4",
"legend-lh5io >=0.2.4",
"legend-pydataobj >=2",
"legend-pygeom-l200 >=0.12",
"legend-pygeom-l1000 >=0.6.2",
"legend-pygeom-tools >=0.7.1",
"legend-pygeom-hpges >=0.11",
"matplotlib",
"mplhep >=1.0",
"numpy",
"psutil",
"pyg4ometry",
"dspeed >=2.4.1",
"pygama >=2.6.2",
"pylegendmeta >=1.11",
"pyyaml",
"reboost >=1.4.2,<2",
"revertex >=0.6",
"ruamel.yaml",
"snakemake >=9.27,<9.28",
"snakemake-argparse-bridge >=0.2.0",
"snakemake-storage-plugin-fs",
"snakemake-executor-plugin-slurm",
"snakemake-logger-plugin-rich >=0.4.2",
"snakemake-logger-plugin-snkmt >=0.1.7",
]
[project.optional-dependencies]
test = [
"pylegendtestdata",
"pytest>=6",
"pytest-cov>=3",
]
docs = [
"sphinx>=7.0",
"myst_parser>=0.13",
"sphinx_inline_tabs",
"sphinx_copybutton",
"sphinx_autodoc_typehints",
"sphinxcontrib-mermaid",
"furo>=2023.08.17",
]
all = [
"legend_simflow[test,docs]",
"pre-commit",
]
[project.scripts]
snakemake-nersc = "legendsimflow.cli:snakemake_nersc_cli"
snakemake-nersc-batch = "legendsimflow.cli:snakemake_nersc_batch_cli"
[tool.pixi.workspace]
channels = ["conda-forge", "bioconda"]
platforms = ["linux-64"]
# NOTE: non-conda dependencies will be installed from pypi (e.g. legend-dataflow-scripts)
[tool.pixi.pypi-dependencies]
legend-simflow = { path = ".", editable = true }
# FIXME: remove when https://github.com/prefix-dev/pixi/issues/532 is closed
[tool.pixi.dependencies]
# legend-simflow core dependencies
awkward = "*"
dbetto = ">=1.4.1,<1.5"
# legend-dataflow-scripts = "..." # not on conda-forge
legend-lh5io = ">=0.2.4,<0.3"
legend-pydataobj = ">=2,<2.1"
pylegendmeta = ">=1.11,<1.12"
legend-pygeom-l200 = ">=0.12,<0.13"
legend-pygeom-l1000 = ">=0.6.2,<0.7"
legend-pygeom-tools = ">=0.7.1,<0.8"
dspeed = ">=2.4.1,<2.5"
matplotlib = "*"
numpy = "*"
psutil = "*"
pyyaml = "*"
"ruamel.yaml" = "*"
# execution
snakemake = ">=9.27,<9.28"
# snakemake-argparse-bridge = "..." # not on conda-forge
snakemake-storage-plugin-fs = "*"
snakemake-executor-plugin-slurm = "*"
# snakemake-logger-plugin-rich = "..." # not on conda-forge
# snakemake-logger-plugin-snkmt = ">=0.1.7" # not on conda-forge
# tier hit
hist = "*"
mplhep = ">=1.0"
legend-pygeom-hpges = ">=0.11,<0.12"
pyg4ometry = "*"
pygama = ">=2.6.2,<2.7"
reboost = ">=1.4.2,<1.5"
# software OpenGL (llvmpipe, through EGL) for the head-less stp geometry rendering
mesalib = "*"
# tier stp
remage = ">=1.1,<1.2"
# drift-time maps and other SSD.jl jobs
julia = ">=1.12,<1.13"
h5py = "*"
hdf5 = "*"
revertex = ">=0.6,<0.7"
[tool.pixi.feature.test.activation.env]
# the mock metadata of the full-chain test is not a Git checkout
METADATA_NO_GIT_REPO = "1"
[tool.pixi.activation.env]
# head-less off-screen rendering; unset to open an on-screen window
VTK_DEFAULT_OPENGL_WINDOW = "vtkEGLRenderWindow"
# libglvnd does not search the environment prefix for Mesa's EGL vendor config
__EGL_VENDOR_LIBRARY_DIRS = "$CONDA_PREFIX/share/glvnd/egl_vendor.d:/usr/share/glvnd/egl_vendor.d"
[tool.pixi.environments]
default = { solve-group = "default" }
test = { features = ["test"], solve-group = "default" }
[tool.pixi.tasks]
snakemake = { description = "Run Snakemake with arbitrary arguments, after the warmup", cmd = "snakemake", depends-on = ["warmup"] }
snakemake-nersc = { description = "Run the Simflow on several NERSC nodes in parallel, after the warmup", cmd = "snakemake-nersc", depends-on = ["warmup"] }
dry = { description = "Check the input paths and the LEGEND-200 data production, then do a Snakemake dry run", cmd = "snakemake --logger rich --dry-run", depends-on = ["validate"] }
touch = { description = "Mark all Simflow outputs as up-to-date without running jobs", cmd = "snakemake --logger rich --touch" }
validate = { description = "Check the input paths and the LEGEND-200 data production at paths.l200data", cmd = "python -m legendsimflow.validate" }
tier-opt = { description = "Run the opt tier script standalone", cmd = "python -m legendsimflow.scripts.tier.opt" }
tier-hit = { description = "Run the hit tier script standalone", cmd = "python -m legendsimflow.scripts.tier.hit" }
tier-evt = { description = "Run the evt tier script standalone", cmd = "python -m legendsimflow.scripts.tier.evt" }
tier-cvt = { description = "Run the cvt tier script standalone", cmd = "python -m legendsimflow.scripts.tier.cvt" }
tier-pdf = { description = "Run the pdf tier script standalone", cmd = "python -m legendsimflow.scripts.tier.pdf" }
extract-hpge-obs-models = { description = "Extract HPGe observable models for a LEGEND run", cmd = "python -m legendsimflow.scripts.pars.extract_hpge_observables_models" }
extract-hpge-currmod = { description = "Extract the HPGe current-pulse model for a LEGEND run", cmd = "python -m legendsimflow.scripts.extract_hpge_current_pulse_model" }
extract-hpge-impurity-model = { description = "Fit the HPGe impurity model to data drift times", cmd = "python -m legendsimflow.scripts.extract_hpge_impurity_model" }
extract-drift-time-psl-tuning = { description = "Compute event drift times over a scan of pulse-shape libraries", cmd = "python -m legendsimflow.scripts.extract_drift_time_psl_tuning" }
extract-hpge-electronics-model-scan = { description = "Extract the HPGe electronics model for a LEGEND run", cmd = "python -m legendsimflow.scripts.extract_hpge_elec_response_model_scan" }
[tool.pixi.tasks.prod]
description = "Run a production with a workflow profile, after the warmup"
cmd = "snakemake --verbose --logger {{ logger }} --workflow-profile workflow/profiles/{{ profile }}"
args = [
{arg = "profile", default = "default"},
{arg = "logger", default = "snkmt rich"},
]
depends-on = ["warmup"]
[tool.pixi.tasks.prodnodes]
description = "Run a production on several NERSC nodes, after the warmup"
cmd = "snakemake-nersc --nodes {{ n_nodes }}"
args = ["n_nodes"]
depends-on = ["warmup"]
[tool.pixi.tasks.prodsubmit]
description = "Submit a production as a NERSC Slurm batch job"
# NOTE: no need to depend on warmup since this command calls `pixi run
# snakemake[-nersc]` internally
cmd = "snakemake-nersc-batch"
[tool.pixi.tasks.warmup]
description = "Fill the Numba cache before parallel jobs start"
# the config lets the warmup discover the DSP chain to warm in l200data (as the
# workflow does); defaults to the prod-cycle config in the current directory
cmd = "python -m legendsimflow.warmup {{ config }} && touch .pixi/warmup.stamp"
args = [{ arg = "config", default = "simflow-config.yaml" }]
outputs = [".pixi/warmup.stamp"]
[tool.pixi.feature.test.tasks]
test-python = { description = "Run the Python tests", cmd = "pytest -vvv" }
init-julia-env = { description = "Set up the Julia environment of LegendSimflow.jl", cmd = "julia --project=workflow/src/LegendSimflow.jl workflow/src/legendsimflow/scripts/init-julia-env.jl && touch .pixi/julia-env.stamp", outputs = [".pixi/julia-env.stamp"] }
test-julia = { description = "Run the Julia tests", cmd = "julia --project=. -e 'using Pkg; Pkg.test()'", cwd = "workflow/src/LegendSimflow.jl", depends-on = ["init-julia-env"] }
test-julia-ci = { description = "Run the Julia tests with code coverage (for CI)", cmd = "julia --code-coverage=user --project=. -e 'using Pkg; Pkg.test(coverage=true)'", cwd = "workflow/src/LegendSimflow.jl", depends-on = ["init-julia-env"] }
test-python-pixi = { description = "Run the Python tests with code coverage (for CI)", cmd = "pytest -vvv --ignore=tests/test_workflow.py --cov=legendsimflow --cov-report=xml", depends-on = ["warmup", "init-julia-env"] }
test-l200-workflow = { description = "Run the full LEGEND-200 test workflow (needs remage)", cmd = "pytest -s -m needs_remage tests/test_workflow.py::test_l200_workflow", depends-on = ["warmup"] }
test-l200-lar-workflow = { description = "Run the full LEGEND-200 test workflow without HPGe detectors (needs remage)", cmd = "pytest -s -m needs_remage tests/test_workflow.py::test_l200_lar_workflow", depends-on = ["warmup"] }
test-l1000-workflow = { description = "Run the full LEGEND-1000 test workflow (needs remage)", cmd = "pytest -s -m needs_remage tests/test_workflow.py::test_l1000_workflow", depends-on = ["warmup"] }
test = { description = "Run the Python and Julia tests", depends-on = ["test-python", "test-julia"] }
[tool.uv.workspace]
exclude = ["generated", "inputs", "software", "workflow"]
[tool.uv]
default-groups = []
[tool.pytest.ini_options]
minversion = "6.0"
addopts = ["-ra", "--showlocals", "--strict-markers", "--strict-config", "-m", "not needs_remage and not needs_julia"]
xfail_strict = true
filterwarnings = [
"error",
"ignore:overflow encountered in divide:RuntimeWarning",
"ignore:overflow encountered in cast:RuntimeWarning",
"ignore:Constructing LpVariable\\(name, \\.\\.\\.\\) directly is deprecated:DeprecationWarning",
]
log_cli_level = "INFO"
testpaths = [
"tests",
]
markers = [
"needs_remage: tests that require a remage installation",
"needs_julia: tests that require a Julia installation with LegendSimflow.jl compiled",
]
[tool.ruff]
src = ["workflow/src"]
[tool.ruff.lint]
extend-select = [
"ARG", # flake8-unused-arguments
"B", # flake8-bugbear
"C4", # flake8-comprehensions
"EM", # flake8-errmsg
"EXE", # flake8-executable
"G", # flake8-logging-format
"I", # isort
"ICN", # flake8-import-conventions
"NPY", # NumPy specific rules
"PD", # pandas-vet
"PGH", # pygrep-hooks
"PIE", # flake8-pie
"PL", # pylint
"PT", # flake8-pytest-style
"PTH", # flake8-use-pathlib
"RET", # flake8-return
"D", # pydocstyle
"RUF", # Ruff-specific
"SIM", # flake8-simplify
"T20", # flake8-print
"UP", # pyupgrade
"YTT", # flake8-2020
]
ignore = [
"PT011", # `pytest.raises(ValueError)` is too broad
"PLR09", # Too many <...>
"PLR2004", # Magic value used in comparison
"ISC001", # Conflicts with formatter
"D1", # Missing docstring — not enforced here
"D203", # Incompatible with D211 (no-blank-line-before-class)
"D213", # Incompatible with D212 (multi-line-summary-first-line)
"D401", # Imperative mood — conflicts with noun-phrase docstring style
]
isort.required-imports = ["from __future__ import annotations"]
pydocstyle.convention = "numpy"
[tool.ruff.lint.per-file-ignores]
"tests/**" = ["T20"]
"noxfile.py" = ["T20"]
[tool.pylint]
py-version = "3.9"
ignore-paths = [".*/_version.py"]
reports.output-format = "colorized"
similarities.ignore-imports = "yes"
messages_control.disable = [
"design",
"fixme",
"line-too-long",
"missing-module-docstring",
"missing-function-docstring",
"wrong-import-position",
"too-many-nested-blocks"
]