bec-ipython-client 3.64.5__py3-none-any.whl → 3.84.0__py3-none-any.whl
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.
Potentially problematic release.
This version of bec-ipython-client might be problematic. Click here for more details.
- .gitignore +3 -0
- PKG-INFO +2 -2
- bec_ipython_client/callbacks/device_progress.py +11 -6
- bec_ipython_client/callbacks/ipython_live_updates.py +8 -3
- bec_ipython_client/callbacks/live_table.py +9 -4
- bec_ipython_client/callbacks/move_device.py +121 -59
- bec_ipython_client/callbacks/utils.py +4 -4
- bec_ipython_client/main.py +76 -7
- {bec_ipython_client-3.64.5.dist-info → bec_ipython_client-3.84.0.dist-info}/METADATA +2 -2
- {bec_ipython_client-3.64.5.dist-info → bec_ipython_client-3.84.0.dist-info}/RECORD +22 -21
- {bec_ipython_client-3.64.5.dist-info → bec_ipython_client-3.84.0.dist-info}/WHEEL +1 -1
- demo.py +2 -1
- pyproject.toml +2 -2
- tests/client_tests/conftest.py +19 -0
- tests/client_tests/test_bec_client.py +32 -1
- tests/client_tests/test_live_table.py +33 -12
- tests/client_tests/test_move_callback.py +112 -70
- tests/end-2-end/_ensure_requirements_container.py +3 -3
- tests/end-2-end/test_procedures_e2e.py +26 -17
- tests/end-2-end/test_scans_e2e.py +4 -4
- tests/end-2-end/test_scans_lib_e2e.py +23 -19
- {bec_ipython_client-3.64.5.dist-info → bec_ipython_client-3.84.0.dist-info}/entry_points.txt +0 -0
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
.gitignore,sha256=
|
|
2
|
-
PKG-INFO,sha256=
|
|
3
|
-
demo.py,sha256=
|
|
4
|
-
pyproject.toml,sha256=
|
|
1
|
+
.gitignore,sha256=XxC6jyyftTo2CLtm4K8axuNPYwA9Wgaz2R93WhX8bTQ,3364
|
|
2
|
+
PKG-INFO,sha256=ijJpv2TMYSqXFg607-vZwabQv7Ib-B-cWeiu71D9-Xc,1052
|
|
3
|
+
demo.py,sha256=AquJB-0Tu2bIEFpcJ0Q3RUBt1xldqS6GgU5CjOAg_ww,7083
|
|
4
|
+
pyproject.toml,sha256=HuXmixsLCNg82K4Z_GDHOdRWAVHza_oeQ7Pe5fKipHU,1229
|
|
5
5
|
bec_ipython_client/__init__.py,sha256=ihd_V8I7Qo0MWKMo7bcvPf-ZyUQqkcNf8IAWLJKiFJE,79
|
|
6
6
|
bec_ipython_client/beamline_mixin.py,sha256=scMWIFbHJajyECzbwEVKyQUGjpqA9C_KiU2M6FuRH_Q,1067
|
|
7
7
|
bec_ipython_client/bec_magics.py,sha256=Rz2aXkUCeAV_VxdXqLUNHh8T44kSH9ha83OiEtdptzI,2792
|
|
8
8
|
bec_ipython_client/bec_startup.py,sha256=GGlHyxnSCQfYF5n-pYq2ic0pSyW5zvnT2PAlI5kY77w,1930
|
|
9
|
-
bec_ipython_client/main.py,sha256=
|
|
9
|
+
bec_ipython_client/main.py,sha256=XxSaiRuvDPKRzM3yuPz3FW5I0wnfyL2SgEfEG3VrDJg,13543
|
|
10
10
|
bec_ipython_client/prettytable.py,sha256=TnhGPGuU0XEvnIYJ1UfTEwadcowFW4rqJW8z_Sm0EDw,2534
|
|
11
11
|
bec_ipython_client/progressbar.py,sha256=aDKYjzXmGSwa82ewm59V8WSuqVQz9GiZPx5G65fEwpk,11090
|
|
12
12
|
bec_ipython_client/signals.py,sha256=mbThPo6h3mQ6RFRm9viETDMC_unFa7QxiymCdM_ZK7U,4194
|
|
13
13
|
bec_ipython_client/callbacks/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
14
|
-
bec_ipython_client/callbacks/device_progress.py,sha256=
|
|
15
|
-
bec_ipython_client/callbacks/ipython_live_updates.py,sha256=
|
|
16
|
-
bec_ipython_client/callbacks/live_table.py,sha256=
|
|
17
|
-
bec_ipython_client/callbacks/move_device.py,sha256=
|
|
18
|
-
bec_ipython_client/callbacks/utils.py,sha256=
|
|
14
|
+
bec_ipython_client/callbacks/device_progress.py,sha256=NzWIO1oowxpN14hPXBne6RfZxOW82EhwDM3jHLnn3xI,2603
|
|
15
|
+
bec_ipython_client/callbacks/ipython_live_updates.py,sha256=Cx62yJSzIcRvAA_lC86PSs8825hJtk22yBPhuJjgRPc,10520
|
|
16
|
+
bec_ipython_client/callbacks/live_table.py,sha256=3qmwCEjqe-xFqo3Ez2dhKchawlr0cOmNgzpg857-gp0,13503
|
|
17
|
+
bec_ipython_client/callbacks/move_device.py,sha256=TkbtKFBr1nuJ8THTSm70Y8D7_va2YQ57oBGGt0BavW4,8153
|
|
18
|
+
bec_ipython_client/callbacks/utils.py,sha256=jS92ndZNU2t5n9FsLrSbulmUIeepHhwdQdfO60YjiJk,5702
|
|
19
19
|
bec_ipython_client/high_level_interfaces/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
20
20
|
bec_ipython_client/high_level_interfaces/bec_hli.py,sha256=G1eF-lbLEDuN2mr_AYSxhhGb4LT6P72g0a4sU9M9zgk,1221
|
|
21
21
|
bec_ipython_client/high_level_interfaces/spec_hli.py,sha256=z7WtjiC4LtMfKJn12SbguHPCLqbAsZNfUDyiUW0LOiU,5818
|
|
@@ -26,18 +26,19 @@ bec_ipython_client/plugins/XTreme/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeR
|
|
|
26
26
|
bec_ipython_client/plugins/XTreme/x-treme.py,sha256=ZKI_EEPYyWW-sdrK9DIllb81aeObc1O3fU1eWqipjTQ,3631
|
|
27
27
|
bec_ipython_client/plugins/flomni/flomni_config.yaml,sha256=bCN1VKCzF6tw24HYeUE2b81kXMXzhEd69Ea8_q8Ywfk,6184
|
|
28
28
|
tests/conftest.py,sha256=4yzGYqs8EVOxxY9Bu-yGbzmOpzG9dxs3cwSCzjmRziQ,233
|
|
29
|
+
tests/client_tests/conftest.py,sha256=dUvYqvl6wogxN-kRCUuo_Uzna3P2uSYD7qGHyMGBlPY,413
|
|
29
30
|
tests/client_tests/test_beamline_mixins.py,sha256=8Ws0bmzl2gSW0VuOVu80_JbYNb5Y-htchmrrptwjwDo,4611
|
|
30
|
-
tests/client_tests/test_bec_client.py,sha256=
|
|
31
|
+
tests/client_tests/test_bec_client.py,sha256=gks7IYoDDXpbkC_EGWQfKtH08Yig71PRZtleXFhkU8A,8903
|
|
31
32
|
tests/client_tests/test_device_progress.py,sha256=GEw2g8MQZnv5mxABEZlxBmaMpxVS33wogaYohFolDEs,2353
|
|
32
33
|
tests/client_tests/test_ipython_live_updates.py,sha256=HpA16Mx0WdseqlfP0FojlAd6VfvjnwAUReDkItZVYWs,6081
|
|
33
|
-
tests/client_tests/test_live_table.py,sha256=
|
|
34
|
-
tests/client_tests/test_move_callback.py,sha256=
|
|
34
|
+
tests/client_tests/test_live_table.py,sha256=0EKgWOgDqpjN8fJEeAzoKNCwFneDEsUY2NfWQkxB6xc,18155
|
|
35
|
+
tests/client_tests/test_move_callback.py,sha256=bUCcWoz_tc-yRAtwmEUMrKE_qKwatop_wReSugGGEIQ,8670
|
|
35
36
|
tests/client_tests/test_pretty_table.py,sha256=uQ-KPb3RXoCFE_t1IrpkT6kZAoqW7pFXxbFc445sX0Y,469
|
|
36
|
-
tests/end-2-end/_ensure_requirements_container.py,sha256=
|
|
37
|
-
tests/end-2-end/test_procedures_e2e.py,sha256=
|
|
38
|
-
tests/end-2-end/test_scans_e2e.py,sha256=
|
|
39
|
-
tests/end-2-end/test_scans_lib_e2e.py,sha256=
|
|
40
|
-
bec_ipython_client-3.
|
|
41
|
-
bec_ipython_client-3.
|
|
42
|
-
bec_ipython_client-3.
|
|
43
|
-
bec_ipython_client-3.
|
|
37
|
+
tests/end-2-end/_ensure_requirements_container.py,sha256=RT2a5cUZnXtMjJRlPImGzgyX-KJPLiav5WSp_l3wzv8,725
|
|
38
|
+
tests/end-2-end/test_procedures_e2e.py,sha256=xjczbB33Cf5pDLe1KWcalRRBrSxOQ3cbV3s3w3GsC_A,4922
|
|
39
|
+
tests/end-2-end/test_scans_e2e.py,sha256=GMStotxqu24794TxIFc55PCtOjuG2qbkmibcUj7r-DI,31069
|
|
40
|
+
tests/end-2-end/test_scans_lib_e2e.py,sha256=dqs0ojkyQWStIQbqABq9mQrjqQyE43gr37VPhxvQ8b8,19427
|
|
41
|
+
bec_ipython_client-3.84.0.dist-info/METADATA,sha256=ijJpv2TMYSqXFg607-vZwabQv7Ib-B-cWeiu71D9-Xc,1052
|
|
42
|
+
bec_ipython_client-3.84.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
43
|
+
bec_ipython_client-3.84.0.dist-info/entry_points.txt,sha256=oQUXYY0jjD9ZvKPHwaGn2wkUIWpDZM8L4ixDA3RlBWE,53
|
|
44
|
+
bec_ipython_client-3.84.0.dist-info/RECORD,,
|
demo.py
CHANGED
|
@@ -23,7 +23,7 @@ scans = bec.scans
|
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
logger.success("Started BECClient")
|
|
26
|
-
scans.umv(dev.samx, 5, relative=
|
|
26
|
+
scans.umv(dev.samx, 5, dev.samy, 20, relative=False)
|
|
27
27
|
|
|
28
28
|
# with scans.interactive_scan() as scan:
|
|
29
29
|
# for ii in range(10):
|
|
@@ -226,4 +226,5 @@ scans.umv(dev.samx, 5, relative=True)
|
|
|
226
226
|
# event = threading.Event()
|
|
227
227
|
# event.wait()
|
|
228
228
|
print("eos")
|
|
229
|
+
bec.shutdown()
|
|
229
230
|
# p.join()
|
pyproject.toml
CHANGED
|
@@ -4,9 +4,9 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "bec_ipython_client"
|
|
7
|
-
version = "3.
|
|
7
|
+
version = "3.84.0"
|
|
8
8
|
description = "BEC IPython client"
|
|
9
|
-
requires-python = ">=3.
|
|
9
|
+
requires-python = ">=3.11"
|
|
10
10
|
classifiers = [
|
|
11
11
|
"Development Status :: 3 - Alpha",
|
|
12
12
|
"Programming Language :: Python :: 3",
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import fakeredis
|
|
2
|
+
import pytest
|
|
3
|
+
|
|
4
|
+
from bec_lib.redis_connector import RedisConnector
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def fake_redis_server(host, port, **kwargs):
|
|
8
|
+
redis = fakeredis.FakeRedis()
|
|
9
|
+
return redis
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@pytest.fixture
|
|
13
|
+
def connected_connector():
|
|
14
|
+
connector = RedisConnector("localhost:1", redis_cls=fake_redis_server)
|
|
15
|
+
connector._redis_conn.flushall()
|
|
16
|
+
try:
|
|
17
|
+
yield connector
|
|
18
|
+
finally:
|
|
19
|
+
connector.shutdown()
|
|
@@ -7,6 +7,7 @@ import pytest
|
|
|
7
7
|
|
|
8
8
|
from bec_ipython_client import BECIPythonClient, main
|
|
9
9
|
from bec_lib import messages
|
|
10
|
+
from bec_lib.alarm_handler import AlarmBase, AlarmHandler, Alarms
|
|
10
11
|
from bec_lib.redis_connector import RedisConnector
|
|
11
12
|
from bec_lib.service_config import ServiceConfig
|
|
12
13
|
|
|
@@ -204,10 +205,40 @@ def test_bec_ipython_client_property_access(ipython_client):
|
|
|
204
205
|
client.start()
|
|
205
206
|
|
|
206
207
|
with mock.patch.object(client._client, "connector") as mock_connector:
|
|
207
|
-
mock_connector.
|
|
208
|
+
mock_connector.get_last.return_value = messages.VariableMessage(value="account")
|
|
208
209
|
assert client._client.active_account == "account"
|
|
209
210
|
|
|
210
211
|
with pytest.raises(AttributeError):
|
|
211
212
|
client.active_account = "account"
|
|
212
213
|
with pytest.raises(AttributeError):
|
|
213
214
|
client._client.active_account = "account"
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
def test_bec_ipython_client_show_last_alarm(ipython_client, capsys):
|
|
218
|
+
client = ipython_client
|
|
219
|
+
error_info = messages.ErrorInfo(
|
|
220
|
+
error_message="This is a test alarm",
|
|
221
|
+
compact_error_message="Test alarm",
|
|
222
|
+
exception_type="TestAlarm",
|
|
223
|
+
device=None,
|
|
224
|
+
)
|
|
225
|
+
alarm_msg = messages.AlarmMessage(severity=Alarms.MAJOR, info=error_info)
|
|
226
|
+
client.alarm_handler = AlarmHandler(connector=mock.MagicMock())
|
|
227
|
+
client.alarm_handler.add_alarm(alarm_msg)
|
|
228
|
+
client._alarm_history.append(
|
|
229
|
+
(AlarmBase, client.alarm_handler.get_unhandled_alarms()[0], None, None)
|
|
230
|
+
)
|
|
231
|
+
client.show_last_alarm()
|
|
232
|
+
captured = capsys.readouterr()
|
|
233
|
+
assert "Alarm Raised" in captured.out
|
|
234
|
+
assert "Severity: MAJOR" in captured.out
|
|
235
|
+
assert "Type: TestAlarm" in captured.out
|
|
236
|
+
assert "This is a test alarm" in captured.out
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
def test_bec_ipython_client_show_last_no_alarm(ipython_client, capsys):
|
|
240
|
+
client = ipython_client
|
|
241
|
+
client._alarm_history = []
|
|
242
|
+
client.show_last_alarm()
|
|
243
|
+
captured = capsys.readouterr()
|
|
244
|
+
assert "No alarm has been raised in this session." in captured.out
|
|
@@ -107,11 +107,12 @@ class TestLiveTable:
|
|
|
107
107
|
)
|
|
108
108
|
def test_get_devices_from_scan_data(self, bec_client_mock, request_msg, scan_report_devices):
|
|
109
109
|
client = bec_client_mock
|
|
110
|
-
client.start()
|
|
111
110
|
data = messages.ScanMessage(
|
|
112
111
|
point_id=0, scan_id="", data={}, metadata={"scan_report_devices": scan_report_devices}
|
|
113
112
|
)
|
|
114
|
-
live_update = LiveUpdatesTable(
|
|
113
|
+
live_update = LiveUpdatesTable(
|
|
114
|
+
client, {"scan_progress": {"points": 10, "show_table": True}}, request_msg
|
|
115
|
+
)
|
|
115
116
|
devices = live_update.get_devices_from_scan_data(data)
|
|
116
117
|
assert devices[0 : len(scan_report_devices)] == scan_report_devices
|
|
117
118
|
|
|
@@ -123,7 +124,9 @@ class TestLiveTable:
|
|
|
123
124
|
)
|
|
124
125
|
client.queue.request_storage.update_with_request(request_msg)
|
|
125
126
|
client.queue.request_storage.update_with_response(response_msg)
|
|
126
|
-
live_update = LiveUpdatesTable(
|
|
127
|
+
live_update = LiveUpdatesTable(
|
|
128
|
+
client, {"scan_progress": {"points": 10, "show_table": True}}, request_msg
|
|
129
|
+
)
|
|
127
130
|
with mock.patch.object(client.queue.queue_storage, "find_queue_item_by_requestID"):
|
|
128
131
|
live_update.wait_for_request_acceptance()
|
|
129
132
|
|
|
@@ -138,7 +141,9 @@ class TestLiveTable:
|
|
|
138
141
|
client = bec_client_mock
|
|
139
142
|
client.start()
|
|
140
143
|
data = messages.ScanMessage(point_id=0, scan_id="", data={}, metadata={})
|
|
141
|
-
live_update = LiveUpdatesTable(
|
|
144
|
+
live_update = LiveUpdatesTable(
|
|
145
|
+
client, {"scan_progress": {"points": 10, "show_table": True}}, request_msg
|
|
146
|
+
)
|
|
142
147
|
live_update.scan_item = scan_item
|
|
143
148
|
scan_item.num_points = 2
|
|
144
149
|
scan_item.live_data = {0: data}
|
|
@@ -163,7 +168,9 @@ class TestLiveTable:
|
|
|
163
168
|
client = bec_client_mock
|
|
164
169
|
client.start()
|
|
165
170
|
data = messages.ScanMessage(point_id=0, scan_id="", data={}, metadata={})
|
|
166
|
-
live_update = LiveUpdatesTable(
|
|
171
|
+
live_update = LiveUpdatesTable(
|
|
172
|
+
client, {"scan_progress": {"points": 10, "show_table": True}}, request_msg
|
|
173
|
+
)
|
|
167
174
|
live_update.scan_item = scan_item
|
|
168
175
|
scan_item.num_points = 2
|
|
169
176
|
scan_item.live_data = {0: data}
|
|
@@ -193,7 +200,9 @@ class TestLiveTable:
|
|
|
193
200
|
)
|
|
194
201
|
client.queue.request_storage.update_with_request(request_msg)
|
|
195
202
|
client.queue.request_storage.update_with_response(response_msg)
|
|
196
|
-
live_update = LiveUpdatesTable(
|
|
203
|
+
live_update = LiveUpdatesTable(
|
|
204
|
+
client, {"scan_progress": {"points": 10, "show_table": True}}, request_msg
|
|
205
|
+
)
|
|
197
206
|
live_update.point_data = messages.ScanMessage(
|
|
198
207
|
point_id=0,
|
|
199
208
|
scan_id="",
|
|
@@ -212,7 +221,9 @@ class TestLiveTable:
|
|
|
212
221
|
)
|
|
213
222
|
client.queue.request_storage.update_with_request(request_msg)
|
|
214
223
|
client.queue.request_storage.update_with_response(response_msg)
|
|
215
|
-
live_update = LiveUpdatesTable(
|
|
224
|
+
live_update = LiveUpdatesTable(
|
|
225
|
+
client, {"scan_progress": {"points": 10, "show_table": True}}, request_msg
|
|
226
|
+
)
|
|
216
227
|
live_update.point_data = messages.ScanMessage(
|
|
217
228
|
point_id=0,
|
|
218
229
|
scan_id="",
|
|
@@ -231,7 +242,9 @@ class TestLiveTable:
|
|
|
231
242
|
)
|
|
232
243
|
client.queue.request_storage.update_with_request(request_msg)
|
|
233
244
|
client.queue.request_storage.update_with_response(response_msg)
|
|
234
|
-
live_update = LiveUpdatesTable(
|
|
245
|
+
live_update = LiveUpdatesTable(
|
|
246
|
+
client, {"scan_progress": {"points": 10, "show_table": True}}, request_msg
|
|
247
|
+
)
|
|
235
248
|
client.device_manager.devices["samx"]._info["hints"] = {"fields": ["samx_hint"]}
|
|
236
249
|
client.device_manager.devices["samx"].precision = 3
|
|
237
250
|
live_update.point_data = messages.ScanMessage(
|
|
@@ -263,7 +276,9 @@ class TestLiveTable:
|
|
|
263
276
|
)
|
|
264
277
|
client.queue.request_storage.update_with_request(request_msg)
|
|
265
278
|
client.queue.request_storage.update_with_response(response_msg)
|
|
266
|
-
live_update = LiveUpdatesTable(
|
|
279
|
+
live_update = LiveUpdatesTable(
|
|
280
|
+
client, {"scan_progress": {"points": 10, "show_table": True}}, request_msg
|
|
281
|
+
)
|
|
267
282
|
client.device_manager.devices["samx"]._info["hints"] = {"fields": ["samx_hint"]}
|
|
268
283
|
client.device_manager.devices["samx"].precision = prec
|
|
269
284
|
live_update.point_data = messages.ScanMessage(
|
|
@@ -312,7 +327,9 @@ class TestLiveTable:
|
|
|
312
327
|
)
|
|
313
328
|
client.queue.request_storage.update_with_request(request_msg)
|
|
314
329
|
client.queue.request_storage.update_with_response(response_msg)
|
|
315
|
-
live_update = LiveUpdatesTable(
|
|
330
|
+
live_update = LiveUpdatesTable(
|
|
331
|
+
client, {"scan_progress": {"points": 10, "show_table": True}}, request_msg
|
|
332
|
+
)
|
|
316
333
|
live_update.point_data = messages.ScanMessage(
|
|
317
334
|
point_id=0,
|
|
318
335
|
scan_id="",
|
|
@@ -355,7 +372,9 @@ class TestLiveTable:
|
|
|
355
372
|
"find_queue_item_by_requestID",
|
|
356
373
|
return_value=mock_queue_item,
|
|
357
374
|
):
|
|
358
|
-
live_update = LiveUpdatesTable(
|
|
375
|
+
live_update = LiveUpdatesTable(
|
|
376
|
+
client, {"scan_progress": {"points": 10, "show_table": True}}, request_msg
|
|
377
|
+
)
|
|
359
378
|
live_update.wait_for_request_acceptance()
|
|
360
379
|
result = StringIO()
|
|
361
380
|
with redirect_stdout(result):
|
|
@@ -376,7 +395,9 @@ class TestLiveTable:
|
|
|
376
395
|
)
|
|
377
396
|
client.queue.request_storage.update_with_request(request_msg)
|
|
378
397
|
client.queue.request_storage.update_with_response(response_msg)
|
|
379
|
-
live_update = LiveUpdatesTable(
|
|
398
|
+
live_update = LiveUpdatesTable(
|
|
399
|
+
client, {"scan_progress": {"points": 10, "show_table": True}}, request_msg
|
|
400
|
+
)
|
|
380
401
|
client.device_manager.devices["samx"]._info["hints"] = {"fields": ["samx_hint"]}
|
|
381
402
|
client.device_manager.devices["samx"].precision = prec
|
|
382
403
|
live_update.point_data = messages.ScanMessage(
|
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
import collections
|
|
2
|
+
import time
|
|
2
3
|
from unittest import mock
|
|
3
4
|
|
|
4
5
|
import pytest
|
|
5
6
|
|
|
6
7
|
from bec_ipython_client.callbacks.move_device import (
|
|
7
8
|
LiveUpdatesReadbackProgressbar,
|
|
8
|
-
|
|
9
|
+
ReadbackDataHandler,
|
|
9
10
|
)
|
|
10
11
|
from bec_lib import messages
|
|
11
12
|
from bec_lib.endpoints import MessageEndpoints
|
|
12
13
|
|
|
13
14
|
|
|
14
15
|
@pytest.fixture
|
|
15
|
-
def
|
|
16
|
-
with mock.patch.object(bec_client_mock.device_manager, "connector"):
|
|
17
|
-
yield
|
|
16
|
+
def readback_data_handler(bec_client_mock, connected_connector):
|
|
17
|
+
with mock.patch.object(bec_client_mock.device_manager, "connector", connected_connector):
|
|
18
|
+
yield ReadbackDataHandler(
|
|
19
|
+
bec_client_mock.device_manager, ["samx", "samy"], request_id="something"
|
|
20
|
+
)
|
|
18
21
|
|
|
19
22
|
|
|
20
23
|
def test_move_callback(bec_client_mock):
|
|
@@ -33,30 +36,25 @@ def test_move_callback(bec_client_mock):
|
|
|
33
36
|
return readback[0]
|
|
34
37
|
|
|
35
38
|
req_done = collections.deque()
|
|
36
|
-
|
|
37
|
-
device="samx", success=True, metadata={"RID": "something"}
|
|
38
|
-
)
|
|
39
|
-
req_done.extend([[None], [None], [None], [msg_acc]])
|
|
39
|
+
req_done.extend([{"samx": (False, False)}, {"samx": (False, False)}, {"samx": (True, True)}])
|
|
40
40
|
|
|
41
41
|
def mock_req_msg(*args):
|
|
42
42
|
if len(req_done) > 1:
|
|
43
43
|
return req_done.popleft()
|
|
44
44
|
return req_done[0]
|
|
45
45
|
|
|
46
|
-
with mock.patch("bec_ipython_client.callbacks.move_device.check_alarms")
|
|
47
|
-
with mock.patch.object(
|
|
48
|
-
with mock.patch.object(
|
|
46
|
+
with mock.patch("bec_ipython_client.callbacks.move_device.check_alarms"):
|
|
47
|
+
with mock.patch.object(LiveUpdatesReadbackProgressbar, "wait_for_request_acceptance"):
|
|
48
|
+
with mock.patch.object(
|
|
49
|
+
LiveUpdatesReadbackProgressbar, "_print_client_msgs_asap"
|
|
50
|
+
) as mock_client_msgs:
|
|
49
51
|
with mock.patch.object(
|
|
50
|
-
LiveUpdatesReadbackProgressbar, "
|
|
51
|
-
) as
|
|
52
|
-
with mock.patch.object(
|
|
53
|
-
|
|
54
|
-
) as mock_client_msgs_all:
|
|
55
|
-
with mock.patch.object(
|
|
56
|
-
ReadbackDataMixin, "get_device_values", mock_readback
|
|
57
|
-
):
|
|
52
|
+
LiveUpdatesReadbackProgressbar, "_print_client_msgs_all"
|
|
53
|
+
) as mock_client_msgs_all:
|
|
54
|
+
with mock.patch.object(ReadbackDataHandler, "get_device_values", mock_readback):
|
|
55
|
+
with mock.patch.object(ReadbackDataHandler, "device_states", mock_req_msg):
|
|
58
56
|
with mock.patch.object(
|
|
59
|
-
|
|
57
|
+
ReadbackDataHandler, "done", side_effect=[False, False, True]
|
|
60
58
|
):
|
|
61
59
|
LiveUpdatesReadbackProgressbar(bec=client, request=request).run()
|
|
62
60
|
assert mock_client_msgs.called is True
|
|
@@ -82,28 +80,21 @@ def test_move_callback_with_report_instruction(bec_client_mock):
|
|
|
82
80
|
return readback[0]
|
|
83
81
|
|
|
84
82
|
req_done = collections.deque()
|
|
85
|
-
|
|
86
|
-
device="samx", success=True, metadata={"RID": "something"}
|
|
87
|
-
)
|
|
88
|
-
req_done.extend([[None], [None], [None], [msg_acc]])
|
|
83
|
+
req_done.extend([{"samx": (False, False)}, {"samx": (False, False)}, {"samx": (True, True)}])
|
|
89
84
|
|
|
90
85
|
def mock_req_msg(*args):
|
|
91
86
|
if len(req_done) > 1:
|
|
92
87
|
return req_done.popleft()
|
|
93
88
|
return req_done[0]
|
|
94
89
|
|
|
95
|
-
with mock.patch("bec_ipython_client.callbacks.move_device.check_alarms")
|
|
96
|
-
with mock.patch.object(
|
|
97
|
-
with mock.patch.object(LiveUpdatesReadbackProgressbar, "
|
|
98
|
-
with mock.patch.object(LiveUpdatesReadbackProgressbar, "
|
|
99
|
-
with mock.patch.object(
|
|
100
|
-
|
|
101
|
-
):
|
|
102
|
-
with mock.patch.object(
|
|
103
|
-
ReadbackDataMixin, "get_device_values", mock_readback
|
|
104
|
-
):
|
|
90
|
+
with mock.patch("bec_ipython_client.callbacks.move_device.check_alarms"):
|
|
91
|
+
with mock.patch.object(LiveUpdatesReadbackProgressbar, "wait_for_request_acceptance"):
|
|
92
|
+
with mock.patch.object(LiveUpdatesReadbackProgressbar, "_print_client_msgs_asap"):
|
|
93
|
+
with mock.patch.object(LiveUpdatesReadbackProgressbar, "_print_client_msgs_all"):
|
|
94
|
+
with mock.patch.object(ReadbackDataHandler, "get_device_values", mock_readback):
|
|
95
|
+
with mock.patch.object(ReadbackDataHandler, "device_states", mock_req_msg):
|
|
105
96
|
with mock.patch.object(
|
|
106
|
-
|
|
97
|
+
ReadbackDataHandler, "done", side_effect=[False, False, False, True]
|
|
107
98
|
):
|
|
108
99
|
LiveUpdatesReadbackProgressbar(
|
|
109
100
|
bec=client,
|
|
@@ -112,70 +103,121 @@ def test_move_callback_with_report_instruction(bec_client_mock):
|
|
|
112
103
|
).run()
|
|
113
104
|
|
|
114
105
|
|
|
115
|
-
def
|
|
116
|
-
|
|
117
|
-
messages.DeviceMessage(
|
|
106
|
+
def test_readback_data_handler(readback_data_handler):
|
|
107
|
+
readback_data_handler.data = {
|
|
108
|
+
"samx": messages.DeviceMessage(
|
|
118
109
|
signals={"samx": {"value": 10}, "samx_setpoint": {"value": 20}},
|
|
119
110
|
metadata={"device": "samx"},
|
|
120
111
|
),
|
|
121
|
-
messages.DeviceMessage(
|
|
112
|
+
"samy": messages.DeviceMessage(
|
|
122
113
|
signals={"samy": {"value": 10}, "samy_setpoint": {"value": 20}},
|
|
123
114
|
metadata={"device": "samy"},
|
|
124
115
|
),
|
|
125
|
-
|
|
126
|
-
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
res = readback_data_handler.get_device_values()
|
|
127
119
|
assert res == [10, 10]
|
|
128
120
|
|
|
129
121
|
|
|
130
|
-
def
|
|
131
|
-
|
|
122
|
+
def test_readback_data_handler_multiple_hints(readback_data_handler):
|
|
123
|
+
readback_data_handler.device_manager.devices.samx._info["hints"]["fields"] = [
|
|
132
124
|
"samx_setpoint",
|
|
133
125
|
"samx",
|
|
134
126
|
]
|
|
135
|
-
|
|
136
|
-
messages.DeviceMessage(
|
|
127
|
+
readback_data_handler.data = {
|
|
128
|
+
"samx": messages.DeviceMessage(
|
|
137
129
|
signals={"samx": {"value": 10}, "samx_setpoint": {"value": 20}},
|
|
138
130
|
metadata={"device": "samx"},
|
|
139
131
|
),
|
|
140
|
-
messages.DeviceMessage(
|
|
132
|
+
"samy": messages.DeviceMessage(
|
|
141
133
|
signals={"samy": {"value": 10}, "samy_setpoint": {"value": 20}},
|
|
142
134
|
metadata={"device": "samy"},
|
|
143
135
|
),
|
|
144
|
-
|
|
145
|
-
res =
|
|
136
|
+
}
|
|
137
|
+
res = readback_data_handler.get_device_values()
|
|
146
138
|
assert res == [20, 10]
|
|
147
139
|
|
|
148
140
|
|
|
149
|
-
def
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
messages.DeviceMessage(
|
|
141
|
+
def test_readback_data_handler_multiple_no_hints(readback_data_handler):
|
|
142
|
+
readback_data_handler.device_manager.devices.samx._info["hints"]["fields"] = []
|
|
143
|
+
readback_data_handler.data = {
|
|
144
|
+
"samx": messages.DeviceMessage(
|
|
153
145
|
signals={"samx": {"value": 10}, "samx_setpoint": {"value": 20}},
|
|
154
146
|
metadata={"device": "samx"},
|
|
155
147
|
),
|
|
156
|
-
messages.DeviceMessage(
|
|
148
|
+
"samy": messages.DeviceMessage(
|
|
157
149
|
signals={"samy": {"value": 10}, "samy_setpoint": {"value": 20}},
|
|
158
150
|
metadata={"device": "samy"},
|
|
159
151
|
),
|
|
160
|
-
|
|
161
|
-
res =
|
|
152
|
+
}
|
|
153
|
+
res = readback_data_handler.get_device_values()
|
|
162
154
|
assert res == [10, 10]
|
|
163
155
|
|
|
164
156
|
|
|
165
|
-
def
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
)
|
|
173
|
-
|
|
157
|
+
def test_readback_data_handler_init(readback_data_handler):
|
|
158
|
+
"""
|
|
159
|
+
Test that the ReadbackDataHandler is initialized correctly.
|
|
160
|
+
"""
|
|
161
|
+
|
|
162
|
+
# Initial state
|
|
163
|
+
assert readback_data_handler._devices_done_state == {
|
|
164
|
+
"samx": (False, False),
|
|
165
|
+
"samy": (False, False),
|
|
166
|
+
}
|
|
167
|
+
assert readback_data_handler._devices_received == {"samx": False, "samy": False}
|
|
168
|
+
assert readback_data_handler.data == {}
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
def test_readback_data_handler_readback_callbacks(readback_data_handler):
|
|
172
|
+
"""
|
|
173
|
+
Test that the readback callback properly updates the readback data.
|
|
174
|
+
"""
|
|
175
|
+
|
|
176
|
+
# Submit readback for samx
|
|
177
|
+
msg = messages.DeviceMessage(
|
|
178
|
+
signals={"samx": {"value": 15}}, metadata={"device": "samx", "RID": "something"}
|
|
174
179
|
)
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
180
|
+
readback_data_handler.connector.set_and_publish(MessageEndpoints.device_readback("samx"), msg)
|
|
181
|
+
|
|
182
|
+
msg_old = messages.DeviceMessage(
|
|
183
|
+
signals={"samy": {"value": 10}}, metadata={"device": "samx", "RID": "something_else"}
|
|
184
|
+
)
|
|
185
|
+
readback_data_handler.connector.set_and_publish(
|
|
186
|
+
MessageEndpoints.device_readback("samy"), msg_old
|
|
187
|
+
)
|
|
188
|
+
while (
|
|
189
|
+
not readback_data_handler._devices_received["samx"]
|
|
190
|
+
or "samx" not in readback_data_handler.data
|
|
191
|
+
):
|
|
192
|
+
time.sleep(0.01)
|
|
193
|
+
assert readback_data_handler.data["samx"].signals["samx"]["value"] == 15
|
|
194
|
+
dev_data = readback_data_handler.get_device_values()
|
|
195
|
+
assert dev_data[0] == 15
|
|
196
|
+
assert dev_data[1] == 10 # samy remains unchanged
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
def test_readback_data_handler_request_done_callbacks(readback_data_handler):
|
|
200
|
+
"""
|
|
201
|
+
Test that the request done callback properly updates the device done state.
|
|
202
|
+
"""
|
|
203
|
+
|
|
204
|
+
# Submit request done for samx
|
|
205
|
+
msg = messages.DeviceReqStatusMessage(device="samx", success=True, request_id="something")
|
|
206
|
+
readback_data_handler.connector.xadd(
|
|
207
|
+
MessageEndpoints.device_req_status("something"), {"data": msg}
|
|
208
|
+
)
|
|
209
|
+
while not readback_data_handler._devices_done_state["samx"][0]:
|
|
210
|
+
time.sleep(0.01)
|
|
211
|
+
assert readback_data_handler._devices_done_state["samx"] == (True, True)
|
|
212
|
+
|
|
213
|
+
assert readback_data_handler.done() is False
|
|
214
|
+
|
|
215
|
+
# Submit request done for samy
|
|
216
|
+
msg = messages.DeviceReqStatusMessage(device="samy", success=False, request_id="something")
|
|
217
|
+
readback_data_handler.connector.xadd(
|
|
218
|
+
MessageEndpoints.device_req_status("something"), {"data": msg}
|
|
181
219
|
)
|
|
220
|
+
while not readback_data_handler._devices_done_state["samy"][0]:
|
|
221
|
+
time.sleep(0.01)
|
|
222
|
+
assert readback_data_handler._devices_done_state["samy"] == (True, False)
|
|
223
|
+
assert readback_data_handler.done() is True
|
|
@@ -8,14 +8,14 @@ image_name = (
|
|
|
8
8
|
)
|
|
9
9
|
podman = PodmanCliUtils()
|
|
10
10
|
|
|
11
|
-
for i in range(1,
|
|
11
|
+
for i in range(1, 6):
|
|
12
12
|
try:
|
|
13
13
|
output = podman._run_and_capture_error("podman", "pull", image_name)
|
|
14
14
|
print("successfully pulled requirements image for current version")
|
|
15
15
|
exit(0)
|
|
16
16
|
except ProcedureWorkerError as e:
|
|
17
17
|
print(e)
|
|
18
|
-
print("retrying in
|
|
19
|
-
sleep(
|
|
18
|
+
print("retrying in 5 minutes...")
|
|
19
|
+
sleep(5 * 60)
|
|
20
20
|
print(f"No more retries. Check if {image_name} actually exists!")
|
|
21
21
|
exit(1)
|