diff --git a/bec_ipython_client/bec_ipython_client/callbacks/ipython_live_updates.py b/bec_ipython_client/bec_ipython_client/callbacks/ipython_live_updates.py index 042f42f98..f94d4684d 100644 --- a/bec_ipython_client/bec_ipython_client/callbacks/ipython_live_updates.py +++ b/bec_ipython_client/bec_ipython_client/callbacks/ipython_live_updates.py @@ -63,9 +63,6 @@ def _process_report_instructions(self, report_instructions: list) -> None: if not self._active_request: return scan_type = self._active_request.scan_type - if scan_type in ["open_scan_def", "close_scan_def"]: - self._process_instruction({"scan_progress": {"points": 0, "show_table": True}}) - return if scan_type == "close_scan_group": return @@ -319,10 +316,9 @@ def _process_queue( if not available_blocks: return False req_block = available_blocks[self._request_block_index[req_id]] - if req_block.msg.scan_type in [ - "open_scan_def", - "mv", - ]: # TODO: make this more general for all scan types that don't have report instructions + if ( + req_block.msg.scan_type == "mv" + ): # TODO: make this more general for scans without report instructions return True report_instructions = req_block.report_instructions or [] @@ -405,11 +401,7 @@ def _reset(self, forced=False): self._current_queue = None self._user_callback = None self._processed_instructions = 0 - scan_closed = ( - forced - or self._active_request is None - or (self._active_request.scan_type == "close_scan_def") - ) + scan_closed = forced or self._active_request is None self._active_request = None if self.client.scans._scan_def_id and not scan_closed: diff --git a/bec_ipython_client/bec_ipython_client/callbacks/live_table.py b/bec_ipython_client/bec_ipython_client/callbacks/live_table.py index 8f861336e..05b171beb 100644 --- a/bec_ipython_client/bec_ipython_client/callbacks/live_table.py +++ b/bec_ipython_client/bec_ipython_client/callbacks/live_table.py @@ -377,11 +377,6 @@ def close_table(self): def process_request(self): """process the request and start the core loop for live updates""" - if self.request.content["scan_type"] == "close_scan_def": - self.wait_for_scan_item_to_finish() - self.close_table() - return - self.wait_for_request_acceptance() self.update_scan_item(timeout=15) self.wait_for_scan_to_start() @@ -396,9 +391,6 @@ def process_request(self): def run(self): """run the live updates""" - if self.request.content["scan_type"] == "open_scan_def": - self.wait_for_request_acceptance() - return self.process_request() self.wait_for_scan_item_to_finish() if self._print_table_data: diff --git a/bec_ipython_client/demo.py b/bec_ipython_client/demo.py index ab802ce90..39f11f4e1 100644 --- a/bec_ipython_client/demo.py +++ b/bec_ipython_client/demo.py @@ -153,13 +153,6 @@ # scans.close_interactive_scan(md={"scan_def_id": scan_def_id}) -# @scan_def -# def new_scan(): -# for ii in range(10): -# scans.umv(dev.samx, ii * 10) -# scans.fermat_scan(dev.samx, -5, 5, dev.samy, -5, 5, step=1, exp_time=0.02, relative=True) - - # for ii in range(10): # scans.umv(dev.samx, ii * 10) # # scans.grid_scan(dev.samx, -5, 5, 5, dev.samy, -5, 5, 10, exp_time=0.02, relative=True) @@ -180,17 +173,9 @@ # # scans.line_scan(dev.samx, -8, 8, steps=200, exp_time=0.1, relative=True) -# with scans.scan_def: -# scan_with_decorator() # with scans.dataset_id_on_hold: # scans.line_scan(dev.samx, -5, 5, steps=10, exp_time=0.1, relative=True) # scans.line_scan(dev.samx, -8, 8, steps=10, exp_time=0.1, relative=True) - -# scan_def_id = str(uuid.uuid4()) -# scans.open_scan_def(md={"scan_def_id": scan_def_id}) -# scans.line_scan(dev.samx, -5, 5, steps=10, exp_time=0.1, md={"scan_def_id": scan_def_id}) -# scans.line_scan(dev.samx, -8, 8, steps=10, exp_time=0.1, md={"scan_def_id": scan_def_id}) -# scans.close_scan_def(md={"scan_def_id": scan_def_id}) # for ii in range(10): # scans.grid_scan(dev.samx, -5, 5, 10, dev.samy, -5, 5, 10, exp_time=0.01) diff --git a/bec_ipython_client/tests/end-2-end/test_scans_e2e.py b/bec_ipython_client/tests/end-2-end/test_scans_e2e.py index 54c22b5e5..9f04d299a 100644 --- a/bec_ipython_client/tests/end-2-end/test_scans_e2e.py +++ b/bec_ipython_client/tests/end-2-end/test_scans_e2e.py @@ -509,58 +509,10 @@ def test_file_writer(bec_ipython_client_fixture): dev.samy.velocity.set(100).wait() -@pytest.mark.timeout(100) -def test_scan_def_callback(capsys, bec_ipython_client_fixture): - bec = bec_ipython_client_fixture - bec.metadata.update({"unit_test": "test_scan_def_callback"}) - scans = bec.scans - dev = bec.device_manager.devices - scan_number = bec.queue.next_scan_number - with scans.scan_def: - scans.line_scan(dev.samx, -5, 5, steps=10, exp_time=0.1, relative=False) - scans.umv(dev.samy, 5, relative=False) - current_pos_samy = dev.samy.read(cached=True)["samy"]["value"] - captured = capsys.readouterr() - assert f"Starting scan {scan_number}" in captured.out - ref_out_samy = f"━━━━━━━━━━━━━━━ {current_pos_samy:10.2f} / 5.00 / 100 %" - assert ref_out_samy in captured.out - scans.line_scan(dev.samx, -5, 5, steps=10, exp_time=0.1, relative=False) - captured = capsys.readouterr() - assert f"Scan {scan_number} finished." in captured.out - - -@pytest.mark.timeout(100) -def test_scan_def(bec_ipython_client_fixture): - bec = bec_ipython_client_fixture - bec.metadata.update({"unit_test": "test_scan_def"}) - scans = bec.scans - dev = bec.device_manager.devices - scan_number = bec.queue.next_scan_number - with scans.scan_def: - scans.line_scan(dev.samx, -5, 5, steps=10, exp_time=0.1, relative=False) - scans.umv(dev.samy, 5, relative=False) - scans.line_scan(dev.samx, -5, 5, steps=10, exp_time=0.1, relative=False) - scans.mv(dev.samx, 0, relative=False) - - assert scan_number == bec.queue.next_scan_number - 1 - - scan_number = bec.queue.next_scan_number - - @scans.scan_def - def scan_def_with_decorator(): - scans.line_scan(dev.samx, -5, 5, steps=10, exp_time=0.1, relative=False) - scans.umv(dev.samy, 5, relative=False) - scans.line_scan(dev.samx, -5, 5, steps=10, exp_time=0.1, relative=False) - scans.mv(dev.samx, 0, relative=False) - - scan_def_with_decorator() - assert scan_number == bec.queue.next_scan_number - 1 - - @pytest.mark.timeout(100) def test_group_def(bec_ipython_client_fixture): bec = bec_ipython_client_fixture - bec.metadata.update({"unit_test": "test_scan_def"}) + bec.metadata.update({"unit_test": "test_group_def"}) scans = bec.scans dev = bec.device_manager.devices scan_number = bec.queue.next_scan_number diff --git a/bec_lib/bec_lib/client.py b/bec_lib/bec_lib/client.py index cf9ac2415..1c53500dd 100644 --- a/bec_lib/bec_lib/client.py +++ b/bec_lib/bec_lib/client.py @@ -277,7 +277,6 @@ def _load_scans(self): else: self.scans._refresh_available_scans() builtins.__dict__["scans"] = self.scans - self.scans_namespace.scan_def = self.scans.scan_def def load_high_level_interface(self, module_name: str) -> None: """Load a high level interface module. diff --git a/bec_lib/bec_lib/scans.py b/bec_lib/bec_lib/scans.py index 528a48bd0..510288c76 100644 --- a/bec_lib/bec_lib/scans.py +++ b/bec_lib/bec_lib/scans.py @@ -181,7 +181,6 @@ def __init__(self, parent): self._scan_def_id = None self._interactive_scan = False self._scan_group_ctx = ScanGroup(parent=self) - self._scan_def_ctx = ScanDef(parent=self) self._hide_report = None self._hide_report_ctx = HideReport(parent=self) self._dataset_id_on_hold = None @@ -367,11 +366,6 @@ def scan_group(self): """Context manager / decorator for defining scan groups""" return self._scan_group_ctx - @property - def scan_def(self): - """Context manager / decorator for defining new scans""" - return self._scan_def_ctx - @property def hide_report(self): """Context manager / decorator for hiding the report""" @@ -408,27 +402,6 @@ def __exit__(self, *exc): self.parent._scan_group = None -class ScanDef(ContextDecorator): - """ScanDef is a ContextDecorator for defining a new scan""" - - def __init__(self, parent: Scans = None) -> None: - super().__init__() - self.parent = parent - - def __enter__(self): - if self.parent._scan_def_id is not None: - raise ScanAbortion("Nested scan definitions currently not supported.") - scan_def_id = str(uuid.uuid4()) - self.parent._scan_def_id = scan_def_id - self.parent.open_scan_def() - return self - - def __exit__(self, *exc): - if exc[0] is None: - self.parent.close_scan_def() - self.parent._scan_def_id = None - - class HideReport(ContextDecorator): """HideReport is a ContextDecorator for hiding the report""" diff --git a/bec_lib/bec_lib/tests/utils.py b/bec_lib/bec_lib/tests/utils.py index 29144401a..733f447cd 100644 --- a/bec_lib/bec_lib/tests/utils.py +++ b/bec_lib/bec_lib/tests/utils.py @@ -60,12 +60,6 @@ class ScansMock(Scans): def _import_scans(self): pass - def open_scan_def(self, *args, device_manager=None, monitored: list | None = None, **kwargs): - pass - - def close_scan_def(self): - pass - def close_scan_group(self): pass @@ -139,8 +133,6 @@ def _load_scans(self): mv=self.scans.mv, umv=self.scans.umv, fermat_scan=self.scans.fermat_scan, - open_scan_def=self.scans.open_scan_def, - close_scan_def=self.scans.close_scan_def, close_scan_group=self.scans.close_scan_group, ) diff --git a/bec_lib/tests/test_scan_context.py b/bec_lib/tests/test_scan_context.py index dff90769f..0e62835d0 100644 --- a/bec_lib/tests/test_scan_context.py +++ b/bec_lib/tests/test_scan_context.py @@ -10,7 +10,6 @@ FileWriter, HideReport, Metadata, - ScanDef, ScanExport, ScanGroup, Scans, @@ -95,16 +94,6 @@ def test_dataset_id_on_hold_cleanup_on_error(bec_client_mock): assert client.scans._dataset_id_on_hold is None -def test_scan_def_cm(bec_client_mock): - client = bec_client_mock - client.scans._scan_def_id = None - scan_def_id_cm = ScanDef(client.scans) - with scan_def_id_cm: - assert isinstance(client.scans._scan_def_id, str) - - assert client.scans._scan_def_id is None - - def test_scan_group_cm(bec_client_mock): client = bec_client_mock client.scans._scan_group = None diff --git a/bec_server/bec_server/scan_server/scans/legacy_scans.py b/bec_server/bec_server/scan_server/scans/legacy_scans.py index c20c5293d..c2492cb2c 100644 --- a/bec_server/bec_server/scan_server/scans/legacy_scans.py +++ b/bec_server/bec_server/scan_server/scans/legacy_scans.py @@ -790,20 +790,6 @@ class ScanStub(RequestBase): pass -class OpenScanDef(ScanStub): - scan_name = "open_scan_def" - - def run(self): - yield from self.stubs.open_scan_def() - - -class CloseScanDef(ScanStub): - scan_name = "close_scan_def" - - def run(self): - yield from self.stubs.close_scan_def() - - class CloseScanGroup(ScanStub): scan_name = "close_scan_group"