From 2df79ea1d562d56947a5066518e17b666bb2d3d5 Mon Sep 17 00:00:00 2001 From: Robert Tuck Date: Mon, 29 Apr 2024 14:11:57 +0100 Subject: [PATCH 1/2] (DiamondLightSource/hyperion#1293) Remove sample_barcode from ispyb callbacks and from read_hardware_for_setup() --- .../device_setup_plans/read_hardware_for_setup.py | 1 - .../callbacks/common/ispyb_mapping.py | 6 +----- .../callbacks/ispyb_callback_base.py | 10 +--------- .../external_interaction/test_ispyb_dev_connection.py | 2 -- .../good_test_robot_load_params.json | 3 +-- tests/unit_tests/experiment_plans/conftest.py | 1 - .../experiment_plans/test_flyscan_xray_centre_plan.py | 2 -- .../test_panda_flyscan_xray_centre_plan.py | 3 --- .../external_interaction/callbacks/conftest.py | 1 - .../callbacks/rotation/test_ispyb_callback.py | 1 - .../callbacks/xray_centre/test_ispyb_callback.py | 1 - tests/unit_tests/parameters/test_parameter_model.py | 2 -- 12 files changed, 3 insertions(+), 30 deletions(-) diff --git a/src/hyperion/device_setup_plans/read_hardware_for_setup.py b/src/hyperion/device_setup_plans/read_hardware_for_setup.py index ca9308394..23ace4ddb 100644 --- a/src/hyperion/device_setup_plans/read_hardware_for_setup.py +++ b/src/hyperion/device_setup_plans/read_hardware_for_setup.py @@ -31,7 +31,6 @@ def read_hardware_for_ispyb_pre_collection( yield from bps.read(s4_slit_gaps.xgap) yield from bps.read(s4_slit_gaps.ygap) yield from bps.read(aperture_scatterguard) - yield from bps.read(robot.barcode) yield from bps.save() diff --git a/src/hyperion/external_interaction/callbacks/common/ispyb_mapping.py b/src/hyperion/external_interaction/callbacks/common/ispyb_mapping.py index 73b9255a5..377236657 100644 --- a/src/hyperion/external_interaction/callbacks/common/ispyb_mapping.py +++ b/src/hyperion/external_interaction/callbacks/common/ispyb_mapping.py @@ -23,16 +23,12 @@ def populate_data_collection_group( - experiment_type: str, - detector_params: DetectorParams, - ispyb_params: IspybParams, - sample_barcode: Optional[str] = None, + experiment_type: str, detector_params: DetectorParams, ispyb_params: IspybParams ): dcg_info = DataCollectionGroupInfo( visit_string=get_visit_string(ispyb_params, detector_params), experiment_type=experiment_type, sample_id=ispyb_params.sample_id, - sample_barcode=sample_barcode, ) return dcg_info diff --git a/src/hyperion/external_interaction/callbacks/ispyb_callback_base.py b/src/hyperion/external_interaction/callbacks/ispyb_callback_base.py index 630595098..7e92b4fcd 100644 --- a/src/hyperion/external_interaction/callbacks/ispyb_callback_base.py +++ b/src/hyperion/external_interaction/callbacks/ispyb_callback_base.py @@ -55,7 +55,6 @@ def __init__( ISPYB_LOGGER.debug("Initialising ISPyB callback") super().__init__(log=ISPYB_LOGGER, emit=emit) self._oav_snapshot_event_idx: int = 0 - self._sample_barcode: Optional[str] = None self.params: GridscanInternalParameters | RotationInternalParameters | None = ( None ) @@ -77,7 +76,6 @@ def __init__( def activity_gated_start(self, doc: RunStart): self._oav_snapshot_event_idx = 0 - self._sample_barcode = None return self._tag_doc(doc) def activity_gated_descriptor(self, doc: EventDescriptor): @@ -131,7 +129,6 @@ def _handle_ispyb_hardware_read( slitgap_horizontal=doc["data"]["s4_slit_gaps_xgap"], slitgap_vertical=doc["data"]["s4_slit_gaps_ygap"], ) - self._sample_barcode = doc["data"]["robot-barcode"] scan_data_infos = self.populate_info_for_update( hwscan_data_collection_info, self.params ) @@ -142,7 +139,6 @@ def _handle_ispyb_hardware_read( self.ispyb.experiment_type, self.params.hyperion_params.detector_params, self.params.hyperion_params.ispyb_params, - self._sample_barcode, ) return data_collection_group_info, scan_data_infos @@ -210,16 +206,12 @@ def _handle_ispyb_transmission_flux_read(self, doc) -> Sequence[ScanDataInfo]: return scan_data_infos def update_deposition( - self, - params, - scan_data_infos: Sequence[ScanDataInfo], - sample_barcode: Optional[str], + self, params, scan_data_infos: Sequence[ScanDataInfo] ) -> IspybIds: data_collection_group_info = populate_data_collection_group( self.ispyb.experiment_type, params.hyperion_params.detector_params, params.hyperion_params.ispyb_params, - sample_barcode, ) return self.ispyb.update_deposition( diff --git a/tests/system_tests/external_interaction/test_ispyb_dev_connection.py b/tests/system_tests/external_interaction/test_ispyb_dev_connection.py index b923f96b0..071b07292 100644 --- a/tests/system_tests/external_interaction/test_ispyb_dev_connection.py +++ b/tests/system_tests/external_interaction/test_ispyb_dev_connection.py @@ -893,5 +893,3 @@ def test_ispyb_deposition_in_rotation_plan( fetch_datacollection_attribute(dcid, "slitGapHorizontal") == test_slit_gap_horiz ) assert fetch_datacollection_attribute(dcid, "slitGapVertical") == test_slit_gap_vert - # TODO Can't test barcode as need BLSample which needs Dewar, Shipping, Container entries for the - # upsert stored proc to use it. diff --git a/tests/test_data/parameter_json_files/good_test_robot_load_params.json b/tests/test_data/parameter_json_files/good_test_robot_load_params.json index 45fc64c57..206931f51 100644 --- a/tests/test_data/parameter_json_files/good_test_robot_load_params.json +++ b/tests/test_data/parameter_json_files/good_test_robot_load_params.json @@ -24,8 +24,7 @@ "focal_spot_size_x": 0.0, "focal_spot_size_y": 0.0, "comment": "Descriptive comment.", - "sample_id": 12345, - "sample_barcode": null + "sample_id": 12345 } }, "experiment_params": { diff --git a/tests/unit_tests/experiment_plans/conftest.py b/tests/unit_tests/experiment_plans/conftest.py index 7926b8caf..14d77e80d 100644 --- a/tests/unit_tests/experiment_plans/conftest.py +++ b/tests/unit_tests/experiment_plans/conftest.py @@ -47,7 +47,6 @@ def make_event_doc(data, descriptor="abc123") -> Event: "synchrotron-synchrotron_mode": SynchrotronMode.USER, "s4_slit_gaps_xgap": 0, "s4_slit_gaps_ygap": 0, - "robot-barcode": "BARCODE", } BASIC_POST_SETUP_DOC = { diff --git a/tests/unit_tests/experiment_plans/test_flyscan_xray_centre_plan.py b/tests/unit_tests/experiment_plans/test_flyscan_xray_centre_plan.py index bc160abf7..694efa25b 100644 --- a/tests/unit_tests/experiment_plans/test_flyscan_xray_centre_plan.py +++ b/tests/unit_tests/experiment_plans/test_flyscan_xray_centre_plan.py @@ -214,7 +214,6 @@ def test_read_hardware_for_ispyb_updates_from_ophyd_devices( fake_fgs_composite.aperture_scatterguard.set( fake_fgs_composite.aperture_scatterguard.aperture_positions.LARGE # type: ignore ) - set_sim_value(fake_fgs_composite.robot.barcode.bare_signal, ["BARCODE"]) test_ispyb_callback = PlanReactiveCallback(ISPYB_LOGGER) test_ispyb_callback.active = True @@ -253,7 +252,6 @@ def test_read_hardware_for_ispyb_updates_from_ophyd_devices( "synchrotron-synchrotron_mode": synchrotron_test_value.value, "s4_slit_gaps_xgap": xgap_test_value, "s4_slit_gaps_ygap": ygap_test_value, - "robot-barcode": "BARCODE", }, ) assert_event( diff --git a/tests/unit_tests/experiment_plans/test_panda_flyscan_xray_centre_plan.py b/tests/unit_tests/experiment_plans/test_panda_flyscan_xray_centre_plan.py index 9cebfa132..3d793446e 100644 --- a/tests/unit_tests/experiment_plans/test_panda_flyscan_xray_centre_plan.py +++ b/tests/unit_tests/experiment_plans/test_panda_flyscan_xray_centre_plan.py @@ -161,8 +161,6 @@ def test_read_hardware_for_ispyb_updates_from_ophyd_devices( flux_test_value = 10.0 fake_fgs_composite.flux.flux_reading.sim_put(flux_test_value) # type: ignore - set_sim_value(fake_fgs_composite.robot.barcode.bare_signal, ["BARCODE"]) - test_ispyb_callback = PlanReactiveCallback(ISPYB_LOGGER) test_ispyb_callback.active = True with patch.multiple( @@ -199,7 +197,6 @@ def test_read_hardware_for_ispyb_updates_from_ophyd_devices( "synchrotron-synchrotron_mode": synchrotron_test_value.value, "s4_slit_gaps_xgap": xgap_test_value, "s4_slit_gaps_ygap": ygap_test_value, - "robot-barcode": "BARCODE", }, ) assert_event( diff --git a/tests/unit_tests/external_interaction/callbacks/conftest.py b/tests/unit_tests/external_interaction/callbacks/conftest.py index 358b76b9a..28256c5d0 100644 --- a/tests/unit_tests/external_interaction/callbacks/conftest.py +++ b/tests/unit_tests/external_interaction/callbacks/conftest.py @@ -196,7 +196,6 @@ class TestData: "s4_slit_gaps_ygap": 0.2345, "synchrotron-synchrotron_mode": SynchrotronMode.USER, "undulator_current_gap": 1.234, - "robot-barcode": "BARCODE", }, "timestamps": {"det1": 1666604299.8220396, "det2": 1666604299.8235943}, "seq_num": 1, diff --git a/tests/unit_tests/external_interaction/callbacks/rotation/test_ispyb_callback.py b/tests/unit_tests/external_interaction/callbacks/rotation/test_ispyb_callback.py index bbf79e6ce..a5f8ad260 100644 --- a/tests/unit_tests/external_interaction/callbacks/rotation/test_ispyb_callback.py +++ b/tests/unit_tests/external_interaction/callbacks/rotation/test_ispyb_callback.py @@ -107,7 +107,6 @@ def test_hardware_read_events( "parentid": TEST_SESSION_ID, "experimenttype": "SAD", "sampleid": TEST_SAMPLE_ID, - "sample_barcode": "BARCODE", }, ) assert_upsert_call_with( diff --git a/tests/unit_tests/external_interaction/callbacks/xray_centre/test_ispyb_callback.py b/tests/unit_tests/external_interaction/callbacks/xray_centre/test_ispyb_callback.py index 474c6318d..aeb0544e7 100644 --- a/tests/unit_tests/external_interaction/callbacks/xray_centre/test_ispyb_callback.py +++ b/tests/unit_tests/external_interaction/callbacks/xray_centre/test_ispyb_callback.py @@ -142,7 +142,6 @@ def test_hardware_read_event_3d(self, mock_ispyb_conn): "parentid": TEST_SESSION_ID, "experimenttype": "Mesh3D", "sampleid": TEST_SAMPLE_ID, - "sample_barcode": "BARCODE", # deferred }, ) assert_upsert_call_with( diff --git a/tests/unit_tests/parameters/test_parameter_model.py b/tests/unit_tests/parameters/test_parameter_model.py index a86ee8a03..ba0be3c84 100644 --- a/tests/unit_tests/parameters/test_parameter_model.py +++ b/tests/unit_tests/parameters/test_parameter_model.py @@ -221,7 +221,6 @@ def test_pin_then_xray(self): "undulator_gap": 0.5, "microns_per_pixel_x": self.microns_per_pixel_x, "microns_per_pixel_y": self.microns_per_pixel_y, - "sample_barcode": "", "position": self.position, "beam_size_x": self.beam_size_x, "beam_size_y": self.beam_size_y, @@ -313,7 +312,6 @@ def test_rotation_new_params(self): "undulator_gap": 0.5, "microns_per_pixel_x": self.microns_per_pixel_x, "microns_per_pixel_y": self.microns_per_pixel_y, - "sample_barcode": "", "position": self.position, "beam_size_x": self.beam_size_x, "beam_size_y": self.beam_size_y, From 0a0ceee0c7713a3f74dcac2e5e7cc292a6970879 Mon Sep 17 00:00:00 2001 From: Robert Tuck Date: Mon, 29 Apr 2024 15:12:22 +0100 Subject: [PATCH 2/2] (DiamondLightSource/hyperion#1293) ispyb callback event handlers no longer update the DataCollectionGroup --- .../callbacks/ispyb_callback_base.py | 45 +++---------------- .../external_interaction/ispyb/ispyb_store.py | 5 +-- .../test_ispyb_dev_connection.py | 8 +--- .../callbacks/rotation/test_ispyb_callback.py | 11 +---- .../xray_centre/test_ispyb_callback.py | 11 +---- .../ispyb/test_gridscan_ispyb_store_3d.py | 40 ++++++----------- .../ispyb/test_rotation_ispyb_store.py | 28 +----------- 7 files changed, 27 insertions(+), 121 deletions(-) diff --git a/src/hyperion/external_interaction/callbacks/ispyb_callback_base.py b/src/hyperion/external_interaction/callbacks/ispyb_callback_base.py index 7e92b4fcd..5d1210530 100644 --- a/src/hyperion/external_interaction/callbacks/ispyb_callback_base.py +++ b/src/hyperion/external_interaction/callbacks/ispyb_callback_base.py @@ -6,9 +6,6 @@ from dodal.devices.synchrotron import SynchrotronMode -from hyperion.external_interaction.callbacks.common.ispyb_mapping import ( - populate_data_collection_group, -) from hyperion.external_interaction.callbacks.plan_reactive_callback import ( PlanReactiveCallback, ) @@ -17,7 +14,6 @@ ) from hyperion.external_interaction.ispyb.data_model import ( DataCollectionGridInfo, - DataCollectionGroupInfo, DataCollectionInfo, ScanDataInfo, ) @@ -96,27 +92,20 @@ def activity_gated_event(self, doc: Event) -> Event: "has no corresponding descriptor record" ) return doc - data_collection_group_info = None match event_descriptor.get("name"): case CONST.DESCRIPTORS.ISPYB_HARDWARE_READ: - data_collection_group_info, scan_data_infos = ( - self._handle_ispyb_hardware_read(doc) - ) + scan_data_infos = self._handle_ispyb_hardware_read(doc) case CONST.DESCRIPTORS.OAV_SNAPSHOT_TRIGGERED: scan_data_infos = self._handle_oav_snapshot_triggered(doc) case CONST.DESCRIPTORS.ISPYB_TRANSMISSION_FLUX_READ: scan_data_infos = self._handle_ispyb_transmission_flux_read(doc) case _: return self._tag_doc(doc) - self.ispyb_ids = self.ispyb.update_deposition( - self.ispyb_ids, data_collection_group_info, scan_data_infos - ) + self.ispyb_ids = self.ispyb.update_deposition(self.ispyb_ids, scan_data_infos) ISPYB_LOGGER.info(f"Recieved ISPYB IDs: {self.ispyb_ids}") return self._tag_doc(doc) - def _handle_ispyb_hardware_read( - self, doc - ) -> tuple[DataCollectionGroupInfo, Sequence[ScanDataInfo]]: + def _handle_ispyb_hardware_read(self, doc) -> Sequence[ScanDataInfo]: assert self.params, "Event handled before activity_gated_start received params" ISPYB_LOGGER.info("ISPyB handler received event from read hardware") assert isinstance( @@ -132,15 +121,8 @@ def _handle_ispyb_hardware_read( scan_data_infos = self.populate_info_for_update( hwscan_data_collection_info, self.params ) - ISPYB_LOGGER.info( - "Updating ispyb data collection and group after hardware read." - ) - data_collection_group_info = populate_data_collection_group( - self.ispyb.experiment_type, - self.params.hyperion_params.detector_params, - self.params.hyperion_params.ispyb_params, - ) - return data_collection_group_info, scan_data_infos + ISPYB_LOGGER.info("Updating ispyb data collection after hardware read.") + return scan_data_infos def _handle_oav_snapshot_triggered(self, doc) -> Sequence[ScanDataInfo]: assert self.ispyb_ids.data_collection_ids, "No current data collection" @@ -182,9 +164,7 @@ def _handle_oav_snapshot_triggered(self, doc) -> Sequence[ScanDataInfo]: data_collection_id=data_collection_id, data_collection_grid_info=data_collection_grid_info, ) - ISPYB_LOGGER.info( - "Updating ispyb data collection and group after oav snapshot." - ) + ISPYB_LOGGER.info("Updating ispyb data collection after oav snapshot.") self._oav_snapshot_event_idx += 1 return [scan_data_info] @@ -205,19 +185,6 @@ def _handle_ispyb_transmission_flux_read(self, doc) -> Sequence[ScanDataInfo]: ISPYB_LOGGER.info("Updating ispyb data collection after flux read.") return scan_data_infos - def update_deposition( - self, params, scan_data_infos: Sequence[ScanDataInfo] - ) -> IspybIds: - data_collection_group_info = populate_data_collection_group( - self.ispyb.experiment_type, - params.hyperion_params.detector_params, - params.hyperion_params.ispyb_params, - ) - - return self.ispyb.update_deposition( - self.ispyb_ids, data_collection_group_info, scan_data_infos - ) - @abstractmethod def populate_info_for_update( self, diff --git a/src/hyperion/external_interaction/ispyb/ispyb_store.py b/src/hyperion/external_interaction/ispyb/ispyb_store.py index 391a74fbb..80953f5ee 100755 --- a/src/hyperion/external_interaction/ispyb/ispyb_store.py +++ b/src/hyperion/external_interaction/ispyb/ispyb_store.py @@ -66,7 +66,6 @@ def begin_deposition( def update_deposition( self, ispyb_ids, - data_collection_group_info: Optional[DataCollectionGroupInfo], scan_data_infos: Sequence[ScanDataInfo], ) -> IspybIds: assert ( @@ -75,9 +74,7 @@ def update_deposition( assert ( ispyb_ids.data_collection_ids ), "Attempted to store scan data without a collection" - return self._begin_or_update_deposition( - ispyb_ids, data_collection_group_info, scan_data_infos - ) + return self._begin_or_update_deposition(ispyb_ids, None, scan_data_infos) def _begin_or_update_deposition( self, diff --git a/tests/system_tests/external_interaction/test_ispyb_dev_connection.py b/tests/system_tests/external_interaction/test_ispyb_dev_connection.py index 071b07292..29b979f42 100644 --- a/tests/system_tests/external_interaction/test_ispyb_dev_connection.py +++ b/tests/system_tests/external_interaction/test_ispyb_dev_connection.py @@ -494,9 +494,7 @@ def test_ispyb_deposition_comment_correct_for_3D_on_failure( ExperimentType.GRIDSCAN_3D, ispyb_ids, ) - ispyb_ids = dummy_ispyb_3d.update_deposition( - ispyb_ids, dummy_data_collection_group_info, scan_data_infos - ) + ispyb_ids = dummy_ispyb_3d.update_deposition(ispyb_ids, scan_data_infos) dcid1 = ispyb_ids.data_collection_ids[0] # type: ignore dcid2 = ispyb_ids.data_collection_ids[1] # type: ignore dummy_ispyb_3d.end_deposition(ispyb_ids, "fail", "could not connect to devices") @@ -539,9 +537,7 @@ def test_can_store_2D_ispyb_data_correctly_when_in_error( dummy_params, dummy_scan_data_info_for_begin, experiment_type, ispyb_ids ) - ispyb_ids = ispyb.update_deposition( - ispyb_ids, dummy_data_collection_group_info, scan_data_infos - ) + ispyb_ids = ispyb.update_deposition(ispyb_ids, scan_data_infos) assert len(ispyb_ids.data_collection_ids) == exp_num_of_grids # type: ignore assert len(ispyb_ids.grid_ids) == exp_num_of_grids # type: ignore assert isinstance(ispyb_ids.data_collection_group_id, int) diff --git a/tests/unit_tests/external_interaction/callbacks/rotation/test_ispyb_callback.py b/tests/unit_tests/external_interaction/callbacks/rotation/test_ispyb_callback.py index a5f8ad260..ad1b817b4 100644 --- a/tests/unit_tests/external_interaction/callbacks/rotation/test_ispyb_callback.py +++ b/tests/unit_tests/external_interaction/callbacks/rotation/test_ispyb_callback.py @@ -99,16 +99,7 @@ def test_hardware_read_events( TestData.test_descriptor_document_pre_data_collection ) callback.activity_gated_event(TestData.test_event_document_pre_data_collection) - assert_upsert_call_with( - mx.upsert_data_collection_group.mock_calls[0], - mx.get_data_collection_group_params(), - { - "id": TEST_DATA_COLLECTION_GROUP_ID, - "parentid": TEST_SESSION_ID, - "experimenttype": "SAD", - "sampleid": TEST_SAMPLE_ID, - }, - ) + mx.upsert_data_collection_group.assert_not_called() assert_upsert_call_with( mx.upsert_data_collection.mock_calls[0], mx.get_data_collection_params(), diff --git a/tests/unit_tests/external_interaction/callbacks/xray_centre/test_ispyb_callback.py b/tests/unit_tests/external_interaction/callbacks/xray_centre/test_ispyb_callback.py index aeb0544e7..06946d6fd 100644 --- a/tests/unit_tests/external_interaction/callbacks/xray_centre/test_ispyb_callback.py +++ b/tests/unit_tests/external_interaction/callbacks/xray_centre/test_ispyb_callback.py @@ -134,16 +134,7 @@ def test_hardware_read_event_3d(self, mock_ispyb_conn): TestData.test_descriptor_document_pre_data_collection ) callback.activity_gated_event(TestData.test_event_document_pre_data_collection) - assert_upsert_call_with( - mx_acq.upsert_data_collection_group.mock_calls[0], # pyright: ignore - mx_acq.get_data_collection_group_params(), - { - "id": TEST_DATA_COLLECTION_GROUP_ID, - "parentid": TEST_SESSION_ID, - "experimenttype": "Mesh3D", - "sampleid": TEST_SAMPLE_ID, - }, - ) + mx_acq.upsert_data_collection_group.assert_not_called() assert_upsert_call_with( mx_acq.upsert_data_collection.mock_calls[0], mx_acq.get_data_collection_params(), diff --git a/tests/unit_tests/external_interaction/ispyb/test_gridscan_ispyb_store_3d.py b/tests/unit_tests/external_interaction/ispyb/test_gridscan_ispyb_store_3d.py index 0495ad9ba..528b22e01 100644 --- a/tests/unit_tests/external_interaction/ispyb/test_gridscan_ispyb_store_3d.py +++ b/tests/unit_tests/external_interaction/ispyb/test_gridscan_ispyb_store_3d.py @@ -245,9 +245,7 @@ def test_ispyb_deposition_comment_for_3D_correct( ispyb_ids = dummy_3d_gridscan_ispyb.begin_deposition( dummy_collection_group_info, [scan_data_info_for_begin] ) - dummy_3d_gridscan_ispyb.update_deposition( - ispyb_ids, dummy_collection_group_info, scan_data_infos_for_update - ) + dummy_3d_gridscan_ispyb.update_deposition(ispyb_ids, scan_data_infos_for_update) first_upserted_param_value_list = mock_upsert_dc.call_args_list[1][0][0] second_upserted_param_value_list = mock_upsert_dc.call_args_list[2][0][0] @@ -280,7 +278,7 @@ def test_store_3d_grid_scan( ) assert dummy_3d_gridscan_ispyb.update_deposition( - ispyb_ids, dummy_collection_group_info, scan_data_infos_for_update + ispyb_ids, scan_data_infos_for_update ) == IspybIds( data_collection_ids=TEST_DATA_COLLECTION_IDS, data_collection_group_id=TEST_DATA_COLLECTION_GROUP_ID, @@ -382,11 +380,12 @@ def test_update_deposition( mx_acq = mx_acquisition_from_conn(mock_ispyb_conn) mx_acq.upsert_data_collection_group.assert_called_once() mx_acq.upsert_data_collection.assert_called_once() + mx_acq.upsert_data_collection_group.reset_mock() dummy_collection_group_info.sample_barcode = TEST_BARCODE actual_rows = dummy_3d_gridscan_ispyb.update_deposition( - ispyb_ids, dummy_collection_group_info, scan_data_infos_for_update + ispyb_ids, scan_data_infos_for_update ) assert actual_rows == IspybIds( @@ -395,17 +394,7 @@ def test_update_deposition( grid_ids=TEST_GRID_INFO_IDS, ) - assert_upsert_call_with( - mx_acq.upsert_data_collection_group.mock_calls[1], - mx_acq.get_data_collection_group_params(), - { - "id": TEST_DATA_COLLECTION_GROUP_ID, - "parentid": TEST_SESSION_ID, - "experimenttype": "Mesh3D", - "sampleid": TEST_SAMPLE_ID, - "sample_barcode": TEST_BARCODE, - }, - ) + mx_acq.upsert_data_collection_group.assert_not_called() assert_upsert_call_with( mx_acq.upsert_data_collection.mock_calls[1], @@ -580,11 +569,12 @@ def test_end_deposition_happy_path( ispyb_ids = dummy_3d_gridscan_ispyb.begin_deposition( dummy_collection_group_info, [scan_data_info_for_begin] ) + mx_acq = mx_acquisition_from_conn(mock_ispyb_conn) + assert len(mx_acq.upsert_data_collection_group.mock_calls) == 1 ispyb_ids = dummy_3d_gridscan_ispyb.update_deposition( - ispyb_ids, dummy_collection_group_info, scan_data_infos_for_update + ispyb_ids, scan_data_infos_for_update ) - mx_acq = mx_acquisition_from_conn(mock_ispyb_conn) - assert len(mx_acq.upsert_data_collection_group.mock_calls) == 2 + assert len(mx_acq.upsert_data_collection_group.mock_calls) == 1 assert len(mx_acq.upsert_data_collection.mock_calls) == 3 assert len(mx_acq.upsert_dc_grid.mock_calls) == 2 @@ -637,7 +627,7 @@ def test_param_keys( dummy_collection_group_info, [scan_data_info_for_begin] ) assert dummy_2d_gridscan_ispyb.update_deposition( - ispyb_ids, dummy_collection_group_info, [scan_xy_data_info_for_update] + ispyb_ids, [scan_xy_data_info_for_update] ) == IspybIds( data_collection_ids=(TEST_DATA_COLLECTION_IDS[0],), data_collection_group_id=TEST_DATA_COLLECTION_GROUP_ID, @@ -658,9 +648,7 @@ def _test_when_grid_scan_stored_then_data_present_in_upserts( ispyb_ids = dummy_ispyb.begin_deposition( dummy_collection_group_info, [scan_data_info_for_begin] ) - dummy_ispyb.update_deposition( - ispyb_ids, dummy_collection_group_info, [scan_data_info_for_update] - ) + dummy_ispyb.update_deposition(ispyb_ids, [scan_data_info_for_update]) mx_acquisition = ispyb_conn.return_value.__enter__.return_value.mx_acquisition @@ -672,7 +660,7 @@ def _test_when_grid_scan_stored_then_data_present_in_upserts( if test_group: upsert_data_collection_group_arg_list = ( - mx_acquisition.upsert_data_collection_group.call_args_list[1][0] + mx_acquisition.upsert_data_collection_group.call_args_list[0][0] ) actual = upsert_data_collection_group_arg_list[0] assert test_function(MXAcquisition.get_data_collection_group_params(), actual) @@ -747,7 +735,7 @@ def test_fail_result_run_results_in_bad_run_status( dummy_collection_group_info, [scan_data_info_for_begin] ) ispyb_ids = dummy_2d_gridscan_ispyb.update_deposition( - ispyb_ids, dummy_collection_group_info, [scan_xy_data_info_for_update] + ispyb_ids, [scan_xy_data_info_for_update] ) dummy_2d_gridscan_ispyb.end_deposition(ispyb_ids, "fail", "test specifies failure") @@ -776,7 +764,7 @@ def test_no_exception_during_run_results_in_good_run_status( dummy_collection_group_info, [scan_data_info_for_begin] ) ispyb_ids = dummy_2d_gridscan_ispyb.update_deposition( - ispyb_ids, dummy_collection_group_info, [scan_xy_data_info_for_update] + ispyb_ids, [scan_xy_data_info_for_update] ) dummy_2d_gridscan_ispyb.end_deposition(ispyb_ids, "success", "") diff --git a/tests/unit_tests/external_interaction/ispyb/test_rotation_ispyb_store.py b/tests/unit_tests/external_interaction/ispyb/test_rotation_ispyb_store.py index e9bf84c1e..f1cb7b0fc 100644 --- a/tests/unit_tests/external_interaction/ispyb/test_rotation_ispyb_store.py +++ b/tests/unit_tests/external_interaction/ispyb/test_rotation_ispyb_store.py @@ -326,23 +326,12 @@ def test_update_deposition( assert dummy_rotation_ispyb.update_deposition( ispyb_ids, - dummy_rotation_data_collection_group_info, [scan_data_info_for_update], ) == IspybIds( data_collection_group_id=TEST_DATA_COLLECTION_GROUP_ID, data_collection_ids=(TEST_DATA_COLLECTION_IDS[0],), ) - assert_upsert_call_with( - mx_acq.upsert_data_collection_group.mock_calls[0], - mx_acq.get_data_collection_group_params(), - { - "id": TEST_DATA_COLLECTION_GROUP_ID, - "parentid": TEST_SESSION_ID, - "experimenttype": "SAD", - "sampleid": TEST_SAMPLE_ID, - "sample_barcode": TEST_BARCODE, # deferred - }, - ) + mx_acq.upsert_data_collection_group.assert_not_called() assert_upsert_call_with( mx_acq.upsert_data_collection.mock_calls[0], mx_acq.get_data_collection_params(), @@ -396,23 +385,12 @@ def test_update_deposition_with_group_id_updates( dummy_rotation_data_collection_group_info.sample_barcode = TEST_BARCODE assert dummy_rotation_ispyb.update_deposition( ispyb_ids, - dummy_rotation_data_collection_group_info, [scan_data_info_for_update], ) == IspybIds( data_collection_group_id=TEST_DATA_COLLECTION_GROUP_ID, data_collection_ids=(TEST_DATA_COLLECTION_IDS[0],), ) - assert_upsert_call_with( - mx_acq.upsert_data_collection_group.mock_calls[0], - mx_acq.get_data_collection_group_params(), - { - "id": TEST_DATA_COLLECTION_GROUP_ID, - "parentid": TEST_SESSION_ID, - "experimenttype": "SAD", - "sampleid": TEST_SAMPLE_ID, - "sample_barcode": TEST_BARCODE, # deferred - }, - ) + mx_acq.upsert_data_collection_group.assert_not_called() assert_upsert_call_with( mx_acq.upsert_data_collection.mock_calls[0], mx_acq.get_data_collection_params(), @@ -462,7 +440,6 @@ def test_end_deposition_happy_path( scan_data_info_for_update.data_collection_id = ispyb_ids.data_collection_ids[0] ispyb_ids = dummy_rotation_ispyb.update_deposition( ispyb_ids, - dummy_rotation_data_collection_group_info, [scan_data_info_for_update], ) mx_acq = mx_acquisition_from_conn(mock_ispyb_conn) @@ -535,7 +512,6 @@ def test_store_rotation_scan_uses_supplied_dcgid( assert ( store_in_ispyb.update_deposition( ispyb_ids, - dummy_rotation_data_collection_group_info, [scan_data_info_for_update], ).data_collection_group_id == dcgid