bec-ipython-client 4.9.0__tar.gz → 4.10.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.
- {bec_ipython_client-4.9.0 → bec_ipython_client-4.10.0}/PKG-INFO +1 -1
- {bec_ipython_client-4.9.0 → bec_ipython_client-4.10.0}/pyproject.toml +1 -1
- bec_ipython_client-4.10.0/tests/end-2-end/test_scan_sequencer_e2e.py +202 -0
- {bec_ipython_client-4.9.0 → bec_ipython_client-4.10.0}/.gitignore +0 -0
- {bec_ipython_client-4.9.0 → bec_ipython_client-4.10.0}/bec_ipython_client/__init__.py +0 -0
- {bec_ipython_client-4.9.0 → bec_ipython_client-4.10.0}/bec_ipython_client/beamline_mixin.py +0 -0
- {bec_ipython_client-4.9.0 → bec_ipython_client-4.10.0}/bec_ipython_client/bec_magics.py +0 -0
- {bec_ipython_client-4.9.0 → bec_ipython_client-4.10.0}/bec_ipython_client/bec_startup.py +0 -0
- {bec_ipython_client-4.9.0 → bec_ipython_client-4.10.0}/bec_ipython_client/callbacks/__init__.py +0 -0
- {bec_ipython_client-4.9.0 → bec_ipython_client-4.10.0}/bec_ipython_client/callbacks/device_progress.py +0 -0
- {bec_ipython_client-4.9.0 → bec_ipython_client-4.10.0}/bec_ipython_client/callbacks/ipython_live_updates.py +0 -0
- {bec_ipython_client-4.9.0 → bec_ipython_client-4.10.0}/bec_ipython_client/callbacks/live_table.py +0 -0
- {bec_ipython_client-4.9.0 → bec_ipython_client-4.10.0}/bec_ipython_client/callbacks/move_device.py +0 -0
- {bec_ipython_client-4.9.0 → bec_ipython_client-4.10.0}/bec_ipython_client/callbacks/utils.py +0 -0
- {bec_ipython_client-4.9.0 → bec_ipython_client-4.10.0}/bec_ipython_client/gui_client.py +0 -0
- {bec_ipython_client-4.9.0 → bec_ipython_client-4.10.0}/bec_ipython_client/high_level_interfaces/__init__.py +0 -0
- {bec_ipython_client-4.9.0 → bec_ipython_client-4.10.0}/bec_ipython_client/high_level_interfaces/bec_hli.py +0 -0
- {bec_ipython_client-4.9.0 → bec_ipython_client-4.10.0}/bec_ipython_client/high_level_interfaces/spec_hli.py +0 -0
- {bec_ipython_client-4.9.0 → bec_ipython_client-4.10.0}/bec_ipython_client/main.py +0 -0
- {bec_ipython_client-4.9.0 → bec_ipython_client-4.10.0}/bec_ipython_client/plugins/SLS/__init__.py +0 -0
- {bec_ipython_client-4.9.0 → bec_ipython_client-4.10.0}/bec_ipython_client/plugins/SLS/sls_info.py +0 -0
- {bec_ipython_client-4.9.0 → bec_ipython_client-4.10.0}/bec_ipython_client/plugins/XTreme/__init__.py +0 -0
- {bec_ipython_client-4.9.0 → bec_ipython_client-4.10.0}/bec_ipython_client/plugins/XTreme/x-treme.py +0 -0
- {bec_ipython_client-4.9.0 → bec_ipython_client-4.10.0}/bec_ipython_client/plugins/__init__.py +0 -0
- {bec_ipython_client-4.9.0 → bec_ipython_client-4.10.0}/bec_ipython_client/plugins/flomni/flomni_config.yaml +0 -0
- {bec_ipython_client-4.9.0 → bec_ipython_client-4.10.0}/bec_ipython_client/prettytable.py +0 -0
- {bec_ipython_client-4.9.0 → bec_ipython_client-4.10.0}/bec_ipython_client/progressbar.py +0 -0
- {bec_ipython_client-4.9.0 → bec_ipython_client-4.10.0}/bec_ipython_client/signals.py +0 -0
- {bec_ipython_client-4.9.0 → bec_ipython_client-4.10.0}/demo.py +0 -0
- {bec_ipython_client-4.9.0 → bec_ipython_client-4.10.0}/tests/client_tests/conftest.py +0 -0
- {bec_ipython_client-4.9.0 → bec_ipython_client-4.10.0}/tests/client_tests/test_beamline_mixins.py +0 -0
- {bec_ipython_client-4.9.0 → bec_ipython_client-4.10.0}/tests/client_tests/test_bec_client.py +0 -0
- {bec_ipython_client-4.9.0 → bec_ipython_client-4.10.0}/tests/client_tests/test_device_progress.py +0 -0
- {bec_ipython_client-4.9.0 → bec_ipython_client-4.10.0}/tests/client_tests/test_gui_client.py +0 -0
- {bec_ipython_client-4.9.0 → bec_ipython_client-4.10.0}/tests/client_tests/test_ipython_live_updates.py +0 -0
- {bec_ipython_client-4.9.0 → bec_ipython_client-4.10.0}/tests/client_tests/test_live_table.py +0 -0
- {bec_ipython_client-4.9.0 → bec_ipython_client-4.10.0}/tests/client_tests/test_move_callback.py +0 -0
- {bec_ipython_client-4.9.0 → bec_ipython_client-4.10.0}/tests/client_tests/test_pretty_table.py +0 -0
- {bec_ipython_client-4.9.0 → bec_ipython_client-4.10.0}/tests/client_tests/test_signals.py +0 -0
- {bec_ipython_client-4.9.0 → bec_ipython_client-4.10.0}/tests/conftest.py +0 -0
- {bec_ipython_client-4.9.0 → bec_ipython_client-4.10.0}/tests/end-2-end/_ensure_requirements_container.py +0 -0
- {bec_ipython_client-4.9.0 → bec_ipython_client-4.10.0}/tests/end-2-end/test_acl_e2e.py +0 -0
- {bec_ipython_client-4.9.0 → bec_ipython_client-4.10.0}/tests/end-2-end/test_actors_e2e.py +0 -0
- {bec_ipython_client-4.9.0 → bec_ipython_client-4.10.0}/tests/end-2-end/test_procedures_e2e.py +0 -0
- {bec_ipython_client-4.9.0 → bec_ipython_client-4.10.0}/tests/end-2-end/test_scan_workflows_lib_e2e.py +0 -0
- {bec_ipython_client-4.9.0 → bec_ipython_client-4.10.0}/tests/end-2-end/test_scans_e2e.py +0 -0
- {bec_ipython_client-4.9.0 → bec_ipython_client-4.10.0}/tests/end-2-end/test_scans_lib_e2e.py +0 -0
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
"""Sequences compose real queue requests and proxy sets against demo services."""
|
|
2
|
+
|
|
3
|
+
from contextlib import nullcontext
|
|
4
|
+
from unittest.mock import Mock
|
|
5
|
+
|
|
6
|
+
import pytest
|
|
7
|
+
|
|
8
|
+
from bec_lib.procedures.helper import ProcedureState
|
|
9
|
+
from bec_lib.scan_sequencer import (
|
|
10
|
+
Definition,
|
|
11
|
+
DefinitionLibrary,
|
|
12
|
+
ExecutionError,
|
|
13
|
+
Schedule,
|
|
14
|
+
Sequencer,
|
|
15
|
+
)
|
|
16
|
+
from bec_lib.tests.utils import wait_until
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
@pytest.mark.timeout(120)
|
|
20
|
+
@pytest.mark.parametrize("exported", [False, True])
|
|
21
|
+
@pytest.mark.parametrize("completed", [False, True])
|
|
22
|
+
def test_sequence_motor_reuse_requires_completed_move(
|
|
23
|
+
bec_ipython_client_fixture, monkeypatch, exported, completed
|
|
24
|
+
):
|
|
25
|
+
bec = bec_ipython_client_fixture
|
|
26
|
+
motor = bec.device_manager.devices.samx
|
|
27
|
+
velocity = motor.velocity.get()
|
|
28
|
+
native_mv = bec.scans.mv
|
|
29
|
+
blocking_move = Mock(wraps=bec.scans.umv)
|
|
30
|
+
|
|
31
|
+
def start_move(*args, **kwargs):
|
|
32
|
+
report = native_mv(*args, **kwargs)
|
|
33
|
+
wait_until(lambda: motor.motor_is_moving.get(), timeout_s=10)
|
|
34
|
+
if completed:
|
|
35
|
+
report.wait()
|
|
36
|
+
return report
|
|
37
|
+
|
|
38
|
+
document = Schedule(
|
|
39
|
+
id="exclusive_move",
|
|
40
|
+
revision=1,
|
|
41
|
+
root={
|
|
42
|
+
"id": "root",
|
|
43
|
+
"type": "sequence",
|
|
44
|
+
"children": [
|
|
45
|
+
{"id": "first", "type": "set", "device": "samx", "value": 5, "wait": False},
|
|
46
|
+
{"id": "second", "type": "set", "device": "samx", "value": 0},
|
|
47
|
+
],
|
|
48
|
+
},
|
|
49
|
+
)
|
|
50
|
+
try:
|
|
51
|
+
motor.velocity.set(1).wait(timeout=10)
|
|
52
|
+
monkeypatch.setattr(bec.scans, "mv", start_move)
|
|
53
|
+
monkeypatch.setattr(bec.scans, "umv", blocking_move)
|
|
54
|
+
sequencer = Sequencer(bec)
|
|
55
|
+
expected = (
|
|
56
|
+
nullcontext()
|
|
57
|
+
if completed
|
|
58
|
+
else pytest.raises(RuntimeError, match="still has an outstanding nonblocking move")
|
|
59
|
+
)
|
|
60
|
+
with bec.scans.hide_report:
|
|
61
|
+
with expected as error:
|
|
62
|
+
if exported:
|
|
63
|
+
exec(
|
|
64
|
+
sequencer.export(document, format="python"),
|
|
65
|
+
{"dev": bec.device_manager.devices, "scans": bec.scans},
|
|
66
|
+
)
|
|
67
|
+
else:
|
|
68
|
+
sequencer.execute(document)
|
|
69
|
+
if not completed and not exported:
|
|
70
|
+
assert isinstance(error.value, ExecutionError)
|
|
71
|
+
assert error.value.path == ("root", "second")
|
|
72
|
+
if completed:
|
|
73
|
+
blocking_move.assert_called_once()
|
|
74
|
+
else:
|
|
75
|
+
blocking_move.assert_not_called()
|
|
76
|
+
wait_until(lambda: not motor.motor_is_moving.get(), timeout_s=5)
|
|
77
|
+
finally:
|
|
78
|
+
motor.stop()
|
|
79
|
+
motor.velocity.set(velocity).wait(timeout=10)
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
@pytest.mark.timeout(180)
|
|
83
|
+
def test_sequence_uses_existing_scan_queue_and_device_statuses(
|
|
84
|
+
bec_ipython_client_fixture, monkeypatch
|
|
85
|
+
):
|
|
86
|
+
# Use the standard demo configuration loaded by the shared client fixture.
|
|
87
|
+
grid_arguments = ["samx", -1.0, 1.0, 2, "samy", -1.0, 1.0, 2]
|
|
88
|
+
grid_keywords = {"relative": False, "exp_time": 0.01}
|
|
89
|
+
definition = Definition(
|
|
90
|
+
id="measure_grid",
|
|
91
|
+
version=1,
|
|
92
|
+
parameters={
|
|
93
|
+
"type": "object",
|
|
94
|
+
"properties": {"position": {"type": "number"}},
|
|
95
|
+
"required": ["position"],
|
|
96
|
+
"additionalProperties": False,
|
|
97
|
+
},
|
|
98
|
+
body={
|
|
99
|
+
"id": "measurement",
|
|
100
|
+
"type": "sequence",
|
|
101
|
+
"children": [
|
|
102
|
+
{
|
|
103
|
+
"id": "move_z",
|
|
104
|
+
"type": "set",
|
|
105
|
+
"device": "samz",
|
|
106
|
+
"value": {"param": "position"},
|
|
107
|
+
"wait": True,
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
"id": "grid",
|
|
111
|
+
"type": "scan_call",
|
|
112
|
+
"name": "grid_scan",
|
|
113
|
+
"positional": grid_arguments,
|
|
114
|
+
"arguments": grid_keywords,
|
|
115
|
+
},
|
|
116
|
+
],
|
|
117
|
+
},
|
|
118
|
+
)
|
|
119
|
+
document = Schedule(
|
|
120
|
+
id="grid_at_z_positions",
|
|
121
|
+
revision=1,
|
|
122
|
+
root={
|
|
123
|
+
"id": "repeat",
|
|
124
|
+
"type": "repeat",
|
|
125
|
+
"count": 2,
|
|
126
|
+
"body": {
|
|
127
|
+
"id": "positions",
|
|
128
|
+
"type": "for_each",
|
|
129
|
+
"variable": "position",
|
|
130
|
+
"values": [1, -1],
|
|
131
|
+
"body": {
|
|
132
|
+
"id": "measure",
|
|
133
|
+
"type": "component_call",
|
|
134
|
+
"definition": {"id": "measure_grid", "version": 1},
|
|
135
|
+
"arguments": {"position": {"ref": "position"}},
|
|
136
|
+
},
|
|
137
|
+
},
|
|
138
|
+
},
|
|
139
|
+
)
|
|
140
|
+
scheduler = Sequencer(bec_ipython_client_fixture, DefinitionLibrary([definition]))
|
|
141
|
+
trace = []
|
|
142
|
+
native_move = bec_ipython_client_fixture.scans.umv
|
|
143
|
+
native_scan = bec_ipython_client_fixture.scans.grid_scan
|
|
144
|
+
|
|
145
|
+
def record_move(target, value, **kwargs):
|
|
146
|
+
trace.append(("set", target.name, value))
|
|
147
|
+
return native_move(target, value, **kwargs)
|
|
148
|
+
|
|
149
|
+
def record_scan(*args, **kwargs):
|
|
150
|
+
trace.append(("scan", "grid_scan"))
|
|
151
|
+
return native_scan(*args, **kwargs)
|
|
152
|
+
|
|
153
|
+
monkeypatch.setattr(bec_ipython_client_fixture.scans, "umv", record_move)
|
|
154
|
+
monkeypatch.setattr(bec_ipython_client_fixture.scans, "grid_scan", record_scan)
|
|
155
|
+
scheduler.execute(document)
|
|
156
|
+
assert trace == [
|
|
157
|
+
("set", "samz", 1),
|
|
158
|
+
("scan", "grid_scan"),
|
|
159
|
+
("set", "samz", -1),
|
|
160
|
+
("scan", "grid_scan"),
|
|
161
|
+
("set", "samz", 1),
|
|
162
|
+
("scan", "grid_scan"),
|
|
163
|
+
("set", "samz", -1),
|
|
164
|
+
("scan", "grid_scan"),
|
|
165
|
+
]
|
|
166
|
+
|
|
167
|
+
# Execute the readable export through the same real public IPython calls.
|
|
168
|
+
move = Mock(wraps=bec_ipython_client_fixture.scans.umv)
|
|
169
|
+
acquire = Mock(wraps=bec_ipython_client_fixture.scans.grid_scan)
|
|
170
|
+
native_calls = Mock()
|
|
171
|
+
native_calls.attach_mock(move, "umv")
|
|
172
|
+
native_calls.attach_mock(acquire, "grid_scan")
|
|
173
|
+
monkeypatch.setattr(bec_ipython_client_fixture.scans, "umv", move)
|
|
174
|
+
monkeypatch.setattr(bec_ipython_client_fixture.scans, "grid_scan", acquire)
|
|
175
|
+
namespace = {
|
|
176
|
+
"bec": bec_ipython_client_fixture,
|
|
177
|
+
"dev": bec_ipython_client_fixture.device_manager.devices,
|
|
178
|
+
"scans": bec_ipython_client_fixture.scans,
|
|
179
|
+
}
|
|
180
|
+
source = scheduler.export(document, format="python")
|
|
181
|
+
with bec_ipython_client_fixture.scans.hide_report:
|
|
182
|
+
exec(compile(source, "exported_sequence.py", "exec"), namespace)
|
|
183
|
+
assert move.call_count == acquire.call_count == 4
|
|
184
|
+
assert [call.args[1] for call in move.call_args_list] == [1, -1, 1, -1]
|
|
185
|
+
assert all(
|
|
186
|
+
call.args[0] is bec_ipython_client_fixture.device_manager.devices.samz
|
|
187
|
+
for call in move.call_args_list
|
|
188
|
+
)
|
|
189
|
+
assert [call[0] for call in native_calls.mock_calls] == ["umv", "grid_scan"] * 4
|
|
190
|
+
assert all(
|
|
191
|
+
list(call.args) == grid_arguments and call.kwargs == grid_keywords
|
|
192
|
+
for call in acquire.call_args_list
|
|
193
|
+
)
|
|
194
|
+
|
|
195
|
+
# Submit to the scan server's procedure manager using the public client API.
|
|
196
|
+
status = bec_ipython_client_fixture.proc.request_new(
|
|
197
|
+
"run_sequence",
|
|
198
|
+
((document.model_dump_json(), [definition.model_dump()]), {}),
|
|
199
|
+
queue="sequence-e2e",
|
|
200
|
+
)
|
|
201
|
+
status.wait(timeout_s=90, raise_on_failure=True)
|
|
202
|
+
assert status.state == ProcedureState.SUCCESS
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{bec_ipython_client-4.9.0 → bec_ipython_client-4.10.0}/bec_ipython_client/callbacks/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{bec_ipython_client-4.9.0 → bec_ipython_client-4.10.0}/bec_ipython_client/callbacks/live_table.py
RENAMED
|
File without changes
|
{bec_ipython_client-4.9.0 → bec_ipython_client-4.10.0}/bec_ipython_client/callbacks/move_device.py
RENAMED
|
File without changes
|
{bec_ipython_client-4.9.0 → bec_ipython_client-4.10.0}/bec_ipython_client/callbacks/utils.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{bec_ipython_client-4.9.0 → bec_ipython_client-4.10.0}/bec_ipython_client/plugins/SLS/__init__.py
RENAMED
|
File without changes
|
{bec_ipython_client-4.9.0 → bec_ipython_client-4.10.0}/bec_ipython_client/plugins/SLS/sls_info.py
RENAMED
|
File without changes
|
{bec_ipython_client-4.9.0 → bec_ipython_client-4.10.0}/bec_ipython_client/plugins/XTreme/__init__.py
RENAMED
|
File without changes
|
{bec_ipython_client-4.9.0 → bec_ipython_client-4.10.0}/bec_ipython_client/plugins/XTreme/x-treme.py
RENAMED
|
File without changes
|
{bec_ipython_client-4.9.0 → bec_ipython_client-4.10.0}/bec_ipython_client/plugins/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{bec_ipython_client-4.9.0 → bec_ipython_client-4.10.0}/tests/client_tests/test_beamline_mixins.py
RENAMED
|
File without changes
|
{bec_ipython_client-4.9.0 → bec_ipython_client-4.10.0}/tests/client_tests/test_bec_client.py
RENAMED
|
File without changes
|
{bec_ipython_client-4.9.0 → bec_ipython_client-4.10.0}/tests/client_tests/test_device_progress.py
RENAMED
|
File without changes
|
{bec_ipython_client-4.9.0 → bec_ipython_client-4.10.0}/tests/client_tests/test_gui_client.py
RENAMED
|
File without changes
|
|
File without changes
|
{bec_ipython_client-4.9.0 → bec_ipython_client-4.10.0}/tests/client_tests/test_live_table.py
RENAMED
|
File without changes
|
{bec_ipython_client-4.9.0 → bec_ipython_client-4.10.0}/tests/client_tests/test_move_callback.py
RENAMED
|
File without changes
|
{bec_ipython_client-4.9.0 → bec_ipython_client-4.10.0}/tests/client_tests/test_pretty_table.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{bec_ipython_client-4.9.0 → bec_ipython_client-4.10.0}/tests/end-2-end/test_procedures_e2e.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{bec_ipython_client-4.9.0 → bec_ipython_client-4.10.0}/tests/end-2-end/test_scans_lib_e2e.py
RENAMED
|
File without changes
|