From 855f9a8412e9c0d8b02d131ece533b4d85882b36 Mon Sep 17 00:00:00 2001 From: wakonig_k Date: Tue, 21 May 2024 12:48:05 +0200 Subject: [PATCH] fix: renamed table_wait to scan_progress --- .../callbacks/ipython_live_updates.py | 4 ++-- .../bec_ipython_client/callbacks/live_table.py | 6 ++++-- .../client_tests/test_ipython_live_updates.py | 4 ++-- .../tests/client_tests/test_live_table.py | 16 ++++++++-------- bec_server/bec_server/scan_server/scan_worker.py | 4 ++-- .../tests/tests_scan_server/test_scan_worker.py | 2 +- 6 files changed, 19 insertions(+), 17 deletions(-) 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 8ff1973c..527ffa9f 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 @@ -46,7 +46,7 @@ class IPythonLiveUpdates: """ scan_type = self._active_request.content["scan_type"] if scan_type in ["open_scan_def", "close_scan_def"]: - self._process_instruction({"table_wait": 0}) + self._process_instruction({"scan_progress": 0}) return if scan_type == "close_scan_group": return @@ -78,7 +78,7 @@ class IPythonLiveUpdates: request=self._active_request, callbacks=self._user_callback, ).run() - elif scan_report_type == "table_wait": + elif scan_report_type == "scan_progress": LiveUpdatesTable( self.client, report_instruction=instr, 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 201b1719..fb0dd554 100644 --- a/bec_ipython_client/bec_ipython_client/callbacks/live_table.py +++ b/bec_ipython_client/bec_ipython_client/callbacks/live_table.py @@ -39,7 +39,7 @@ class LiveUpdatesTable(LiveUpdatesBase): """ MAX_DEVICES = 10 - REPORT_TYPE = "table_wait" + REPORT_TYPE = "scan_progress" def __init__( self, @@ -60,7 +60,9 @@ class LiveUpdatesTable(LiveUpdatesBase): self.table = None self.__print_table_data = None self._print_table_data = ( - print_table_data if print_table_data is not None else self.REPORT_TYPE == "table_wait" + print_table_data + if print_table_data is not None + else self.REPORT_TYPE == "scan_progress" ) def wait_for_scan_to_start(self): diff --git a/bec_ipython_client/tests/client_tests/test_ipython_live_updates.py b/bec_ipython_client/tests/client_tests/test_ipython_live_updates.py index d1bf82a5..2d92fe54 100644 --- a/bec_ipython_client/tests/client_tests/test_ipython_live_updates.py +++ b/bec_ipython_client/tests/client_tests/test_ipython_live_updates.py @@ -153,7 +153,7 @@ def test_live_updates_process_queue_without_queue_number(bec_client_mock): # with mock.patch( # "bec_client_mock.callbacks.ipython_live_updates.LiveUpdatesTable", new_callable=mock.Co # ) as table: -# live_updates._process_instruction({"table_wait": 10}) +# live_updates._process_instruction({"scan_progress": 10}) # table.assert_called_once_with( -# client, report_instructions={"table_wait": 10}, request=request_msg, callbacks=[] +# client, report_instructions={"scan_progress": 10}, request=request_msg, callbacks=[] # ) diff --git a/bec_ipython_client/tests/client_tests/test_live_table.py b/bec_ipython_client/tests/client_tests/test_live_table.py index d0ab0af9..5717ffd2 100644 --- a/bec_ipython_client/tests/client_tests/test_live_table.py +++ b/bec_ipython_client/tests/client_tests/test_live_table.py @@ -79,7 +79,7 @@ def test_get_devices_from_scan_data(bec_client_mock, request_msg, scan_report_de data = messages.ScanMessage( point_id=0, scan_id="", data={}, metadata={"scan_report_devices": scan_report_devices} ) - live_update = LiveUpdatesTable(client, {"table_wait": 10}, request_msg) + live_update = LiveUpdatesTable(client, {"scan_progress": 10}, request_msg) devices = live_update.get_devices_from_scan_data(data) assert devices[0 : len(scan_report_devices)] == scan_report_devices @@ -92,7 +92,7 @@ def test_wait_for_request_acceptance(client_with_grid_scan): ) client.queue.request_storage.update_with_request(request_msg) client.queue.request_storage.update_with_response(response_msg) - live_update = LiveUpdatesTable(client, {"table_wait": 10}, request_msg) + live_update = LiveUpdatesTable(client, {"scan_progress": 10}, request_msg) with mock.patch.object(client.queue.queue_storage, "find_queue_item_by_requestID"): live_update.wait_for_request_acceptance() @@ -110,7 +110,7 @@ def test_print_table_data(client_with_grid_scan): ) client.queue.request_storage.update_with_request(request_msg) client.queue.request_storage.update_with_response(response_msg) - live_update = LiveUpdatesTable(client, {"table_wait": 10}, request_msg) + live_update = LiveUpdatesTable(client, {"scan_progress": 10}, request_msg) live_update.point_data = messages.ScanMessage( point_id=0, scan_id="", @@ -130,7 +130,7 @@ def test_print_table_data_lamni_flyer(client_with_grid_scan): ) client.queue.request_storage.update_with_request(request_msg) client.queue.request_storage.update_with_response(response_msg) - live_update = LiveUpdatesTable(client, {"table_wait": 10}, request_msg) + live_update = LiveUpdatesTable(client, {"scan_progress": 10}, request_msg) live_update.point_data = messages.ScanMessage( point_id=0, scan_id="", @@ -150,7 +150,7 @@ def test_print_table_data_hinted_value(client_with_grid_scan): ) client.queue.request_storage.update_with_request(request_msg) client.queue.request_storage.update_with_response(response_msg) - live_update = LiveUpdatesTable(client, {"table_wait": 10}, request_msg) + live_update = LiveUpdatesTable(client, {"scan_progress": 10}, request_msg) client.device_manager.devices["samx"]._info["hints"] = {"fields": ["samx_hint"]} client.device_manager.devices["samx"].precision = 3 live_update.point_data = messages.ScanMessage( @@ -178,7 +178,7 @@ def test_print_table_data_hinted_value_with_precision(client_with_grid_scan): ) client.queue.request_storage.update_with_request(request_msg) client.queue.request_storage.update_with_response(response_msg) - live_update = LiveUpdatesTable(client, {"table_wait": 10}, request_msg) + live_update = LiveUpdatesTable(client, {"scan_progress": 10}, request_msg) client.device_manager.devices["samx"]._info["hints"] = {"fields": ["samx_hint"]} client.device_manager.devices["samx"].precision = 2 live_update.point_data = messages.ScanMessage( @@ -223,7 +223,7 @@ def test_print_table_data_variants(client_with_grid_scan, value, expected): ) client.queue.request_storage.update_with_request(request_msg) client.queue.request_storage.update_with_response(response_msg) - live_update = LiveUpdatesTable(client, {"table_wait": 10}, request_msg) + live_update = LiveUpdatesTable(client, {"scan_progress": 10}, request_msg) live_update.point_data = messages.ScanMessage( point_id=0, scan_id="", @@ -254,7 +254,7 @@ def test_print_client_msgs(client_with_grid_scan): with mock.patch.object( client.queue.request_storage.scan_manager.queue_storage, "find_queue_item_by_requestID" ): - live_update = LiveUpdatesTable(client, {"table_wait": 10}, request_msg) + live_update = LiveUpdatesTable(client, {"scan_progress": 10}, request_msg) live_update.wait_for_request_acceptance() result = StringIO() with redirect_stdout(result): diff --git a/bec_server/bec_server/scan_server/scan_worker.py b/bec_server/bec_server/scan_server/scan_worker.py index 6c0f6b60..37975bca 100644 --- a/bec_server/bec_server/scan_server/scan_worker.py +++ b/bec_server/bec_server/scan_server/scan_worker.py @@ -74,11 +74,11 @@ class ScanWorker(threading.Thread): self._initialize_scan_info(active_rb, instr, num_points) - # only append the table_wait if the scan is not using device_progress + # only append the scan_progress if the scan is not using device_progress if not self.scan_report_instructions or not self.scan_report_instructions[-1].get( "device_progress" ): - self.scan_report_instructions.append({"table_wait": num_points}) + self.scan_report_instructions.append({"scan_progress": num_points}) self.current_instruction_queue_item.parent.queue_manager.send_queue_status() self._send_scan_status("open") diff --git a/bec_server/tests/tests_scan_server/test_scan_worker.py b/bec_server/tests/tests_scan_server/test_scan_worker.py index e2fcfe39..213ca062 100644 --- a/bec_server/tests/tests_scan_server/test_scan_worker.py +++ b/bec_server/tests/tests_scan_server/test_scan_worker.py @@ -1072,7 +1072,7 @@ def test_open_scan(scan_worker_mock, instr, corr_num_points, scan_id): assert worker.scan_motors == ["bpm4i"] init_mock.assert_called_once_with(active_rb, instr, corr_num_points) assert active_rb.scan_report_instructions == [ - {"table_wait": corr_num_points} + {"scan_progress": corr_num_points} ] queue_status_mock.assert_called_once() send_mock.assert_called_once_with("open")