Skip to content

Commit ae1d403

Browse files
committed
Implements pyproject, removing setup.cfg
NOT BACKWARD COMPATIBLE, requires Odin-data: 1.10.2, Odin-control: 1.6.0 Raises appropriate error if control interface's IP/MAC cannot be determined Cuts down number of redundant Python packages from dependencies archiver: Updates version control to setuptools SCM Moves versioning from versioneer to setuptools SCM odin_server.js: improves source code readability Adds live histogram adapter unit tests Updates tox test environment.
1 parent fe00def commit ae1d403

14 files changed

+349
-668
lines changed

control/pyproject.toml

+138
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
[build-system]
2+
requires = ["setuptools>=64", "setuptools_scm[toml]>=8"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "hexitec"
7+
classifiers = [
8+
"Development Status :: 4 - Beta",
9+
"License :: OSI Approved :: Apache Software License",
10+
"Programming Language :: Python :: 3.8",
11+
"Programming Language :: Python :: 3.9",
12+
"Programming Language :: Python :: 3.10",
13+
]
14+
description = "Odin Detector Adapters for Hexitec"
15+
dynamic = ["version"]
16+
readme = "README.md"
17+
license.file = "LICENSE"
18+
authors = [
19+
{name = "Christian Angelsen", email = "[email protected]"},
20+
]
21+
requires-python = ">= 3.8"
22+
23+
dependencies = [
24+
"odin-control @ git+https://[email protected]/odin-detector/odin-control.git",
25+
"odin-data @ git+https://[email protected]/odin-detector/[email protected]#subdirectory=python",
26+
"attrs",
27+
"coverage",
28+
"exceptiongroup",
29+
"future",
30+
"httpie",
31+
"h5py",
32+
"iniconfig",
33+
"matplotlib",
34+
"numpy==1.24.2",
35+
"opencv-python",
36+
"persist-queue",
37+
"pluggy",
38+
"psutil",
39+
"pytest",
40+
"pytest-cov",
41+
"pytest_asyncio",
42+
"pyzmq",
43+
"requests",
44+
"tox",
45+
"urllib3==1.26.14",
46+
"xmltodict"
47+
]
48+
49+
[project.optional-dependencies]
50+
dev = [
51+
"tox",
52+
]
53+
54+
sync_proxy = [
55+
"requests"
56+
]
57+
graylog = [
58+
"pygelf"
59+
]
60+
61+
[project.scripts]
62+
odin_control = "odin.main:main"
63+
odin_server = "odin.main:main_deprecate"
64+
65+
[project.urls]
66+
GitHub = "https://github.com/stfc-aeg/hexitec-detector"
67+
68+
[tool.setuptools_scm]
69+
version_file = "src/hexitec/_version.py"
70+
root = ".."
71+
72+
[tool.coverage.paths]
73+
source = ["src", "**/site-packages/"]
74+
75+
[tool.coverage.run]
76+
data_file = "/tmp/hexitec.coverage"
77+
78+
[tool.pytest.ini_options]
79+
addopts = "-vv --cov=odin --cov-report=term-missing --asyncio-mode=strict"
80+
# Addresses '"asyncio_default_fixture_loop_scope" is unset':
81+
asyncio_default_fixture_loop_scope = "function"
82+
83+
[tool.tox]
84+
legacy_tox_ini = """
85+
# tox test configuration for hexitec
86+
87+
[tox]
88+
envlist = clean, py{38, 39, 310}, report
89+
90+
[gh-actions]
91+
python =
92+
3.8: py38
93+
3.9: py39
94+
3.10: py310, clean, report
95+
96+
[testenv]
97+
install_command = pip install --no-deps --index-url https://gitlab.com/api/v4/projects/44753656/packages/pypi/simple rdmacontrol boardcfgstatus hexitec-vsr udpcore
98+
99+
deps =
100+
cycler
101+
git+https://github.com/odin-detector/odin-control.git#egg=odin_control
102+
Pillow
103+
kiwisolver
104+
pytest
105+
pytest-cov
106+
pytest_asyncio
107+
python-dateutil
108+
requests
109+
six
110+
tomli
111+
tornado>=6.4.1
112+
xmltodict
113+
setenv =
114+
py{38,39, 310}: COVERAGE_FILE=.coverage.{envname}
115+
commands =
116+
pytest --cov=hexitec {posargs:-vv}
117+
depends =
118+
py{38,39,310}: clean
119+
report: py{38,39,310}
120+
121+
[testenv:clean]
122+
skip_install = true
123+
deps = coverage
124+
commands = coverage erase
125+
126+
[testenv:report]
127+
skip_install = true
128+
deps = coverage
129+
commands =
130+
coverage combine
131+
coverage report -m
132+
133+
[flake8]
134+
ignore = E226,E302,E41
135+
max-line-length = 160
136+
exclude = tests/*
137+
max-complexity = 10
138+
"""

control/setup.cfg

-106
This file was deleted.

control/setup.py

-12
This file was deleted.

control/src/hexitec/FileInterface.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
from odin.adapters.adapter import ApiAdapter, ApiAdapterResponse, request_types, response_types
1919
from odin.adapters.parameter_tree import ParameterTree, ParameterTreeError
20-
from odin._version import get_versions
20+
from odin._version import __version__
2121

2222
DIRECTORY_CONFIG_NAME = "directories"
2323

@@ -146,11 +146,11 @@ def __init__(self, directories):
146146
self.init_time = time.time()
147147

148148
# Get package version information
149-
version_info = get_versions()
149+
version_info = __version__
150150

151151
# Store all information in a parameter tree
152152
self.param_tree = ParameterTree({
153-
'odin_version': version_info['version'],
153+
'odin_version': version_info,
154154
'tornado_version': tornado.version,
155155
'server_uptime': (self.get_server_uptime, None),
156156
'fr_config_files': (self.get_fr_config_files, None),

control/src/hexitec/HexitecDAQ.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,7 @@ def write_metadata(self, metadata_group, param_tree_dict, hdf_file):
638638

639639
for param_file in file_name:
640640
if param_file not in param_tree_dict:
641-
print(" *** {} not in parameter tree: {}".format(param_file, param_tree_dict))
641+
logging.error("File {} not in parameter tree: {}".format(param_file, param_tree_dict))
642642
continue
643643
# Only attempt to open file if it exists
644644
file_name = param_tree_dict[param_file]

control/src/hexitec/HexitecFem.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,12 @@ def extract_interface_parameters(self, iface):
270270
ip_address = str(interface_param.address)
271271
if str(interface_param.family) == "AddressFamily.AF_PACKET":
272272
mac_address = str(interface_param.address)
273+
if ip_address is None:
274+
error = f"Control Interface '{iface}' couldn't parse IP from '{ip_address}'"
275+
raise ParameterTreeError(error)
276+
if mac_address is None:
277+
error = f"Control Interface '{iface}' couldn't parse MAC from '{mac_address}'"
278+
raise ParameterTreeError(error)
273279
return ip_address, mac_address
274280

275281
def extract_string_parameters(self, param):
@@ -787,8 +793,6 @@ def acquire_data(self):
787793
logging.debug("Enable data")
788794
self.data_en(enable=True)
789795
time.sleep(0.2)
790-
# data_triggered_timestamp = '%s' % (datetime.now().strftime(HexitecFem.DATE_FORMAT))
791-
# print(f" fem.data_triggered_timestamp: {data_triggered_timestamp} [X ")
792796

793797
# Stop data flow (free acquisition mode), reset setting if number of frames mode
794798
logging.debug("Disable data")

0 commit comments

Comments
 (0)