lima2.client 3.1.2__tar.gz → 4.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. lima2_client-4.0.0/PKG-INFO +295 -0
  2. lima2_client-4.0.0/README.md +236 -0
  3. lima2_client-4.0.0/pyproject.toml +107 -0
  4. lima2_client-4.0.0/src/lima2/client/__init__.py +9 -0
  5. lima2_client-4.0.0/src/lima2/client/exceptions.py +20 -0
  6. lima2_client-4.0.0/src/lima2/client/services.py +415 -0
  7. lima2_client-4.0.0/src/lima2/client/session.py +122 -0
  8. lima2_client-4.0.0/src/lima2/client/shell.py +132 -0
  9. lima2_client-4.0.0/src/lima2/common/__init__.py +13 -0
  10. {lima2_client-3.1.2/src/lima2/client → lima2_client-4.0.0/src/lima2/common}/devencoded/__init__.py +5 -0
  11. {lima2_client-3.1.2/src/lima2/client → lima2_client-4.0.0/src/lima2/common}/devencoded/dense_frame.py +4 -3
  12. {lima2_client-3.1.2/src/lima2/client → lima2_client-4.0.0/src/lima2/common}/devencoded/smx_sparse_frame.py +26 -15
  13. {lima2_client-3.1.2/src/lima2/client → lima2_client-4.0.0/src/lima2/common}/devencoded/sparse_frame.py +10 -10
  14. {lima2_client-3.1.2/src/lima2/client → lima2_client-4.0.0/src/lima2/common}/devencoded/structured_array.py +12 -14
  15. lima2_client-4.0.0/src/lima2/common/exceptions.py +143 -0
  16. lima2_client-4.0.0/src/lima2/common/pipelines.py +131 -0
  17. {lima2_client-3.1.2/src/lima2/client → lima2_client-4.0.0/src/lima2/common}/progress_counter.py +34 -5
  18. lima2_client-4.0.0/src/lima2/common/state.py +138 -0
  19. lima2_client-4.0.0/src/lima2/common/types.py +210 -0
  20. lima2_client-4.0.0/src/lima2/conductor/__init__.py +6 -0
  21. lima2_client-4.0.0/src/lima2/conductor/acquisition_system.py +628 -0
  22. lima2_client-4.0.0/src/lima2/conductor/processing/__init__.py +68 -0
  23. lima2_client-4.0.0/src/lima2/conductor/processing/failing.py +26 -0
  24. lima2_client-4.0.0/src/lima2/conductor/processing/legacy.py +27 -0
  25. lima2_client-4.0.0/src/lima2/conductor/processing/master_file.py +401 -0
  26. lima2_client-4.0.0/src/lima2/conductor/processing/pipeline.py +592 -0
  27. lima2_client-4.0.0/src/lima2/conductor/processing/reduced_data.py +576 -0
  28. lima2_client-4.0.0/src/lima2/conductor/processing/smx.py +57 -0
  29. lima2_client-4.0.0/src/lima2/conductor/processing/xpcs.py +28 -0
  30. lima2_client-4.0.0/src/lima2/conductor/tango/__init__.py +9 -0
  31. lima2_client-4.0.0/src/lima2/conductor/tango/control.py +202 -0
  32. lima2_client-4.0.0/src/lima2/conductor/tango/processing.py +188 -0
  33. lima2_client-4.0.0/src/lima2/conductor/tango/receiver.py +197 -0
  34. lima2_client-4.0.0/src/lima2/conductor/tango/utils.py +64 -0
  35. lima2_client-4.0.0/src/lima2/conductor/topology.py +311 -0
  36. lima2_client-4.0.0/src/lima2/conductor/utils.py +199 -0
  37. lima2_client-4.0.0/src/lima2/conductor/webservice/__init__.py +10 -0
  38. lima2_client-4.0.0/src/lima2/conductor/webservice/acquisition.py +230 -0
  39. lima2_client-4.0.0/src/lima2/conductor/webservice/benchmark.py +55 -0
  40. lima2_client-4.0.0/src/lima2/conductor/webservice/benchmark_generators/__init__.py +6 -0
  41. lima2_client-4.0.0/src/lima2/conductor/webservice/benchmark_generators/rois.py +58 -0
  42. lima2_client-4.0.0/src/lima2/conductor/webservice/cli.py +85 -0
  43. lima2_client-4.0.0/src/lima2/conductor/webservice/detector.py +115 -0
  44. lima2_client-4.0.0/src/lima2/conductor/webservice/main.py +98 -0
  45. lima2_client-4.0.0/src/lima2/conductor/webservice/pipeline.py +489 -0
  46. lima2_client-4.0.0/src/lima2/conductor/webservice/utils.py +103 -0
  47. lima2_client-4.0.0/src/lima2/conductor/webservice/webapp.py +175 -0
  48. lima2_client-4.0.0/src/lima2_client.egg-info/PKG-INFO +295 -0
  49. lima2_client-4.0.0/src/lima2_client.egg-info/SOURCES.txt +57 -0
  50. lima2_client-4.0.0/src/lima2_client.egg-info/entry_points.txt +3 -0
  51. lima2_client-4.0.0/src/lima2_client.egg-info/requires.txt +40 -0
  52. lima2_client-4.0.0/src/lima2_client.egg-info/top_level.txt +1 -0
  53. lima2_client-3.1.2/PKG-INFO +0 -94
  54. lima2_client-3.1.2/README.md +0 -42
  55. lima2_client-3.1.2/pyproject.toml +0 -74
  56. lima2_client-3.1.2/src/finite_state_machine/__init__.py +0 -6
  57. lima2_client-3.1.2/src/finite_state_machine/draw_state_diagram.py +0 -108
  58. lima2_client-3.1.2/src/finite_state_machine/examples/async_github_pull_request.py +0 -46
  59. lima2_client-3.1.2/src/finite_state_machine/examples/async_turnstile.py +0 -21
  60. lima2_client-3.1.2/src/finite_state_machine/examples/boolean_field.py +0 -22
  61. lima2_client-3.1.2/src/finite_state_machine/examples/github_pull_request.py +0 -30
  62. lima2_client-3.1.2/src/finite_state_machine/examples/turnstile.py +0 -17
  63. lima2_client-3.1.2/src/finite_state_machine/exceptions.py +0 -13
  64. lima2_client-3.1.2/src/finite_state_machine/state_machine.py +0 -153
  65. lima2_client-3.1.2/src/lima2/client/__init__.py +0 -19
  66. lima2_client-3.1.2/src/lima2/client/client.py +0 -437
  67. lima2_client-3.1.2/src/lima2/client/convert.py +0 -34
  68. lima2_client-3.1.2/src/lima2/client/detector.py +0 -708
  69. lima2_client-3.1.2/src/lima2/client/pipeline.py +0 -829
  70. lima2_client-3.1.2/src/lima2/client/pipelines/__init__.py +0 -44
  71. lima2_client-3.1.2/src/lima2/client/pipelines/failing.py +0 -51
  72. lima2_client-3.1.2/src/lima2/client/pipelines/legacy.py +0 -60
  73. lima2_client-3.1.2/src/lima2/client/pipelines/smx.py +0 -178
  74. lima2_client-3.1.2/src/lima2/client/pipelines/xpcs.py +0 -141
  75. lima2_client-3.1.2/src/lima2/client/shell.py +0 -165
  76. lima2_client-3.1.2/src/lima2/client/state_machine.py +0 -254
  77. lima2_client-3.1.2/src/lima2/client/topology.py +0 -166
  78. lima2_client-3.1.2/src/lima2/client/utils.py +0 -97
  79. lima2_client-3.1.2/src/lima2/master_file/generate.py +0 -819
  80. lima2_client-3.1.2/src/lima2/server/__init__.py +0 -9
  81. lima2_client-3.1.2/src/lima2/server/control.py +0 -196
  82. lima2_client-3.1.2/src/lima2/server/receiver.py +0 -195
  83. lima2_client-3.1.2/src/lima2/server/timer.py +0 -26
  84. lima2_client-3.1.2/src/lima2_client.egg-info/PKG-INFO +0 -94
  85. lima2_client-3.1.2/src/lima2_client.egg-info/SOURCES.txt +0 -47
  86. lima2_client-3.1.2/src/lima2_client.egg-info/entry_points.txt +0 -2
  87. lima2_client-3.1.2/src/lima2_client.egg-info/requires.txt +0 -31
  88. lima2_client-3.1.2/src/lima2_client.egg-info/top_level.txt +0 -2
  89. {lima2_client-3.1.2 → lima2_client-4.0.0}/LICENSE +0 -0
  90. {lima2_client-3.1.2 → lima2_client-4.0.0}/setup.cfg +0 -0
  91. {lima2_client-3.1.2 → lima2_client-4.0.0}/src/lima2/client/py.typed +0 -0
  92. {lima2_client-3.1.2/src/lima2/client → lima2_client-4.0.0/src/lima2/common}/devencoded/exception.py +0 -0
  93. {lima2_client-3.1.2/src/lima2/master_file → lima2_client-4.0.0/src/lima2/common}/py.typed +0 -0
  94. /lima2_client-3.1.2/src/finite_state_machine/examples/__init__.py → /lima2_client-4.0.0/src/lima2/conductor/py.typed +0 -0
  95. {lima2_client-3.1.2 → lima2_client-4.0.0}/src/lima2_client.egg-info/dependency_links.txt +0 -0
@@ -0,0 +1,295 @@
1
+ Metadata-Version: 2.4
2
+ Name: lima2-client
3
+ Version: 4.0.0
4
+ Summary: Python client library for Lima2 detector
5
+ Author: BCU (ESRF)
6
+ License: Copyright (c) 2020-2024 Beamline Control Unit, ESRF
7
+
8
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
11
+
12
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
13
+
14
+ Project-URL: Repository, https://gitlab.esrf.fr/limagroup/lima2-client
15
+ Project-URL: Documentation, https://limagroup.gitlab-pages.esrf.fr/lima2-client/
16
+ Classifier: Intended Audience :: Science/Research
17
+ Classifier: License :: OSI Approved :: MIT License
18
+ Classifier: Programming Language :: Python :: 3
19
+ Requires-Python: >=3.10
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ Requires-Dist: h5py
23
+ Requires-Dist: jsonschema
24
+ Requires-Dist: jsonschema-default
25
+ Requires-Dist: numpy
26
+ Requires-Dist: pytango
27
+ Requires-Dist: pyyaml
28
+ Requires-Dist: requests
29
+ Requires-Dist: termcolor
30
+ Requires-Dist: typing-extensions
31
+ Requires-Dist: typer
32
+ Provides-Extra: conductor
33
+ Requires-Dist: starlette; extra == "conductor"
34
+ Requires-Dist: uvicorn[standard]; extra == "conductor"
35
+ Provides-Extra: shell
36
+ Requires-Dist: ipython; extra == "shell"
37
+ Provides-Extra: dev
38
+ Requires-Dist: black==22.3; extra == "dev"
39
+ Requires-Dist: flake8; extra == "dev"
40
+ Requires-Dist: httpx; extra == "dev"
41
+ Requires-Dist: lima2-client[conductor]; extra == "dev"
42
+ Requires-Dist: lima2-client[shell]; extra == "dev"
43
+ Requires-Dist: mypy; extra == "dev"
44
+ Requires-Dist: nosqltangodb; extra == "dev"
45
+ Requires-Dist: pytest; extra == "dev"
46
+ Requires-Dist: pytest-asyncio; extra == "dev"
47
+ Requires-Dist: pytest-cov; extra == "dev"
48
+ Requires-Dist: requests-mock; extra == "dev"
49
+ Requires-Dist: types-jsonschema; extra == "dev"
50
+ Requires-Dist: types-pyyaml; extra == "dev"
51
+ Requires-Dist: types-requests; extra == "dev"
52
+ Provides-Extra: docs
53
+ Requires-Dist: mkdocs; extra == "docs"
54
+ Requires-Dist: markdown-include; extra == "docs"
55
+ Requires-Dist: mkdocs-material; extra == "docs"
56
+ Requires-Dist: mkdocstrings[python]; extra == "docs"
57
+ Requires-Dist: pygments; extra == "docs"
58
+ Dynamic: license-file
59
+
60
+ # LImA 2 Client
61
+
62
+ ![pypi badge](https://badge.fury.io/py/lima2.client.svg?icon=si%3Apython)
63
+ ![pipeline badge](https://gitlab.esrf.fr/limagroup/lima2-client/badges/main/pipeline.svg)
64
+ ![coverage badge](https://gitlab.esrf.fr/limagroup/lima2-client/badges/main/coverage.svg?min_good=90&min_acceptable=80&min_medium=75)
65
+
66
+ This repo contains source code for the Lima2 Conductor, an orchestration module
67
+ for the Lima2 acquisition system, and its python client library, the
68
+ `lima2.client` package.
69
+
70
+ Install the lima2-client package:
71
+
72
+ ```sh
73
+ pip install lima2-client
74
+ ```
75
+
76
+ ## Quickstart
77
+
78
+ A minimal setup for running Lima2 requires:
79
+
80
+ - The [`lima2`](https://anaconda.org/esrf-bcu/lima2) conda package
81
+ - The [`lima2-client`](https://pypi.org/project/lima2-client/) python package
82
+ - A tango server, e.g. [`nosqltangodb`](https://pypi.org/project/nosqltangodb/)
83
+
84
+ > **_NOTE:_** In a bliss environment, the tango server comes with `bliss-demo-servers`,
85
+ > so `nosqltangodb` is not required.
86
+
87
+ Install everything into a new conda environment:
88
+
89
+ ```sh
90
+ conda create -n lima2 "python==3.10"
91
+ conda activate lima2
92
+ conda install -c esrf-bcu lima2
93
+ pip install lima2-client[conductor,shell] nosqltangodb
94
+ ```
95
+
96
+ The first step is to start the tango server. For `nosqltangodb`, example config
97
+ files can be found in the repo's
98
+ [`tests/integration/tango_db/`](https://gitlab.esrf.fr/limagroup/lima2-client/-/tree/main/tests/integration/tango_db)
99
+ directory. Fetch it into the current directory with:
100
+
101
+ ```sh
102
+ wget -qO- https://gitlab.esrf.fr/limagroup/lima2-client/-/archive/main/lima2-client-main.tar.gz?path=tests/integration/tango_db | tar -xz --strip-components=1
103
+ ```
104
+
105
+ Start the tango server:
106
+
107
+ ```sh
108
+ NosqlTangoDB --port 10000 --db_access yaml:tests/integration/tango_db/ 2
109
+ ```
110
+
111
+ Start the Lima2 devices (one control, two receivers):
112
+
113
+ ```sh
114
+ export TANGO_HOST="localhost:10000"
115
+ mpiexec -n 1 lima2_tango simulator_ctl : \
116
+ -n 1 lima2_tango simulator_rcv1 : \
117
+ -n 1 lima2_tango simulator_rcv2
118
+ ```
119
+
120
+ Start the Lima2 Conductor, which listens on port 58712 by default:
121
+
122
+ ```sh
123
+ lima2-conductor start \
124
+ localhost:10000 \
125
+ round_robin \
126
+ id00/limacontrol/simulator \
127
+ id00/limareceiver/simulator1 \
128
+ id00/limareceiver/simulator2
129
+ ```
130
+
131
+ With all parts online, a client can now make requests to the conductor to
132
+ interact with the acquisition system.
133
+
134
+ The quickest way to start is inside the interactive session (requires the
135
+ `lima2-client[shell]` extra dependencies):
136
+
137
+ ```sh
138
+ lima2-shell
139
+ ```
140
+
141
+ ```py
142
+ In [1]: run_acquisition(nb_frames=120, expo_time=0.02) # Should take 2.4 seconds
143
+ In [2]: pipeline.progress()
144
+ Out[2]:
145
+ {'nb_frames_counters': 0,
146
+ 'nb_frames_input': 120,
147
+ 'nb_frames_source': 120,
148
+ [...]
149
+ ```
150
+
151
+ In the shell, the entire API of the conductor is exposed via the following
152
+ namespaces:
153
+
154
+ - `acquisition`: direct commands (prepare, start, stop, reset), system state and
155
+ progress
156
+ - `detector`: detector information, commands, capabilities and real-time status
157
+ - `pipeline`: data access (reduced data streams, frames) and detailed processing
158
+ progress
159
+
160
+ For more details, the [lima2-shell doc](https://limagroup.gitlab-pages.esrf.fr/lima2-client/shell/) and the
161
+ [API reference](https://limagroup.gitlab-pages.esrf.fr/lima2-client/reference/)
162
+ should be useful.
163
+
164
+ ## Description
165
+
166
+ This repo is organized as follows:
167
+
168
+ ```sh
169
+ lima2-client
170
+ ├── conda # Conda build configuration
171
+ ├── docs # Documentation sources
172
+ ├── scripts # Auxiliary scripts
173
+ ├── src/lima2
174
+ │   ├── client # Conductor client-side library
175
+ │   ├── conductor # Conductor server code
176
+ │   └── common # Shared definitions
177
+ └── tests
178
+ ├── integration
179
+ └── unit
180
+ ├── client
181
+ ├── conductor
182
+ └── common
183
+ ```
184
+
185
+ The project is composed of three main python packages.
186
+
187
+ ### `lima2.client`
188
+
189
+ The conductor's client-side library, meant to be imported from a control
190
+ application or a data consumer. In this package, the conductor webapp's API
191
+ endpoints are wrapped into python functions. The docs contain a complete [API
192
+ reference](https://limagroup.gitlab-pages.esrf.fr/lima2-client/reference/).
193
+
194
+ ### `lima2.conductor`
195
+
196
+ Implements the [Lima2
197
+ Conductor](https://limagroup.gitlab-pages.esrf.fr/lima2-client/dev/conductor_requirements/),
198
+ the orchestration process for distributed acquisitions.
199
+
200
+ Its central class is the
201
+ [`AcquisitionSystem`](https://limagroup.gitlab-pages.esrf.fr/lima2-client/dev/conductor_design/#acquisition-system),
202
+ which encapsulates the Lima2 acquisition, detector and processing systems.
203
+
204
+ This package also contains the `lima2.conductor.webservice` subpackage: the
205
+ conductor web server, which provides HTTP endpoints to interact with the
206
+ conductor remotely.
207
+
208
+ ### `lima2.common`
209
+
210
+ Contains type definitions and utilities meant to be imported from
211
+ `lima2.client`, `lima2.conductor`, and directly from client apps.
212
+
213
+ ## Development environment
214
+
215
+ The `dev` optional dependencies contains tools necessary for development and testing.
216
+
217
+ ### uv
218
+
219
+ Install all dependencies into a local venv:
220
+
221
+ ```sh
222
+ uv sync --extra dev
223
+ ```
224
+
225
+ Commands can be run with `uv run`:
226
+
227
+ ```sh
228
+ uv run lima2-conductor --help
229
+ uv run lima2-shell --help
230
+ ```
231
+
232
+ > **_NOTE:_** lima2-conductor has a `dev` command, which enables live code reloading
233
+ > on save.
234
+
235
+ ### conda
236
+
237
+ Create a new conda environment with python > 3.9:
238
+
239
+ ```sh
240
+ conda create -n lima2-client "python==3.10"
241
+ conda activate lima2-client
242
+ pip install -e .[dev]
243
+ ```
244
+
245
+ Execute commands directly:
246
+
247
+ ```sh
248
+ lima2-conductor --help
249
+ lima2-shell --help
250
+ ```
251
+
252
+ ## Tests
253
+
254
+ Unit and integration tests can be run locally. All dependencies for unit tests should be in the optional `dev` dependencies, and the `pyproject.toml` defines common `pytest` parameters.
255
+
256
+ After setting up your [dev environment](#development-environment), run the unit tests (prepend `uv run` if using uv):
257
+
258
+ ```sh
259
+ pytest tests/unit
260
+ # Compute coverage and output the coverage report to htmlcov/
261
+ pytest --cov lima2.client --cov lima2.conductor --cov-report html tests/unit/
262
+ ```
263
+
264
+ Integration tests require the Lima2 server, available via conda (see [install with conda](#conda)):
265
+
266
+ ```sh
267
+ conda activate lima2-client
268
+ conda install -c esrf-bcu lima2
269
+ pytest tests/integration
270
+ ```
271
+
272
+ ## Documentation
273
+
274
+ The repo's [pages](https://limagroup.gitlab-pages.esrf.fr/lima2-client/) contain
275
+ user guides, an API reference and design docs. Source files used to build the
276
+ documentation are located in the `docs/` directory.
277
+
278
+ The docs are written in markdown and rendered by
279
+ [`mkdocs`](https://www.mkdocs.org/).
280
+
281
+ ### Build the docs (uv)
282
+
283
+ ```sh
284
+ uv sync --extra docs
285
+ uv run mkdocs serve # Start the dev server at localhost:8000
286
+ uv run mkdocs build # Render HTML pages to ./site/
287
+ ```
288
+
289
+ ### Build the docs (conda/pip)
290
+
291
+ ```sh
292
+ pip install .[docs]
293
+ mkdocs serve # Start the dev server at localhost:8000
294
+ mkdocs build # Render HTML pages to ./site/
295
+ ```
@@ -0,0 +1,236 @@
1
+ # LImA 2 Client
2
+
3
+ ![pypi badge](https://badge.fury.io/py/lima2.client.svg?icon=si%3Apython)
4
+ ![pipeline badge](https://gitlab.esrf.fr/limagroup/lima2-client/badges/main/pipeline.svg)
5
+ ![coverage badge](https://gitlab.esrf.fr/limagroup/lima2-client/badges/main/coverage.svg?min_good=90&min_acceptable=80&min_medium=75)
6
+
7
+ This repo contains source code for the Lima2 Conductor, an orchestration module
8
+ for the Lima2 acquisition system, and its python client library, the
9
+ `lima2.client` package.
10
+
11
+ Install the lima2-client package:
12
+
13
+ ```sh
14
+ pip install lima2-client
15
+ ```
16
+
17
+ ## Quickstart
18
+
19
+ A minimal setup for running Lima2 requires:
20
+
21
+ - The [`lima2`](https://anaconda.org/esrf-bcu/lima2) conda package
22
+ - The [`lima2-client`](https://pypi.org/project/lima2-client/) python package
23
+ - A tango server, e.g. [`nosqltangodb`](https://pypi.org/project/nosqltangodb/)
24
+
25
+ > **_NOTE:_** In a bliss environment, the tango server comes with `bliss-demo-servers`,
26
+ > so `nosqltangodb` is not required.
27
+
28
+ Install everything into a new conda environment:
29
+
30
+ ```sh
31
+ conda create -n lima2 "python==3.10"
32
+ conda activate lima2
33
+ conda install -c esrf-bcu lima2
34
+ pip install lima2-client[conductor,shell] nosqltangodb
35
+ ```
36
+
37
+ The first step is to start the tango server. For `nosqltangodb`, example config
38
+ files can be found in the repo's
39
+ [`tests/integration/tango_db/`](https://gitlab.esrf.fr/limagroup/lima2-client/-/tree/main/tests/integration/tango_db)
40
+ directory. Fetch it into the current directory with:
41
+
42
+ ```sh
43
+ wget -qO- https://gitlab.esrf.fr/limagroup/lima2-client/-/archive/main/lima2-client-main.tar.gz?path=tests/integration/tango_db | tar -xz --strip-components=1
44
+ ```
45
+
46
+ Start the tango server:
47
+
48
+ ```sh
49
+ NosqlTangoDB --port 10000 --db_access yaml:tests/integration/tango_db/ 2
50
+ ```
51
+
52
+ Start the Lima2 devices (one control, two receivers):
53
+
54
+ ```sh
55
+ export TANGO_HOST="localhost:10000"
56
+ mpiexec -n 1 lima2_tango simulator_ctl : \
57
+ -n 1 lima2_tango simulator_rcv1 : \
58
+ -n 1 lima2_tango simulator_rcv2
59
+ ```
60
+
61
+ Start the Lima2 Conductor, which listens on port 58712 by default:
62
+
63
+ ```sh
64
+ lima2-conductor start \
65
+ localhost:10000 \
66
+ round_robin \
67
+ id00/limacontrol/simulator \
68
+ id00/limareceiver/simulator1 \
69
+ id00/limareceiver/simulator2
70
+ ```
71
+
72
+ With all parts online, a client can now make requests to the conductor to
73
+ interact with the acquisition system.
74
+
75
+ The quickest way to start is inside the interactive session (requires the
76
+ `lima2-client[shell]` extra dependencies):
77
+
78
+ ```sh
79
+ lima2-shell
80
+ ```
81
+
82
+ ```py
83
+ In [1]: run_acquisition(nb_frames=120, expo_time=0.02) # Should take 2.4 seconds
84
+ In [2]: pipeline.progress()
85
+ Out[2]:
86
+ {'nb_frames_counters': 0,
87
+ 'nb_frames_input': 120,
88
+ 'nb_frames_source': 120,
89
+ [...]
90
+ ```
91
+
92
+ In the shell, the entire API of the conductor is exposed via the following
93
+ namespaces:
94
+
95
+ - `acquisition`: direct commands (prepare, start, stop, reset), system state and
96
+ progress
97
+ - `detector`: detector information, commands, capabilities and real-time status
98
+ - `pipeline`: data access (reduced data streams, frames) and detailed processing
99
+ progress
100
+
101
+ For more details, the [lima2-shell doc](https://limagroup.gitlab-pages.esrf.fr/lima2-client/shell/) and the
102
+ [API reference](https://limagroup.gitlab-pages.esrf.fr/lima2-client/reference/)
103
+ should be useful.
104
+
105
+ ## Description
106
+
107
+ This repo is organized as follows:
108
+
109
+ ```sh
110
+ lima2-client
111
+ ├── conda # Conda build configuration
112
+ ├── docs # Documentation sources
113
+ ├── scripts # Auxiliary scripts
114
+ ├── src/lima2
115
+ │   ├── client # Conductor client-side library
116
+ │   ├── conductor # Conductor server code
117
+ │   └── common # Shared definitions
118
+ └── tests
119
+ ├── integration
120
+ └── unit
121
+ ├── client
122
+ ├── conductor
123
+ └── common
124
+ ```
125
+
126
+ The project is composed of three main python packages.
127
+
128
+ ### `lima2.client`
129
+
130
+ The conductor's client-side library, meant to be imported from a control
131
+ application or a data consumer. In this package, the conductor webapp's API
132
+ endpoints are wrapped into python functions. The docs contain a complete [API
133
+ reference](https://limagroup.gitlab-pages.esrf.fr/lima2-client/reference/).
134
+
135
+ ### `lima2.conductor`
136
+
137
+ Implements the [Lima2
138
+ Conductor](https://limagroup.gitlab-pages.esrf.fr/lima2-client/dev/conductor_requirements/),
139
+ the orchestration process for distributed acquisitions.
140
+
141
+ Its central class is the
142
+ [`AcquisitionSystem`](https://limagroup.gitlab-pages.esrf.fr/lima2-client/dev/conductor_design/#acquisition-system),
143
+ which encapsulates the Lima2 acquisition, detector and processing systems.
144
+
145
+ This package also contains the `lima2.conductor.webservice` subpackage: the
146
+ conductor web server, which provides HTTP endpoints to interact with the
147
+ conductor remotely.
148
+
149
+ ### `lima2.common`
150
+
151
+ Contains type definitions and utilities meant to be imported from
152
+ `lima2.client`, `lima2.conductor`, and directly from client apps.
153
+
154
+ ## Development environment
155
+
156
+ The `dev` optional dependencies contains tools necessary for development and testing.
157
+
158
+ ### uv
159
+
160
+ Install all dependencies into a local venv:
161
+
162
+ ```sh
163
+ uv sync --extra dev
164
+ ```
165
+
166
+ Commands can be run with `uv run`:
167
+
168
+ ```sh
169
+ uv run lima2-conductor --help
170
+ uv run lima2-shell --help
171
+ ```
172
+
173
+ > **_NOTE:_** lima2-conductor has a `dev` command, which enables live code reloading
174
+ > on save.
175
+
176
+ ### conda
177
+
178
+ Create a new conda environment with python > 3.9:
179
+
180
+ ```sh
181
+ conda create -n lima2-client "python==3.10"
182
+ conda activate lima2-client
183
+ pip install -e .[dev]
184
+ ```
185
+
186
+ Execute commands directly:
187
+
188
+ ```sh
189
+ lima2-conductor --help
190
+ lima2-shell --help
191
+ ```
192
+
193
+ ## Tests
194
+
195
+ Unit and integration tests can be run locally. All dependencies for unit tests should be in the optional `dev` dependencies, and the `pyproject.toml` defines common `pytest` parameters.
196
+
197
+ After setting up your [dev environment](#development-environment), run the unit tests (prepend `uv run` if using uv):
198
+
199
+ ```sh
200
+ pytest tests/unit
201
+ # Compute coverage and output the coverage report to htmlcov/
202
+ pytest --cov lima2.client --cov lima2.conductor --cov-report html tests/unit/
203
+ ```
204
+
205
+ Integration tests require the Lima2 server, available via conda (see [install with conda](#conda)):
206
+
207
+ ```sh
208
+ conda activate lima2-client
209
+ conda install -c esrf-bcu lima2
210
+ pytest tests/integration
211
+ ```
212
+
213
+ ## Documentation
214
+
215
+ The repo's [pages](https://limagroup.gitlab-pages.esrf.fr/lima2-client/) contain
216
+ user guides, an API reference and design docs. Source files used to build the
217
+ documentation are located in the `docs/` directory.
218
+
219
+ The docs are written in markdown and rendered by
220
+ [`mkdocs`](https://www.mkdocs.org/).
221
+
222
+ ### Build the docs (uv)
223
+
224
+ ```sh
225
+ uv sync --extra docs
226
+ uv run mkdocs serve # Start the dev server at localhost:8000
227
+ uv run mkdocs build # Render HTML pages to ./site/
228
+ ```
229
+
230
+ ### Build the docs (conda/pip)
231
+
232
+ ```sh
233
+ pip install .[docs]
234
+ mkdocs serve # Start the dev server at localhost:8000
235
+ mkdocs build # Render HTML pages to ./site/
236
+ ```
@@ -0,0 +1,107 @@
1
+ [build-system]
2
+ requires = ["setuptools>=45", "setuptools_scm[toml]>=6.2"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [tool.setuptools_scm]
6
+ version_scheme = "guess-next-dev"
7
+
8
+ [project]
9
+ name = "lima2-client"
10
+ requires-python = ">= 3.10"
11
+ dynamic = ["version"]
12
+ authors = [{ name = "BCU (ESRF)" }]
13
+ description = "Python client library for Lima2 detector"
14
+ readme = "README.md"
15
+ license = { file = "LICENSE" }
16
+ classifiers = [
17
+ "Intended Audience :: Science/Research",
18
+ "License :: OSI Approved :: MIT License",
19
+ "Programming Language :: Python :: 3",
20
+ ]
21
+ dependencies = [
22
+ "h5py",
23
+ "jsonschema",
24
+ "jsonschema-default",
25
+ "numpy",
26
+ "pytango",
27
+ "pyyaml",
28
+ "requests",
29
+ "termcolor",
30
+ "typing-extensions",
31
+ "typer",
32
+ ]
33
+
34
+ [project.urls]
35
+ Repository = "https://gitlab.esrf.fr/limagroup/lima2-client"
36
+ Documentation = "https://limagroup.gitlab-pages.esrf.fr/lima2-client/"
37
+
38
+ [project.scripts]
39
+ lima2-conductor = "lima2.conductor.webservice.cli:cli [conductor]"
40
+ lima2-shell = "lima2.client.shell:app [dev]"
41
+
42
+ [project.optional-dependencies]
43
+ conductor = ["starlette", "uvicorn[standard]"]
44
+ shell = ["ipython"]
45
+ dev = [
46
+ "black==22.3",
47
+ "flake8",
48
+ "httpx",
49
+ "lima2-client[conductor]", # required to run unit tests
50
+ "lima2-client[shell]", # for convenience
51
+ "mypy",
52
+ "nosqltangodb",
53
+ "pytest",
54
+ "pytest-asyncio",
55
+ "pytest-cov",
56
+ "requests-mock",
57
+ "types-jsonschema",
58
+ "types-pyyaml",
59
+ "types-requests",
60
+ ]
61
+ docs = [
62
+ "mkdocs",
63
+ "markdown-include",
64
+ "mkdocs-material",
65
+ "mkdocstrings[python]",
66
+ "pygments",
67
+ ]
68
+
69
+ [tool.mypy]
70
+ packages = ["lima2.client", "lima2.conductor", "lima2.common"]
71
+ plugins = "numpy.typing.mypy_plugin"
72
+ mypy_path = "src"
73
+ strict = true
74
+ allow_redefinition = true
75
+ explicit_package_bases = true
76
+ warn_return_any = true
77
+ warn_unused_configs = true
78
+
79
+ [[tool.mypy.overrides]]
80
+ module = "tango.*"
81
+ ignore_missing_imports = true
82
+
83
+ [[tool.mypy.overrides]]
84
+ module = "jsonschema_default.*"
85
+ ignore_missing_imports = true
86
+
87
+ [[tool.mypy.overrides]]
88
+ module = "h5py.*"
89
+ ignore_missing_imports = true
90
+
91
+
92
+ [tool.pytest.ini_options]
93
+ addopts = "-v"
94
+ testpaths = "tests"
95
+ required_plugins = ["pytest-cov>=6.0.0", "pytest-asyncio>=0.25.3"]
96
+ asyncio_default_fixture_loop_scope = "function"
97
+
98
+ [tool.coverage.run]
99
+ # Omit entrypoints in coverage report
100
+ omit = [
101
+ "src/lima2/client/shell.py",
102
+ "src/lima2/conductor/webservice/cli.py",
103
+ "src/lima2/conductor/webservice/main.py",
104
+ ]
105
+
106
+ [tool.coverage.report]
107
+ exclude_also = ["raise NotImplementedError", "def __repr__"]
@@ -0,0 +1,9 @@
1
+ # This file is part of the Lima2 project
2
+ #
3
+ # Copyright (c) 2020-2024 Beamline Control Unit, ESRF
4
+ # Distributed under the MIT licence. See LICENSE for more info.
5
+
6
+ """Conductor client subpackage.
7
+
8
+ Contains a client-side library for the lima2 conductor HTTP API.
9
+ """
@@ -0,0 +1,20 @@
1
+ # This file is part of the Lima2 project
2
+ #
3
+ # Copyright (c) 2020-2024 Beamline Control Unit, ESRF
4
+ # Distributed under the MIT licence. See LICENSE for more info.
5
+
6
+ """Conductor client exceptions."""
7
+
8
+
9
+ class MalformedConductorResponse(RuntimeError):
10
+ """Raised when the conductor's response cannot be interpreted.
11
+
12
+ Raised when the conductor returns a 400 response but it has a
13
+ non-json payload, or the payload doesn't have an 'error' key.
14
+
15
+ Indicates a flaw in error handling code on the server side.
16
+ """
17
+
18
+
19
+ class ConductorConnectionError(RuntimeError):
20
+ """Raised by all client functions when the conductor can't be reached."""