From fdfb6db84be0d80b15b46d2f5e808a74cc057b20 Mon Sep 17 00:00:00 2001 From: appel_c Date: Thu, 6 Jun 2024 15:15:24 +0200 Subject: [PATCH] refactor: publish file location with successful and done --- csaxs_bec/devices/epics/eiger9m_csaxs.py | 2 +- csaxs_bec/devices/epics/falcon_csaxs.py | 2 +- csaxs_bec/devices/epics/pilatus_csaxs.py | 4 +++- tests/tests_devices/test_eiger9m_csaxs.py | 3 +-- tests/tests_devices/test_falcon_csaxs.py | 3 +-- tests/tests_devices/test_pilatus_csaxs.py | 13 ++----------- 6 files changed, 9 insertions(+), 18 deletions(-) diff --git a/csaxs_bec/devices/epics/eiger9m_csaxs.py b/csaxs_bec/devices/epics/eiger9m_csaxs.py index f7b407f..cf3e31d 100644 --- a/csaxs_bec/devices/epics/eiger9m_csaxs.py +++ b/csaxs_bec/devices/epics/eiger9m_csaxs.py @@ -118,7 +118,7 @@ class Eiger9MSetup(CustomDetectorMixin): """Prepare the detector for scan""" self.prepare_detector() self.prepare_data_backend() - self.publish_file_location(done=False) + self.publish_file_location(done=False, successful=False) self.arm_acquisition() def prepare_detector(self) -> None: diff --git a/csaxs_bec/devices/epics/falcon_csaxs.py b/csaxs_bec/devices/epics/falcon_csaxs.py index 0ab1018..962eb9f 100644 --- a/csaxs_bec/devices/epics/falcon_csaxs.py +++ b/csaxs_bec/devices/epics/falcon_csaxs.py @@ -162,7 +162,7 @@ class FalconSetup(CustomDetectorMixin): """Prepare detector and backend for acquisition""" self.prepare_detector() self.prepare_data_backend() - self.publish_file_location(done=False) + self.publish_file_location(done=False, successful=False) self.arm_acquisition() def prepare_detector(self) -> None: diff --git a/csaxs_bec/devices/epics/pilatus_csaxs.py b/csaxs_bec/devices/epics/pilatus_csaxs.py index b4f8d09..6a87369 100644 --- a/csaxs_bec/devices/epics/pilatus_csaxs.py +++ b/csaxs_bec/devices/epics/pilatus_csaxs.py @@ -103,7 +103,9 @@ class PilatusSetup(CustomDetectorMixin): """Stage the detector for scan""" self.prepare_detector() self.prepare_data_backend() - self.publish_file_location(done=False, metadata={"input_path": self.parent.filepath_raw}) + self.publish_file_location( + done=False, successful=False, metadata={"input_path": self.parent.filepath_raw} + ) def prepare_detector(self) -> None: """ diff --git a/tests/tests_devices/test_eiger9m_csaxs.py b/tests/tests_devices/test_eiger9m_csaxs.py index 04af331..6ea2eb2 100644 --- a/tests/tests_devices/test_eiger9m_csaxs.py +++ b/tests/tests_devices/test_eiger9m_csaxs.py @@ -239,7 +239,7 @@ def test_stage( ) assert mock_det.cam.num_frames.get() == 1 - mock_publish_file_location.assert_called_with(done=False) + mock_publish_file_location.assert_called_with(done=False, successful=False) assert mock_det.cam.acquire.get() == 1 @@ -345,7 +345,6 @@ def test_stop_detector_backend(mock_det): [ ({"filepath": "test.h5", "successful": True, "done": False, "scan_id": "123"}), ({"filepath": "test.h5", "successful": False, "done": True, "scan_id": "123"}), - ({"filepath": "test.h5", "successful": None, "done": True, "scan_id": "123"}), ], ) def test_publish_file_location(mock_det, scaninfo): diff --git a/tests/tests_devices/test_falcon_csaxs.py b/tests/tests_devices/test_falcon_csaxs.py index d6066fc..3f78198 100644 --- a/tests/tests_devices/test_falcon_csaxs.py +++ b/tests/tests_devices/test_falcon_csaxs.py @@ -147,7 +147,7 @@ def test_stage(mock_det, scaninfo): scaninfo["num_points"] * scaninfo["frames_per_trigger"] ) mock_prep_data_backend.assert_called_once() - mock_publish_file_location.assert_called_once_with(done=False) + mock_publish_file_location.assert_called_once_with(done=False, successful=False) mock_arm_acquisition.assert_called_once() @@ -193,7 +193,6 @@ def test_prepare_data_backend(mock_det, scaninfo): [ ({"filepath": "test.h5", "successful": True, "done": False, "scan_id": "123"}), ({"filepath": "test.h5", "successful": False, "done": True, "scan_id": "123"}), - ({"filepath": "test.h5", "successful": None, "done": True, "scan_id": "123"}), ], ) def test_publish_file_location(mock_det, scaninfo): diff --git a/tests/tests_devices/test_pilatus_csaxs.py b/tests/tests_devices/test_pilatus_csaxs.py index 663296d..8818e19 100644 --- a/tests/tests_devices/test_pilatus_csaxs.py +++ b/tests/tests_devices/test_pilatus_csaxs.py @@ -115,8 +115,8 @@ def test_stage(mock_det, scaninfo, stopped, expected_exception): ) assert mock_det.cam.num_frames.get() == 1 - mock_publish_file_location.assert_called_with( - done=False, metadata={"input_path": path} + mock_publish_file_location.assert_called_once_with( + done=False, successful=False, metadata={"input_path": path} ) @@ -159,15 +159,6 @@ def test_update_readout_time(mock_det, readout_time, expected_value): "scan_id": "123", } ), - ( - { - "filepath": "test.h5", - "filepath_raw": "test5_raw.h5", - "successful": None, - "done": True, - "scan_id": "123", - } - ), ], ) def test_publish_file_location(mock_det, scaninfo):