fix: renamed table_wait to scan_progress

This commit is contained in:
wakonig_k 2024-05-21 12:48:05 +02:00
parent d344e85137
commit 855f9a8412
6 changed files with 19 additions and 17 deletions

View File

@ -46,7 +46,7 @@ class IPythonLiveUpdates:
""" """
scan_type = self._active_request.content["scan_type"] scan_type = self._active_request.content["scan_type"]
if scan_type in ["open_scan_def", "close_scan_def"]: if scan_type in ["open_scan_def", "close_scan_def"]:
self._process_instruction({"table_wait": 0}) self._process_instruction({"scan_progress": 0})
return return
if scan_type == "close_scan_group": if scan_type == "close_scan_group":
return return
@ -78,7 +78,7 @@ class IPythonLiveUpdates:
request=self._active_request, request=self._active_request,
callbacks=self._user_callback, callbacks=self._user_callback,
).run() ).run()
elif scan_report_type == "table_wait": elif scan_report_type == "scan_progress":
LiveUpdatesTable( LiveUpdatesTable(
self.client, self.client,
report_instruction=instr, report_instruction=instr,

View File

@ -39,7 +39,7 @@ class LiveUpdatesTable(LiveUpdatesBase):
""" """
MAX_DEVICES = 10 MAX_DEVICES = 10
REPORT_TYPE = "table_wait" REPORT_TYPE = "scan_progress"
def __init__( def __init__(
self, self,
@ -60,7 +60,9 @@ class LiveUpdatesTable(LiveUpdatesBase):
self.table = None self.table = None
self.__print_table_data = None self.__print_table_data = None
self._print_table_data = ( 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): def wait_for_scan_to_start(self):

View File

@ -153,7 +153,7 @@ def test_live_updates_process_queue_without_queue_number(bec_client_mock):
# with mock.patch( # with mock.patch(
# "bec_client_mock.callbacks.ipython_live_updates.LiveUpdatesTable", new_callable=mock.Co # "bec_client_mock.callbacks.ipython_live_updates.LiveUpdatesTable", new_callable=mock.Co
# ) as table: # ) as table:
# live_updates._process_instruction({"table_wait": 10}) # live_updates._process_instruction({"scan_progress": 10})
# table.assert_called_once_with( # 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=[]
# ) # )

View File

@ -79,7 +79,7 @@ def test_get_devices_from_scan_data(bec_client_mock, request_msg, scan_report_de
data = messages.ScanMessage( data = messages.ScanMessage(
point_id=0, scan_id="", data={}, metadata={"scan_report_devices": scan_report_devices} 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) devices = live_update.get_devices_from_scan_data(data)
assert devices[0 : len(scan_report_devices)] == scan_report_devices 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_request(request_msg)
client.queue.request_storage.update_with_response(response_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"): with mock.patch.object(client.queue.queue_storage, "find_queue_item_by_requestID"):
live_update.wait_for_request_acceptance() 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_request(request_msg)
client.queue.request_storage.update_with_response(response_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( live_update.point_data = messages.ScanMessage(
point_id=0, point_id=0,
scan_id="", 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_request(request_msg)
client.queue.request_storage.update_with_response(response_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( live_update.point_data = messages.ScanMessage(
point_id=0, point_id=0,
scan_id="", 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_request(request_msg)
client.queue.request_storage.update_with_response(response_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"]._info["hints"] = {"fields": ["samx_hint"]}
client.device_manager.devices["samx"].precision = 3 client.device_manager.devices["samx"].precision = 3
live_update.point_data = messages.ScanMessage( 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_request(request_msg)
client.queue.request_storage.update_with_response(response_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"]._info["hints"] = {"fields": ["samx_hint"]}
client.device_manager.devices["samx"].precision = 2 client.device_manager.devices["samx"].precision = 2
live_update.point_data = messages.ScanMessage( 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_request(request_msg)
client.queue.request_storage.update_with_response(response_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( live_update.point_data = messages.ScanMessage(
point_id=0, point_id=0,
scan_id="", scan_id="",
@ -254,7 +254,7 @@ def test_print_client_msgs(client_with_grid_scan):
with mock.patch.object( with mock.patch.object(
client.queue.request_storage.scan_manager.queue_storage, "find_queue_item_by_requestID" 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() live_update.wait_for_request_acceptance()
result = StringIO() result = StringIO()
with redirect_stdout(result): with redirect_stdout(result):

View File

@ -74,11 +74,11 @@ class ScanWorker(threading.Thread):
self._initialize_scan_info(active_rb, instr, num_points) 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( if not self.scan_report_instructions or not self.scan_report_instructions[-1].get(
"device_progress" "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.current_instruction_queue_item.parent.queue_manager.send_queue_status()
self._send_scan_status("open") self._send_scan_status("open")

View File

@ -1072,7 +1072,7 @@ def test_open_scan(scan_worker_mock, instr, corr_num_points, scan_id):
assert worker.scan_motors == ["bpm4i"] assert worker.scan_motors == ["bpm4i"]
init_mock.assert_called_once_with(active_rb, instr, corr_num_points) init_mock.assert_called_once_with(active_rb, instr, corr_num_points)
assert active_rb.scan_report_instructions == [ assert active_rb.scan_report_instructions == [
{"table_wait": corr_num_points} {"scan_progress": corr_num_points}
] ]
queue_status_mock.assert_called_once() queue_status_mock.assert_called_once()
send_mock.assert_called_once_with("open") send_mock.assert_called_once_with("open")