-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathpyproject.toml
More file actions
360 lines (326 loc) · 10.9 KB
/
pyproject.toml
File metadata and controls
360 lines (326 loc) · 10.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
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
[build-system]
requires = ["setuptools>=64", "setuptools_scm[toml]>=8"]
build-backend = "setuptools.build_meta"
[tool.uv]
# Restrict lockfile to a sane subset of platforms
environments = ["sys_platform == 'linux' and platform_machine == 'x86_64'"]
[project]
name = "mx-bluesky"
classifiers = [
"Development Status :: 3 - Alpha",
"License :: OSI Approved :: Apache Software License",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
]
description = "Bluesky tools for MX Beamlines at DLS"
dependencies = [
#
# If a constraint is not set here or if the dependency is pinned to a hash
# it will be auto-pinned to the latest release version by the pre-release workflow
#
"annotated_types",
"caproto",
"fastapi[all]",
"flask-restful",
"jupyterlab",
"matplotlib",
"nexgen >= 0.11.0",
"numpy >= 2.3.5",
"opencv-python", # Needed for I24 ssx moveonclick. To be changed to headless once this is moved to separate ui.
"opentelemetry-distro",
"opentelemetry-exporter-otlp",
"pydantic",
"pydantic-extra-types >= 2.10.1",
"pyepics",
"pyzmq",
"requests",
"scanspec",
"scipy",
"semver",
"deepdiff",
"matplotlib",
"cachetools",
"bluesky-stomp >= 0.2.0",
"mysql-connector-python == 9.5.0", # Can unpin once https://github.com/DiamondLightSource/ispyb-api/pull/244 is merged and released
#
# These dependencies may be issued as pre-release versions and should have a pin constraint
# as by default pip-install will not upgrade to a pre-release.
#
"daq-config-server >= 1.3.0",
"blueapi >= 1.12.0",
"ophyd >= 1.10.5",
"ophyd-async >= 0.16.0",
"bluesky >= 1.14.6",
"dls-dodal @ git+https://github.com/DiamondLightSource/dodal.git@main",
]
dynamic = ["version"]
license.file = "LICENSE"
readme = "README.rst"
requires-python = ">=3.11"
[dependency-groups]
dev = [
"black",
"build",
# Commented out due to dependency version conflict with pydantic 1.x
# "copier",
"diff-cover",
"GitPython",
"import-linter",
"ispyb",
"ipython",
"mypy",
"myst-parser",
"plantweb",
"pre-commit",
"pydata-sphinx-theme>=0.12",
"pyright>=1.1.408",
"pytest-asyncio",
"pytest-cov",
"pytest-random-order",
"pytest-timeout",
"pytest",
"responses",
"ruff",
"sphinx-autobuild",
"sphinx-copybutton",
"sphinx-design",
"tox-uv",
"types-mock",
"types-requests",
"sphinxcontrib.mermaid", # To build dodal docs
]
[project.scripts]
mx-bluesky = "mx_bluesky.__main__:main"
run_extruder = "mx_bluesky.beamlines.i24.serial.run_serial:run_extruder"
run_fixed_target = "mx_bluesky.beamlines.i24.serial.run_serial:run_fixed_target"
hyperion = "mx_bluesky.hyperion.__main__:main"
hyperion-callbacks = "mx_bluesky.hyperion.external_interaction.callbacks.__main__:main"
redis_to_murko = "mx_bluesky.beamlines.i04.redis_to_murko_forwarder:main"
[project.urls]
GitHub = "https://github.com/DiamondLightSource/mx-bluesky"
[[project.authors]] # Further authors may be added by duplicating this section
email = "dominic.oram@diamond.ac.uk"
name = "Dominic Oram"
[tool.setuptools_scm]
version_file = "src/mx_bluesky/_version.py"
[tool.pyright]
typeCheckingMode = "strict"
reportMissingTypeStubs = false
reportUnknownMemberType = false
reportUnknownLambdaType = false
reportUnknownParameterType = false
reportUnknownArgumentType = false
reportMissingParameterType = false
reportMissingTypeArgument = false
reportPrivateUsage = false
reportUnknownVariableType = false
reportUnusedVariable = false
reportMatchNotExhaustive = false
[tool.pytest.ini_options]
# Run pytest with all our checkers, and don't spam us with massive tracebacks on error
asyncio_mode = "auto"
asyncio_default_fixture_loop_scope = "function"
timeout = 1
markers = [
"dlstbx: marks tests as requiring dlstbx (deselect with '-m \"not dlstbx\"')",
"skip_log_setup: marks tests so that loggers are not setup before the test.",
"skip_in_pycharm: marks test as not working in pycharm testrunner",
"system_test: marks tests as a system test",
"requires: marks a test as having an external dependency such as a service or hardware",
]
addopts = """
--tb=native -vv --doctest-modules --doctest-glob="*.rst" --durations=10
"""
# https://iscinumpy.gitlab.io/post/bound-version-constraints/#watch-for-warnings
filterwarnings = [
"error",
# Ophyd status objects in tests
"ignore:.*The 'done' and 'success' parameters will be removed.*:DeprecationWarning",
# Ignore nondeterministic closing of log, run_engine, etc. before test end
"ignore:(.*)unclosed file(.*)name='(.*)dodal.log'(.*):ResourceWarning",
"ignore:(.*)unclosed <socket(.*):ResourceWarning",
"ignore:(.*)unclosed event loop(.*):ResourceWarning",
# Ignore warning about deprecated throw() call https://github.com/bluesky/bluesky/issues/1817
"ignore:.*signature of throw\\(\\) is deprecated.*:DeprecationWarning",
#Remove when we drop python 3.11
"ignore:.*__contains__ will no longer raise TypeError.*:DeprecationWarning",
# epicscorelibs requires setuptools >= 70.1
"ignore:.*The 'wheel' package is no longer the canonical location of the 'bdist_wheel' command.*:DeprecationWarning",
]
# Doctest python code in docs, python code in src docstrings, test functions in tests
testpaths = "docs src tests/unit_tests"
[tool.coverage.run]
patch = ["subprocess"]
data_file = "/tmp/mx_bluesky.coverage"
[tool.coverage.paths]
# Tests are run from installed location, map back to the src directory
source = ["src", "**/site-packages/"]
[tool.tox]
skipsdist = true
# envs to runs automatically with tox -p
env_list = ["pre-commit", "type-checking", "tests", "docs"]
[tool.tox.env_run_base]
# Pass all environment variables to the test environments
passenv = ["*"]
[tool.tox.env.pre-commit]
description = "Run pre-commit on all files"
commands = [
[
"pre-commit",
"run",
"--all-files",
"--show-diff-on-failure",
{ replace = "posargs", default = [
], extend = true },
],
]
[tool.tox.env.type-checking]
description = "Run pyright"
commands = [
[
"pyright",
"--pythonpath",
"{env:VIRTUAL_ENV}/bin/python",
"src",
"tests",
{ replace = "posargs", default = [
], extend = true },
],
]
[tool.tox.env.tests]
description = "Run tests with coverage"
commands = [
[
"pytest",
"--cov=mx_bluesky",
"--cov-report",
"term",
"--cov-report",
"xml:cov.xml",
{ replace = "posargs", default = [
], extend = true },
],
]
[tool.tox.env.systemtests]
description = "Run tests with coverage"
commands = [
[
"pytest",
"--junit-xml=systemtests_output.xml",
"-m",
"system_test",
"tests/system_tests",
"--timeout=60",
{ replace = "posargs", default = [
], extend = true },
],
]
set_env = { DODAL_TEST_MODE = "true", BEAMLINE = "test" }
# Runs the system tests locally
[tool.tox.env.localsystemtests]
commands = [
[
"pytest",
"-m",
"system_test",
"--timeout=60",
"tests/system_tests",
{ replace = "posargs", default = [
], extend = true },
],
]
[tool.tox.env.localsystemtests.set_env]
DOCKER = "podman"
DODAL_TEST_MODE = "true"
ISPYB_CONFIG_PATH = "{toxinidir}/tests/test_data/ispyb-test-credentials.cfg"
ZOCALO_CONFIG = "{toxinidir}/tests/test_data/zocalo-test-configuration.yaml"
BEAMLINE = "test"
[tool.tox.env.docs]
description = "Run docs build with clean environment"
env_dir = ".venv"
skip_install = true
commands_pre = [
[
"python",
"{toxinidir}/utility_scripts/generate_plantuml.py",
"docs/developer/hyperion/reference/param_hierarchy.puml",
],
]
commands = [
[
"sphinx-build",
"--fresh-env",
"--show-traceback",
"--fail-on-warning",
"--keep-going",
"docs",
"build/html",
{ replace = "posargs", default = [
], extend = true },
],
]
[tool.tox.env.docs-autobuild]
description = "Run docs with autobuild on change"
commands = [
[
"sphinx-autobuild",
"--show-traceback",
"--watch",
"README.rst",
"docs",
"build/html",
{ replace = "posargs", default = [
], extend = true },
],
]
[tool.ruff]
src = ["src", "tests"]
line-length = 88
lint.select = [
"B", # flake8-bugbear - https://docs.astral.sh/ruff/rules/#flake8-bugbear-b
"C4", # flake8-comprehensions - https://docs.astral.sh/ruff/rules/#flake8-comprehensions-c4
"E", # pycodestyle errors - https://docs.astral.sh/ruff/rules/#error-e
"F", # pyflakes rules - https://docs.astral.sh/ruff/rules/#pyflakes-f
"N", # pep8-naming - https://docs.astral.sh/ruff/rules/#pep8-naming-n
"W", # pycodestyle warnings - https://docs.astral.sh/ruff/rules/#warning-w
"I", # isort - https://docs.astral.sh/ruff/rules/#isort-i
"UP", # pyupgrade - https://docs.astral.sh/ruff/rules/#pyupgrade-up
"SLF", # self - https://docs.astral.sh/ruff/settings/#lintflake8-self
"PT012", # flake8-pytest-style rules - https://docs.astral.sh/ruff/rules/pytest-raises-with-multiple-statements/#pytest-raises-with-multiple-statements-pt012
"RUF018", # walrus operators in asserts - https://docs.astral.sh/ruff/rules/assignment-in-assert/
"TID251", # banned api - https://docs.astral.sh/ruff/rules/banned-api/
"INP001", # missing __init__.py - https://docs.astral.sh/ruff/rules/implicit-namespace-package/
]
lint.extend-ignore = [
"E501", # Line too long
"B008", # Allow inject("device")
]
[tool.ruff.lint.per-file-ignores]
# By default, private member access is allowed in tests
# See https://github.com/DiamondLightSource/python-copier-template/issues/154
# Remove this line to forbid private member access, walrys operators in asserts, banned api in tests
"tests/**/*" = ["SLF001", "B023", "RUF018", "TID251"]
".github/**/*" = ["INP001"]
"docs/**/*" = ["INP001"]
"utility_scripts/**/*" = ["INP001"]
[tool.ruff.lint.flake8-tidy-imports.banned-api]
"time.sleep".msg = "Use bps.sleep instead. # noqa will disable this rule for that line. See https://github.com/DiamondLightSource/mx-bluesky/issues/925"
[tool.mypy]
plugins = ["pydantic.mypy"]
[tool.importlinter]
root_package = "mx_bluesky"
[[tool.importlinter.contracts]]
name = "Common does not import from apps"
type = "forbidden"
source_modules = "mx_bluesky.common"
forbidden_modules = ["mx_bluesky.beamlines", "mx_bluesky.hyperion"]
[[tool.importlinter.contracts]]
name = "Beamlines do not import from each other"
type = "independence"
modules = "mx_bluesky.beamlines.*"
[[tool.importlinter.contracts]]
name = "Beamlines do not import from hyperion"
type = "forbidden"
source_modules = "mx_bluesky.beamlines.**"
forbidden_modules = "mx_bluesky.hyperion.**"