Skip to content

Commit 04fbf35

Browse files
committed
Project Modernization
- Migrated setup.py/cfg to pyproject.toml - Switched mypy to pyproject.toml - Switched isort/flake8/black to ruff - Moved version management ot bump-my-version and pyproject.toml - Updated requirements.txt
1 parent 60cf6c3 commit 04fbf35

25 files changed

+118
-191
lines changed

.bumpversion.cfg

Lines changed: 0 additions & 16 deletions
This file was deleted.

.mypy.ini

Lines changed: 0 additions & 2 deletions
This file was deleted.

.pre-commit-config.yaml

Lines changed: 13 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
repos:
22
# Syntax validation and some basic sanity checks
33
- repo: https://github.com/pre-commit/pre-commit-hooks
4-
rev: v4.1.0
4+
rev: v5.0.0
55
hooks:
66
- id: check-merge-conflict
77
- id: check-ast
@@ -11,40 +11,23 @@ repos:
1111
args: ['--maxkb=200']
1212
- id: check-yaml
1313

14-
# Automatically sort imports
15-
- repo: https://github.com/PyCQA/isort
16-
rev: 5.12.0
14+
- repo: https://github.com/astral-sh/ruff-pre-commit
15+
rev: v0.4.8
1716
hooks:
18-
- id: isort
19-
args: [
20-
'-a', 'from __future__ import annotations', # 3.7-3.11
21-
'--rm', 'from __future__ import absolute_import', # -3.0
22-
'--rm', 'from __future__ import division', # -3.0
23-
'--rm', 'from __future__ import generator_stop', # -3.7
24-
'--rm', 'from __future__ import generators', # -2.3
25-
'--rm', 'from __future__ import nested_scopes', # -2.2
26-
'--rm', 'from __future__ import print_function', # -3.0
27-
'--rm', 'from __future__ import unicode_literals', # -3.0
28-
'--rm', 'from __future__ import with_statement', # -2.6
29-
]
17+
- id: ruff
18+
args: [--fix, --exit-non-zero-on-fix, --show-fixes]
19+
- id: ruff-format
3020

31-
# Automatic source code formatting
32-
- repo: https://github.com/psf/black
33-
rev: 22.3.0
34-
hooks:
35-
- id: black
36-
args: [--safe, --quiet]
37-
38-
# Linting
39-
- repo: https://github.com/PyCQA/flake8
40-
rev: 4.0.1
41-
hooks:
42-
- id: flake8
43-
additional_dependencies: ['flake8-comprehensions==3.8.0']
21+
# # Linting
22+
# - repo: https://github.com/PyCQA/flake8
23+
# rev: 7.1.1
24+
# hooks:
25+
# - id: flake8
26+
# additional_dependencies: ['flake8-comprehensions==3.8.0']
4427

4528
# Type checking
4629
- repo: https://github.com/pre-commit/mirrors-mypy
47-
rev: v0.910
30+
rev: v1.13.0
4831
hooks:
4932
- id: mypy
5033
files: 'src/.*\.py$'

MANIFEST.in

Lines changed: 0 additions & 13 deletions
This file was deleted.

pyproject.toml

Lines changed: 82 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,91 @@
11
[build-system]
2-
requires = ["setuptools >= 40.6.0", "wheel"]
2+
requires = ["setuptools>=61.2", "setuptools-scm"]
33
build-backend = "setuptools.build_meta"
44

5+
[project]
6+
name = "workflows"
7+
version = "2.27"
8+
description = "Data processing in distributed environments"
9+
readme = "README.rst"
10+
authors = [
11+
{ name = "Diamond Light Source", email = "[email protected]" },
12+
]
13+
classifiers = [
14+
"Development Status :: 5 - Production/Stable",
15+
"Intended Audience :: Developers",
16+
"License :: OSI Approved :: BSD License",
17+
"Programming Language :: Python :: 3",
18+
"Programming Language :: Python :: 3.8",
19+
"Programming Language :: Python :: 3.9",
20+
"Programming Language :: Python :: 3.10",
21+
"Programming Language :: Python :: 3.11",
22+
"Operating System :: OS Independent",
23+
"Topic :: Software Development :: Libraries :: Python Modules",
24+
]
25+
license = { text = "BSD-3-Clause" }
26+
requires-python = ">=3.8"
27+
dependencies = ["bidict", "pika", "setuptools", "stomp-py>=7"]
28+
29+
[project.urls]
30+
Download = "https://github.com/DiamondLightSource/python-workflows/releases"
31+
Documentation = "https://github.com/DiamondLightSource/python-workflows"
32+
GitHub = "https://github.com/DiamondLightSource/python-workflows"
33+
Bug-Tracker = "https://github.com/DiamondLightSource/python-workflows/issues"
34+
35+
[project.optional-dependencies]
36+
prometheus = ["prometheus-client"]
37+
38+
[project.entry-points."libtbx.dispatcher.script"]
39+
"workflows.validate_recipe" = "workflows.validate_recipe"
40+
41+
[project.entry-points."libtbx.precommit"]
42+
workflows = "workflows"
43+
44+
[project.entry-points."workflows.services"]
45+
SampleConsumer = "workflows.services.sample_consumer:SampleConsumer"
46+
SampleProducer = "workflows.services.sample_producer:SampleProducer"
47+
SampleTxn = "workflows.services.sample_transaction:SampleTxn"
48+
SampleTxnProducer = "workflows.services.sample_transaction:SampleTxnProducer"
49+
50+
[project.entry-points."workflows.transport"]
51+
PikaTransport = "workflows.transport.pika_transport:PikaTransport"
52+
StompTransport = "workflows.transport.stomp_transport:StompTransport"
53+
OfflineTransport = "workflows.transport.offline_transport:OfflineTransport"
54+
55+
[project.entry-points."zocalo.configuration.plugins"]
56+
pika = "workflows.util.zocalo.configuration:Pika"
57+
stomp = "workflows.util.zocalo.configuration:Stomp"
58+
transport = "workflows.util.zocalo.configuration:DefaultTransport"
59+
60+
[project.scripts]
61+
"workflows.validate_recipe" = "workflows.recipe.validate:main"
62+
563
[tool.isort]
664
profile = "black"
765

866
[tool.pytest.ini_options]
967
addopts = "-ra"
1068
required_plugins = "pytest-timeout"
69+
70+
[tool.bumpversion]
71+
current_version = "2.27"
72+
parse = '(?P<major>\d+)\.(?P<minor>\d+)'
73+
serialize = ["{major}.{minor}"]
74+
commit = true
75+
tag = true
76+
77+
[[tool.bumpversion.files]]
78+
filename = "src/workflows/__init__.py"
79+
80+
[tool.ruff.lint]
81+
select = ["E", "F", "W", "C4", "I"]
82+
unfixable = ["F841"]
83+
# E501 line too long (handled by formatter)
84+
ignore = ["E501"]
85+
86+
[tool.ruff.lint.isort]
87+
known-first-party = ["dxtbx_*", "dxtbx"]
88+
required-imports = ["from __future__ import annotations"]
89+
90+
[tool.mypy]
91+
mypy_path = "src/"

requirements_dev.txt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
bidict==0.22.1
2-
prometheus-client==0.17.0
3-
pytest==8.2.2
4-
pytest-cov==5.0.0
5-
pytest-mock==3.11.1
6-
pytest-timeout==2.1.0
7-
setuptools==70.0.0
8-
stomp.py==8.1.0
1+
bidict==0.23.1
92
pika==1.3.2
3+
prometheus_client==0.21.0
4+
pytest==8.3.3
5+
pytest-cov==6.0.0
6+
pytest-mock==3.14.0
7+
pytest-timeout==2.3.1
8+
stomp-py==8.1.2
9+
websocket-client==1.8.0

setup.cfg

Lines changed: 0 additions & 82 deletions
This file was deleted.

setup.py

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/workflows/contrib/start_service.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from __future__ import annotations
22

33
import sys
4-
54
from optparse import SUPPRESS_HELP, OptionParser
65

76
import workflows

src/workflows/frontend/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,8 @@ def get_status(self):
368368

369369
def exponential_backoff(self):
370370
"""A function that keeps waiting longer and longer the more rapidly it is called.
371-
It can be used to increasingly slow down service starts when they keep failing."""
371+
It can be used to increasingly slow down service starts when they keep failing.
372+
"""
372373
last_service_switch = self._service_starttime
373374
if not last_service_switch:
374375
return

0 commit comments

Comments
 (0)