lima2.client 4.0.dev1__tar.gz → 4.0.1__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 (82) hide show
  1. lima2_client-4.0.1/PKG-INFO +293 -0
  2. lima2_client-4.0.1/README.md +232 -0
  3. {lima2_client-4.0.dev1 → lima2_client-4.0.1}/pyproject.toml +18 -15
  4. {lima2_client-4.0.dev1/src/lima2/conductor/server → lima2_client-4.0.1/src/lima2/client}/__init__.py +4 -1
  5. lima2_client-4.0.1/src/lima2/client/exceptions.py +24 -0
  6. lima2_client-4.0.1/src/lima2/client/services.py +415 -0
  7. lima2_client-4.0.1/src/lima2/client/session.py +135 -0
  8. {lima2_client-4.0.dev1/src/lima2/conductor → lima2_client-4.0.1/src/lima2}/client/shell.py +33 -37
  9. lima2_client-4.0.1/src/lima2/common/__init__.py +13 -0
  10. {lima2_client-4.0.dev1/src/lima2/client → lima2_client-4.0.1/src/lima2/common}/devencoded/dense_frame.py +1 -2
  11. {lima2_client-4.0.dev1/src/lima2/client → lima2_client-4.0.1/src/lima2/common}/devencoded/smx_sparse_frame.py +2 -3
  12. {lima2_client-4.0.dev1/src/lima2/client → lima2_client-4.0.1/src/lima2/common}/devencoded/sparse_frame.py +1 -1
  13. {lima2_client-4.0.dev1/src/lima2/client → lima2_client-4.0.1/src/lima2/common}/devencoded/structured_array.py +1 -2
  14. lima2_client-4.0.1/src/lima2/common/exceptions.py +148 -0
  15. lima2_client-4.0.1/src/lima2/common/pipelines.py +131 -0
  16. {lima2_client-4.0.dev1/src/lima2/client → lima2_client-4.0.1/src/lima2/common}/progress_counter.py +2 -1
  17. {lima2_client-4.0.dev1/src/lima2/client → lima2_client-4.0.1/src/lima2/common}/state.py +35 -14
  18. lima2_client-4.0.1/src/lima2/common/types.py +188 -0
  19. {lima2_client-4.0.dev1/src/lima2/client → lima2_client-4.0.1/src/lima2/conductor}/acquisition_system.py +332 -151
  20. {lima2_client-4.0.dev1/src/lima2/client → lima2_client-4.0.1/src/lima2/conductor}/processing/__init__.py +13 -23
  21. lima2_client-4.0.1/src/lima2/conductor/processing/failing.py +43 -0
  22. lima2_client-4.0.1/src/lima2/conductor/processing/legacy.py +57 -0
  23. lima2_client-4.0.1/src/lima2/conductor/processing/master_file.py +462 -0
  24. lima2_client-4.0.1/src/lima2/conductor/processing/pipeline.py +651 -0
  25. lima2_client-4.0.1/src/lima2/conductor/processing/reduced_data.py +587 -0
  26. lima2_client-4.0.1/src/lima2/conductor/processing/smx.py +71 -0
  27. lima2_client-4.0.1/src/lima2/conductor/processing/xpcs.py +58 -0
  28. lima2_client-4.0.1/src/lima2/conductor/py.typed +0 -0
  29. {lima2_client-4.0.dev1/src/lima2/client → lima2_client-4.0.1/src/lima2/conductor}/tango/control.py +40 -25
  30. {lima2_client-4.0.dev1/src/lima2/client → lima2_client-4.0.1/src/lima2/conductor}/tango/processing.py +47 -44
  31. {lima2_client-4.0.dev1/src/lima2/client → lima2_client-4.0.1/src/lima2/conductor}/tango/receiver.py +46 -29
  32. lima2_client-4.0.1/src/lima2/conductor/tango/utils.py +110 -0
  33. lima2_client-4.0.1/src/lima2/conductor/topology.py +278 -0
  34. lima2_client-4.0.1/src/lima2/conductor/utils.py +261 -0
  35. lima2_client-4.0.1/src/lima2/conductor/webservice/__init__.py +10 -0
  36. {lima2_client-4.0.dev1/src/lima2/conductor/server → lima2_client-4.0.1/src/lima2/conductor/webservice}/acquisition.py +23 -20
  37. {lima2_client-4.0.dev1/src/lima2/conductor/server → lima2_client-4.0.1/src/lima2/conductor/webservice}/cli.py +8 -8
  38. {lima2_client-4.0.dev1/src/lima2/conductor/server → lima2_client-4.0.1/src/lima2/conductor/webservice}/detector.py +1 -1
  39. {lima2_client-4.0.dev1/src/lima2/conductor/server → lima2_client-4.0.1/src/lima2/conductor/webservice}/main.py +19 -11
  40. {lima2_client-4.0.dev1/src/lima2/conductor/server → lima2_client-4.0.1/src/lima2/conductor/webservice}/pipeline.py +160 -52
  41. {lima2_client-4.0.dev1/src/lima2/conductor/server → lima2_client-4.0.1/src/lima2/conductor/webservice}/utils.py +4 -1
  42. {lima2_client-4.0.dev1/src/lima2/conductor/server → lima2_client-4.0.1/src/lima2/conductor/webservice}/webapp.py +41 -22
  43. lima2_client-4.0.1/src/lima2_client.egg-info/PKG-INFO +293 -0
  44. lima2_client-4.0.1/src/lima2_client.egg-info/SOURCES.txt +57 -0
  45. lima2_client-4.0.1/src/lima2_client.egg-info/entry_points.txt +3 -0
  46. {lima2_client-4.0.dev1 → lima2_client-4.0.1}/src/lima2_client.egg-info/requires.txt +16 -8
  47. lima2_client-4.0.dev1/PKG-INFO +0 -98
  48. lima2_client-4.0.dev1/README.md +0 -43
  49. lima2_client-4.0.dev1/src/lima2/client/__init__.py +0 -14
  50. lima2_client-4.0.dev1/src/lima2/client/processing/failing.py +0 -38
  51. lima2_client-4.0.dev1/src/lima2/client/processing/frame.py +0 -91
  52. lima2_client-4.0.dev1/src/lima2/client/processing/legacy.py +0 -41
  53. lima2_client-4.0.dev1/src/lima2/client/processing/master_file.py +0 -541
  54. lima2_client-4.0.dev1/src/lima2/client/processing/pipeline.py +0 -392
  55. lima2_client-4.0.dev1/src/lima2/client/processing/reduced_data.py +0 -592
  56. lima2_client-4.0.dev1/src/lima2/client/processing/smx.py +0 -70
  57. lima2_client-4.0.dev1/src/lima2/client/processing/xpcs.py +0 -64
  58. lima2_client-4.0.dev1/src/lima2/client/tango/utils.py +0 -86
  59. lima2_client-4.0.dev1/src/lima2/client/topology.py +0 -221
  60. lima2_client-4.0.dev1/src/lima2/client/utils.py +0 -75
  61. lima2_client-4.0.dev1/src/lima2/conductor/client/__init__.py +0 -30
  62. lima2_client-4.0.dev1/src/lima2/conductor/client/acquisition.py +0 -91
  63. lima2_client-4.0.dev1/src/lima2/conductor/client/detector.py +0 -25
  64. lima2_client-4.0.dev1/src/lima2/conductor/client/exceptions.py +0 -32
  65. lima2_client-4.0.dev1/src/lima2/conductor/client/pipeline.py +0 -171
  66. lima2_client-4.0.dev1/src/lima2/conductor/client/session.py +0 -91
  67. lima2_client-4.0.dev1/src/lima2_client.egg-info/PKG-INFO +0 -98
  68. lima2_client-4.0.dev1/src/lima2_client.egg-info/SOURCES.txt +0 -56
  69. lima2_client-4.0.dev1/src/lima2_client.egg-info/entry_points.txt +0 -3
  70. {lima2_client-4.0.dev1 → lima2_client-4.0.1}/LICENSE +0 -0
  71. {lima2_client-4.0.dev1 → lima2_client-4.0.1}/setup.cfg +0 -0
  72. {lima2_client-4.0.dev1 → lima2_client-4.0.1}/src/lima2/client/py.typed +0 -0
  73. {lima2_client-4.0.dev1/src/lima2/client → lima2_client-4.0.1/src/lima2/common}/devencoded/__init__.py +0 -0
  74. {lima2_client-4.0.dev1/src/lima2/client → lima2_client-4.0.1/src/lima2/common}/devencoded/exception.py +0 -0
  75. {lima2_client-4.0.dev1/src/lima2/conductor → lima2_client-4.0.1/src/lima2/common}/py.typed +0 -0
  76. {lima2_client-4.0.dev1 → lima2_client-4.0.1}/src/lima2/conductor/__init__.py +0 -0
  77. {lima2_client-4.0.dev1/src/lima2/client → lima2_client-4.0.1/src/lima2/conductor}/tango/__init__.py +0 -0
  78. {lima2_client-4.0.dev1/src/lima2/conductor/server → lima2_client-4.0.1/src/lima2/conductor/webservice}/benchmark.py +0 -0
  79. {lima2_client-4.0.dev1/src/lima2/conductor/server → lima2_client-4.0.1/src/lima2/conductor/webservice}/benchmark_generators/__init__.py +0 -0
  80. {lima2_client-4.0.dev1/src/lima2/conductor/server → lima2_client-4.0.1/src/lima2/conductor/webservice}/benchmark_generators/rois.py +0 -0
  81. {lima2_client-4.0.dev1 → lima2_client-4.0.1}/src/lima2_client.egg-info/dependency_links.txt +0 -0
  82. {lima2_client-4.0.dev1 → lima2_client-4.0.1}/src/lima2_client.egg-info/top_level.txt +0 -0
@@ -0,0 +1,293 @@
1
+ Metadata-Version: 2.4
2
+ Name: lima2-client
3
+ Version: 4.0.1
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: jsonschema-rs; extra == "conductor"
34
+ Requires-Dist: orjson; extra == "conductor"
35
+ Requires-Dist: starlette; extra == "conductor"
36
+ Requires-Dist: uvicorn[standard]; extra == "conductor"
37
+ Provides-Extra: shell
38
+ Requires-Dist: ipython; extra == "shell"
39
+ Provides-Extra: dev
40
+ Requires-Dist: black==22.3; extra == "dev"
41
+ Requires-Dist: flake8; extra == "dev"
42
+ Requires-Dist: httpx; extra == "dev"
43
+ Requires-Dist: lima2-client[conductor]; extra == "dev"
44
+ Requires-Dist: lima2-client[shell]; extra == "dev"
45
+ Requires-Dist: mypy; extra == "dev"
46
+ Requires-Dist: nosqltangodb; extra == "dev"
47
+ Requires-Dist: pytest; extra == "dev"
48
+ Requires-Dist: pytest-asyncio; extra == "dev"
49
+ Requires-Dist: pytest-cov; extra == "dev"
50
+ Requires-Dist: requests-mock; extra == "dev"
51
+ Requires-Dist: types-jsonschema; extra == "dev"
52
+ Requires-Dist: types-pyyaml; extra == "dev"
53
+ Requires-Dist: types-requests; extra == "dev"
54
+ Provides-Extra: docs
55
+ Requires-Dist: mkdocs; extra == "docs"
56
+ Requires-Dist: markdown-include; extra == "docs"
57
+ Requires-Dist: mkdocs-material; extra == "docs"
58
+ Requires-Dist: mkdocstrings[python]; extra == "docs"
59
+ Requires-Dist: pygments; extra == "docs"
60
+ Dynamic: license-file
61
+
62
+ # Lima2 Client
63
+
64
+ ![pypi badge](https://badge.fury.io/py/lima2.client.svg?icon=si%3Apython)
65
+ ![pipeline badge](https://gitlab.esrf.fr/limagroup/lima2-client/badges/main/pipeline.svg)
66
+ ![coverage badge](https://gitlab.esrf.fr/limagroup/lima2-client/badges/main/coverage.svg?min_good=90&min_acceptable=80&min_medium=75)
67
+
68
+ This repo contains source code for the Lima2 Conductor, an orchestration module
69
+ for the Lima2 acquisition system, and its python client library, the
70
+ `lima2.client` package.
71
+
72
+ Install the lima2-client package:
73
+
74
+ ```sh
75
+ pip install lima2-client
76
+ ```
77
+
78
+ ## Quickstart
79
+
80
+ A minimal setup for running Lima2 requires:
81
+
82
+ - The [`lima2`](https://anaconda.org/esrf-bcu/lima2) conda package
83
+ - The [`lima2-client`](https://pypi.org/project/lima2-client/) python package
84
+ - A tango server, e.g. [`nosqltangodb`](https://pypi.org/project/nosqltangodb/)
85
+
86
+ > **_NOTE:_** In a bliss environment, the tango server comes with `bliss-demo-servers`,
87
+ > so `nosqltangodb` is not required.
88
+
89
+ Install everything into a new conda environment:
90
+
91
+ ```sh
92
+ conda create -n lima2 "python==3.10"
93
+ conda activate lima2
94
+ conda install -c esrf-bcu lima2
95
+ pip install lima2-client[conductor,shell] nosqltangodb
96
+ ```
97
+
98
+ The first step is to start the tango server. For `nosqltangodb`, example config
99
+ files can be found in the repo's
100
+ [`tests/integration/tango_db/`](https://gitlab.esrf.fr/limagroup/lima2-client/-/tree/main/tests/integration/tango_db)
101
+ directory. Fetch it into the current directory with:
102
+
103
+ ```sh
104
+ 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
105
+ ```
106
+
107
+ Start the tango server:
108
+
109
+ ```sh
110
+ NosqlTangoDB --port 10000 --db_access yaml:tests/integration/tango_db/ 2
111
+ ```
112
+
113
+ Start the Lima2 devices (one control, two receivers):
114
+
115
+ ```sh
116
+ export TANGO_HOST="localhost:10000"
117
+ mpiexec -n 1 lima2_tango simulator_ctl : \
118
+ -n 1 lima2_tango simulator_rcv1 : \
119
+ -n 1 lima2_tango simulator_rcv2
120
+ ```
121
+
122
+ Start the Lima2 Conductor, which listens on port 58712 by default:
123
+
124
+ ```sh
125
+ lima2-conductor start \
126
+ localhost:10000 \
127
+ round_robin \
128
+ id00/limacontrol/simulator \
129
+ id00/limareceiver/simulator1 \
130
+ id00/limareceiver/simulator2
131
+ ```
132
+
133
+ With all parts online, a client can now make requests to the conductor to
134
+ interact with the acquisition system.
135
+
136
+ The quickest way to start is inside the interactive session (requires the
137
+ `lima2-client[shell]` extra dependencies):
138
+
139
+ ```sh
140
+ lima2-shell
141
+ ```
142
+
143
+ ```py
144
+ In [1]: run_acquisition(nb_frames=120, expo_time=0.02) # Should take 2.4 seconds
145
+ In [2]: pipeline.progress()
146
+ Out[2]: 120
147
+ ```
148
+
149
+ In the shell, the entire API of the conductor is exposed via the following
150
+ namespaces:
151
+
152
+ - `acquisition`: direct commands (prepare, start, stop, reset), system state and
153
+ progress
154
+ - `detector`: detector information, commands, capabilities and real-time status
155
+ - `pipeline`: data access (reduced data streams, frames) and detailed processing
156
+ progress
157
+
158
+ For more details, the [lima2-shell doc](https://limagroup.gitlab-pages.esrf.fr/lima2-client/shell/) and the
159
+ [API reference](https://limagroup.gitlab-pages.esrf.fr/lima2-client/reference/)
160
+ should be useful.
161
+
162
+ ## Description
163
+
164
+ This repo is organized as follows:
165
+
166
+ ```sh
167
+ lima2-client
168
+ ├── conda # Conda build configuration
169
+ ├── docs # Documentation sources
170
+ ├── scripts # Auxiliary scripts
171
+ ├── src/lima2
172
+ │   ├── client # Conductor client-side library
173
+ │   ├── conductor # Conductor server code
174
+ │   └── common # Shared definitions
175
+ └── tests
176
+ ├── integration
177
+ └── unit
178
+ ├── client
179
+ ├── conductor
180
+ └── common
181
+ ```
182
+
183
+ The project is composed of three main python packages.
184
+
185
+ ### `lima2.client`
186
+
187
+ The conductor's client-side library, meant to be imported from a control
188
+ application or a data consumer. In this package, the conductor webapp's API
189
+ endpoints are wrapped into python functions. The docs contain a complete [API
190
+ reference](https://limagroup.gitlab-pages.esrf.fr/lima2-client/reference/).
191
+
192
+ ### `lima2.conductor`
193
+
194
+ Implements the [Lima2
195
+ Conductor](https://limagroup.gitlab-pages.esrf.fr/lima2-client/dev/conductor_requirements/),
196
+ the orchestration process for distributed acquisitions.
197
+
198
+ Its central class is the
199
+ [`AcquisitionSystem`](https://limagroup.gitlab-pages.esrf.fr/lima2-client/dev/conductor_design/#acquisition-system),
200
+ which encapsulates the Lima2 acquisition, detector and processing systems.
201
+
202
+ This package also contains the `lima2.conductor.webservice` subpackage: the
203
+ conductor web server, which provides HTTP endpoints to interact with the
204
+ conductor remotely.
205
+
206
+ ### `lima2.common`
207
+
208
+ Contains type definitions and utilities meant to be imported from
209
+ `lima2.client`, `lima2.conductor`, and directly from client apps.
210
+
211
+ ## Development environment
212
+
213
+ The `dev` optional dependencies contains tools necessary for development and testing.
214
+
215
+ ### uv
216
+
217
+ Install all dependencies into a local venv:
218
+
219
+ ```sh
220
+ uv sync --extra dev
221
+ ```
222
+
223
+ Commands can be run with `uv run`:
224
+
225
+ ```sh
226
+ uv run lima2-conductor --help
227
+ uv run lima2-shell --help
228
+ ```
229
+
230
+ > **_NOTE:_** lima2-conductor has a `dev` command, which enables live code reloading
231
+ > on save.
232
+
233
+ ### conda
234
+
235
+ Create a new conda environment with python > 3.9:
236
+
237
+ ```sh
238
+ conda create -n lima2-client "python==3.10"
239
+ conda activate lima2-client
240
+ pip install -e .[dev]
241
+ ```
242
+
243
+ Execute commands directly:
244
+
245
+ ```sh
246
+ lima2-conductor --help
247
+ lima2-shell --help
248
+ ```
249
+
250
+ ## Tests
251
+
252
+ 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.
253
+
254
+ After setting up your [dev environment](#development-environment), run the unit tests (prepend `uv run` if using uv):
255
+
256
+ ```sh
257
+ pytest tests/unit
258
+ # Compute coverage and output the coverage report to htmlcov/
259
+ pytest --cov lima2.client --cov lima2.conductor --cov-report html tests/unit/
260
+ ```
261
+
262
+ Integration tests require the Lima2 server, available via conda (see [install with conda](#conda)):
263
+
264
+ ```sh
265
+ conda activate lima2-client
266
+ conda install -c esrf-bcu lima2
267
+ pytest tests/integration
268
+ ```
269
+
270
+ ## Documentation
271
+
272
+ The repo's [pages](https://limagroup.gitlab-pages.esrf.fr/lima2-client/) contain
273
+ user guides, an API reference and design docs. Source files used to build the
274
+ documentation are located in the `docs/` directory.
275
+
276
+ The docs are written in markdown and rendered by
277
+ [`mkdocs`](https://www.mkdocs.org/).
278
+
279
+ ### Build the docs (uv)
280
+
281
+ ```sh
282
+ uv sync --extra docs
283
+ uv run mkdocs serve # Start the dev server at localhost:8000
284
+ uv run mkdocs build # Render HTML pages to ./site/
285
+ ```
286
+
287
+ ### Build the docs (conda/pip)
288
+
289
+ ```sh
290
+ pip install .[docs]
291
+ mkdocs serve # Start the dev server at localhost:8000
292
+ mkdocs build # Render HTML pages to ./site/
293
+ ```
@@ -0,0 +1,232 @@
1
+ # Lima2 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]: 120
86
+ ```
87
+
88
+ In the shell, the entire API of the conductor is exposed via the following
89
+ namespaces:
90
+
91
+ - `acquisition`: direct commands (prepare, start, stop, reset), system state and
92
+ progress
93
+ - `detector`: detector information, commands, capabilities and real-time status
94
+ - `pipeline`: data access (reduced data streams, frames) and detailed processing
95
+ progress
96
+
97
+ For more details, the [lima2-shell doc](https://limagroup.gitlab-pages.esrf.fr/lima2-client/shell/) and the
98
+ [API reference](https://limagroup.gitlab-pages.esrf.fr/lima2-client/reference/)
99
+ should be useful.
100
+
101
+ ## Description
102
+
103
+ This repo is organized as follows:
104
+
105
+ ```sh
106
+ lima2-client
107
+ ├── conda # Conda build configuration
108
+ ├── docs # Documentation sources
109
+ ├── scripts # Auxiliary scripts
110
+ ├── src/lima2
111
+ │   ├── client # Conductor client-side library
112
+ │   ├── conductor # Conductor server code
113
+ │   └── common # Shared definitions
114
+ └── tests
115
+ ├── integration
116
+ └── unit
117
+ ├── client
118
+ ├── conductor
119
+ └── common
120
+ ```
121
+
122
+ The project is composed of three main python packages.
123
+
124
+ ### `lima2.client`
125
+
126
+ The conductor's client-side library, meant to be imported from a control
127
+ application or a data consumer. In this package, the conductor webapp's API
128
+ endpoints are wrapped into python functions. The docs contain a complete [API
129
+ reference](https://limagroup.gitlab-pages.esrf.fr/lima2-client/reference/).
130
+
131
+ ### `lima2.conductor`
132
+
133
+ Implements the [Lima2
134
+ Conductor](https://limagroup.gitlab-pages.esrf.fr/lima2-client/dev/conductor_requirements/),
135
+ the orchestration process for distributed acquisitions.
136
+
137
+ Its central class is the
138
+ [`AcquisitionSystem`](https://limagroup.gitlab-pages.esrf.fr/lima2-client/dev/conductor_design/#acquisition-system),
139
+ which encapsulates the Lima2 acquisition, detector and processing systems.
140
+
141
+ This package also contains the `lima2.conductor.webservice` subpackage: the
142
+ conductor web server, which provides HTTP endpoints to interact with the
143
+ conductor remotely.
144
+
145
+ ### `lima2.common`
146
+
147
+ Contains type definitions and utilities meant to be imported from
148
+ `lima2.client`, `lima2.conductor`, and directly from client apps.
149
+
150
+ ## Development environment
151
+
152
+ The `dev` optional dependencies contains tools necessary for development and testing.
153
+
154
+ ### uv
155
+
156
+ Install all dependencies into a local venv:
157
+
158
+ ```sh
159
+ uv sync --extra dev
160
+ ```
161
+
162
+ Commands can be run with `uv run`:
163
+
164
+ ```sh
165
+ uv run lima2-conductor --help
166
+ uv run lima2-shell --help
167
+ ```
168
+
169
+ > **_NOTE:_** lima2-conductor has a `dev` command, which enables live code reloading
170
+ > on save.
171
+
172
+ ### conda
173
+
174
+ Create a new conda environment with python > 3.9:
175
+
176
+ ```sh
177
+ conda create -n lima2-client "python==3.10"
178
+ conda activate lima2-client
179
+ pip install -e .[dev]
180
+ ```
181
+
182
+ Execute commands directly:
183
+
184
+ ```sh
185
+ lima2-conductor --help
186
+ lima2-shell --help
187
+ ```
188
+
189
+ ## Tests
190
+
191
+ 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.
192
+
193
+ After setting up your [dev environment](#development-environment), run the unit tests (prepend `uv run` if using uv):
194
+
195
+ ```sh
196
+ pytest tests/unit
197
+ # Compute coverage and output the coverage report to htmlcov/
198
+ pytest --cov lima2.client --cov lima2.conductor --cov-report html tests/unit/
199
+ ```
200
+
201
+ Integration tests require the Lima2 server, available via conda (see [install with conda](#conda)):
202
+
203
+ ```sh
204
+ conda activate lima2-client
205
+ conda install -c esrf-bcu lima2
206
+ pytest tests/integration
207
+ ```
208
+
209
+ ## Documentation
210
+
211
+ The repo's [pages](https://limagroup.gitlab-pages.esrf.fr/lima2-client/) contain
212
+ user guides, an API reference and design docs. Source files used to build the
213
+ documentation are located in the `docs/` directory.
214
+
215
+ The docs are written in markdown and rendered by
216
+ [`mkdocs`](https://www.mkdocs.org/).
217
+
218
+ ### Build the docs (uv)
219
+
220
+ ```sh
221
+ uv sync --extra docs
222
+ uv run mkdocs serve # Start the dev server at localhost:8000
223
+ uv run mkdocs build # Render HTML pages to ./site/
224
+ ```
225
+
226
+ ### Build the docs (conda/pip)
227
+
228
+ ```sh
229
+ pip install .[docs]
230
+ mkdocs serve # Start the dev server at localhost:8000
231
+ mkdocs build # Render HTML pages to ./site/
232
+ ```
@@ -26,10 +26,9 @@ dependencies = [
26
26
  "pytango",
27
27
  "pyyaml",
28
28
  "requests",
29
- "starlette",
29
+ "termcolor",
30
30
  "typing-extensions",
31
31
  "typer",
32
- "uvicorn[standard]",
33
32
  ]
34
33
 
35
34
  [project.urls]
@@ -37,37 +36,41 @@ Repository = "https://gitlab.esrf.fr/limagroup/lima2-client"
37
36
  Documentation = "https://limagroup.gitlab-pages.esrf.fr/lima2-client/"
38
37
 
39
38
  [project.scripts]
40
- lima2-conductor = "lima2.conductor.server.cli:cli"
41
- lima2-shell = "lima2.conductor.client.shell:app [dev]"
39
+ lima2-conductor = "lima2.conductor.webservice.cli:cli [conductor]"
40
+ lima2-shell = "lima2.client.shell:app [dev]"
42
41
 
43
42
  [project.optional-dependencies]
43
+ conductor = ["jsonschema-rs", "orjson", "starlette", "uvicorn[standard]"]
44
+ shell = ["ipython"]
44
45
  dev = [
45
46
  "black==22.3",
46
47
  "flake8",
47
48
  "httpx",
48
- "ipython",
49
+ "lima2-client[conductor]", # required to run unit tests
50
+ "lima2-client[shell]", # for convenience
49
51
  "mypy",
50
52
  "nosqltangodb",
51
53
  "pytest",
52
54
  "pytest-asyncio",
53
55
  "pytest-cov",
54
56
  "requests-mock",
55
- "termcolor",
56
57
  "types-jsonschema",
57
58
  "types-pyyaml",
58
59
  "types-requests",
59
60
  ]
60
61
  docs = [
61
- "recommonmark",
62
- "sphinx",
63
- "sphinxcontrib-mermaid",
64
- "sphinxcontrib-napoleon",
65
- "sphinx-immaterial",
62
+ "mkdocs",
63
+ "markdown-include",
64
+ "mkdocs-material",
65
+ "mkdocstrings[python]",
66
+ "pygments",
66
67
  ]
67
68
 
68
69
  [tool.mypy]
69
- packages = ["lima2.client", "lima2.conductor"]
70
+ packages = ["lima2.client", "lima2.conductor", "lima2.common"]
71
+ plugins = "numpy.typing.mypy_plugin"
70
72
  mypy_path = "src"
73
+ strict = true
71
74
  allow_redefinition = true
72
75
  explicit_package_bases = true
73
76
  warn_return_any = true
@@ -95,9 +98,9 @@ asyncio_default_fixture_loop_scope = "function"
95
98
  [tool.coverage.run]
96
99
  # Omit entrypoints in coverage report
97
100
  omit = [
98
- "src/lima2/conductor/client/shell.py",
99
- "src/lima2/conductor/server/cli.py",
100
- "src/lima2/conductor/server/main.py",
101
+ "src/lima2/client/shell.py",
102
+ "src/lima2/conductor/webservice/cli.py",
103
+ "src/lima2/conductor/webservice/main.py",
101
104
  ]
102
105
 
103
106
  [tool.coverage.report]
@@ -3,4 +3,7 @@
3
3
  # Copyright (c) 2020-2024 Beamline Control Unit, ESRF
4
4
  # Distributed under the MIT licence. See LICENSE for more info.
5
5
 
6
- """Conductor server subpackage"""
6
+ """Conductor client subpackage.
7
+
8
+ Contains a client-side library for the lima2 conductor HTTP API.
9
+ """
@@ -0,0 +1,24 @@
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."""
21
+
22
+
23
+ class ConductorEndpointNotFound(RuntimeError):
24
+ """Raised when a request is made to the conductor on an invalid endpoint."""