From 4576541498dcbd06b62152538953b003914ab098 Mon Sep 17 00:00:00 2001 From: Dominic Oram Date: Wed, 27 Nov 2024 18:54:14 +0000 Subject: [PATCH 1/5] Use separate aperture and scatterguard moves --- pyproject.toml | 2 +- .../grid_detect_then_xray_centre_plan.py | 8 ++++++++ .../hyperion/experiment_plans/oav_snapshot_plan.py | 10 ++-------- .../experiment_plans/robot_load_and_change_energy.py | 8 ++------ .../hyperion/experiment_plans/rotation_scan_plan.py | 7 +++++++ tests/conftest.py | 12 ++++++------ .../test_flyscan_xray_centre_plan.py | 4 ++-- .../test_pin_centre_then_xray_centre_plan.py | 6 ++---- .../test_robot_load_and_change_energy.py | 6 +++--- .../experiment_plans/test_rotation_scan_plan.py | 5 ++--- 10 files changed, 35 insertions(+), 33 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index c46287b53..bc6e0dc41 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -46,7 +46,7 @@ dependencies = [ "ophyd == 1.9.0", "ophyd-async >= 0.8a5", "bluesky >= 1.13.0a4", - "dls-dodal @ git+https://github.com/DiamondLightSource/dodal.git@main", + "dls-dodal @ git+https://github.com/DiamondLightSource/dodal.git@fcd581d6e5cda2bb78c67893c856ec672581b8ff", ] diff --git a/src/mx_bluesky/hyperion/experiment_plans/grid_detect_then_xray_centre_plan.py b/src/mx_bluesky/hyperion/experiment_plans/grid_detect_then_xray_centre_plan.py index dbdcd6b19..ac0d24509 100644 --- a/src/mx_bluesky/hyperion/experiment_plans/grid_detect_then_xray_centre_plan.py +++ b/src/mx_bluesky/hyperion/experiment_plans/grid_detect_then_xray_centre_plan.py @@ -144,6 +144,14 @@ def run_grid_detection_plan( parameters.box_size_um, ) + if parameters.selected_aperture: + # Start moving the aperture/scatterguard into position without moving it in + yield from bps.abs_set( + composite.aperture_scatterguard.aperture_outside_beam, + parameters.selected_aperture, + group=CONST.WAIT.GRID_READY_FOR_DC, + ) + yield from run_grid_detection_plan( oav_params, snapshot_template, diff --git a/src/mx_bluesky/hyperion/experiment_plans/oav_snapshot_plan.py b/src/mx_bluesky/hyperion/experiment_plans/oav_snapshot_plan.py index e214f6ee5..bf1aea872 100644 --- a/src/mx_bluesky/hyperion/experiment_plans/oav_snapshot_plan.py +++ b/src/mx_bluesky/hyperion/experiment_plans/oav_snapshot_plan.py @@ -3,7 +3,7 @@ from bluesky import plan_stubs as bps from bluesky.utils import MsgGenerator -from dodal.devices.aperturescatterguard import ApertureScatterguard, ApertureValue +from dodal.devices.aperturescatterguard import ApertureScatterguard from dodal.devices.backlight import Backlight, BacklightPosition from dodal.devices.oav.oav_detector import OAV from dodal.devices.oav.oav_parameters import OAVParameters @@ -33,22 +33,16 @@ def setup_beamline_for_OAV( max_vel = yield from bps.rd(smargon.omega.max_velocity) yield from bps.abs_set(smargon.omega.velocity, max_vel, group=group) yield from bps.abs_set(backlight, BacklightPosition.IN, group=group) - yield from bps.abs_set( - aperture_scatterguard, - ApertureValue.ROBOT_LOAD, - group=group, - ) + yield from bps.trigger(aperture_scatterguard.move_out, group=group) def oav_snapshot_plan( composite: OavSnapshotComposite, parameters: WithSnapshot, oav_parameters: OAVParameters, - wait: bool = True, ) -> MsgGenerator: if not parameters.take_snapshots: return - yield from bps.wait(group=CONST.WAIT.READY_FOR_OAV) yield from _setup_oav(composite, parameters, oav_parameters) for omega in parameters.snapshot_omegas_deg or []: yield from _take_oav_snapshot(composite, omega) diff --git a/src/mx_bluesky/hyperion/experiment_plans/robot_load_and_change_energy.py b/src/mx_bluesky/hyperion/experiment_plans/robot_load_and_change_energy.py index 74423743d..e5448eea7 100644 --- a/src/mx_bluesky/hyperion/experiment_plans/robot_load_and_change_energy.py +++ b/src/mx_bluesky/hyperion/experiment_plans/robot_load_and_change_energy.py @@ -10,7 +10,7 @@ import pydantic from blueapi.core import BlueskyContext from bluesky.utils import Msg -from dodal.devices.aperturescatterguard import ApertureScatterguard, ApertureValue +from dodal.devices.aperturescatterguard import ApertureScatterguard from dodal.devices.attenuator import Attenuator from dodal.devices.dcm import DCM from dodal.devices.focusing_mirror import FocusingMirrorWithStripes, MirrorVoltages @@ -94,11 +94,7 @@ def take_robot_snapshots(oav: OAV, webcam: Webcam, directory: Path): def prepare_for_robot_load( aperture_scatterguard: ApertureScatterguard, smargon: Smargon ): - yield from bps.abs_set( - aperture_scatterguard, - ApertureValue.ROBOT_LOAD, - group="prepare_robot_load", - ) + yield from bps.trigger(aperture_scatterguard.move_out, group="prepare_robot_load") yield from bps.mv(smargon.stub_offsets, StubPosition.RESET_TO_ROBOT_LOAD) # type: ignore # See: https://github.com/bluesky/bluesky/issues/1809 diff --git a/src/mx_bluesky/hyperion/experiment_plans/rotation_scan_plan.py b/src/mx_bluesky/hyperion/experiment_plans/rotation_scan_plan.py index 9887847c4..de4aa5dce 100644 --- a/src/mx_bluesky/hyperion/experiment_plans/rotation_scan_plan.py +++ b/src/mx_bluesky/hyperion/experiment_plans/rotation_scan_plan.py @@ -331,6 +331,13 @@ def _div_by_1000_if_not_none(num: float | None): yield from setup_beamline_for_OAV( composite.smargon, composite.backlight, composite.aperture_scatterguard ) + yield from bps.wait(group=CONST.WAIT.READY_FOR_OAV) + if params.selected_aperture: + yield from bps.abs_set( + composite.aperture_scatterguard.aperture_outside_beam, + params.selected_aperture, + group=CONST.WAIT.ROTATION_READY_FOR_DC, + ) yield from oav_snapshot_plan(composite, params, oav_params) yield from rotation_scan_plan( composite, diff --git a/tests/conftest.py b/tests/conftest.py index 702e507c9..b26c35464 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -559,15 +559,15 @@ def aperture_scatterguard(RE): ): ap_sg = i03.aperture_scatterguard(fake_with_ophyd_sim=True) with ( - patch_async_motor(ap_sg.aperture.x), - patch_async_motor(ap_sg.aperture.y), - patch_async_motor(ap_sg.aperture.z, 2), - patch_async_motor(ap_sg.scatterguard.x), - patch_async_motor(ap_sg.scatterguard.y), + patch_async_motor(ap_sg._aperture.x), + patch_async_motor(ap_sg._aperture.y), + patch_async_motor(ap_sg._aperture.z, 2), + patch_async_motor(ap_sg._scatterguard.x), + patch_async_motor(ap_sg._scatterguard.y), ): RE(bps.abs_set(ap_sg, ApertureValue.SMALL)) - set_mock_value(ap_sg.aperture.small, 1) + set_mock_value(ap_sg._aperture.small, 1) yield ap_sg diff --git a/tests/unit_tests/hyperion/experiment_plans/test_flyscan_xray_centre_plan.py b/tests/unit_tests/hyperion/experiment_plans/test_flyscan_xray_centre_plan.py index 640f81189..0be8604c6 100644 --- a/tests/unit_tests/hyperion/experiment_plans/test_flyscan_xray_centre_plan.py +++ b/tests/unit_tests/hyperion/experiment_plans/test_flyscan_xray_centre_plan.py @@ -315,7 +315,7 @@ def test_read_hardware_for_ispyb_updates_from_ophyd_devices( # fmt: on @patch( - "dodal.devices.aperturescatterguard.ApertureScatterguard._safe_move_within_datacollection_range", + "dodal.devices.aperturescatterguard._safe_move_whilst_in_beam", return_value=NullStatus(), ) @patch( @@ -452,7 +452,7 @@ def test_results_passed_to_move_motors( ) @patch( - "dodal.devices.aperturescatterguard.ApertureScatterguard._safe_move_within_datacollection_range", + "dodal.devices.aperturescatterguard._safe_move_whilst_in_beam", return_value=NullStatus(), ) @patch( diff --git a/tests/unit_tests/hyperion/experiment_plans/test_pin_centre_then_xray_centre_plan.py b/tests/unit_tests/hyperion/experiment_plans/test_pin_centre_then_xray_centre_plan.py index 1e823779e..17ce2024c 100644 --- a/tests/unit_tests/hyperion/experiment_plans/test_pin_centre_then_xray_centre_plan.py +++ b/tests/unit_tests/hyperion/experiment_plans/test_pin_centre_then_xray_centre_plan.py @@ -4,7 +4,6 @@ from bluesky.run_engine import RunEngine from bluesky.simulators import RunEngineSimulator, assert_message_and_return_remaining from bluesky.utils import Msg -from dodal.devices.aperturescatterguard import ApertureValue from dodal.devices.backlight import BacklightPosition from dodal.devices.detector.detector_motion import ShutterState from dodal.devices.smargon import Smargon @@ -292,9 +291,8 @@ def test_pin_centre_then_xray_centre_plan_sets_up_backlight_and_aperture( ) msgs = assert_message_and_return_remaining( msgs, - lambda msg: msg.command == "set" - and msg.obj.name == "aperture_scatterguard" - and msg.args == (ApertureValue.ROBOT_LOAD,) + lambda msg: msg.command == "trigger" + and msg.obj.name == "aperture_scatterguard-move_out" and msg.kwargs["group"] == CONST.WAIT.READY_FOR_OAV, ) diff --git a/tests/unit_tests/hyperion/experiment_plans/test_robot_load_and_change_energy.py b/tests/unit_tests/hyperion/experiment_plans/test_robot_load_and_change_energy.py index c688a99a5..25596abd2 100644 --- a/tests/unit_tests/hyperion/experiment_plans/test_robot_load_and_change_energy.py +++ b/tests/unit_tests/hyperion/experiment_plans/test_robot_load_and_change_energy.py @@ -6,7 +6,7 @@ from bluesky.run_engine import RunEngine from bluesky.simulators import RunEngineSimulator, assert_message_and_return_remaining from bluesky.utils import Msg -from dodal.devices.aperturescatterguard import ApertureScatterguard, ApertureValue +from dodal.devices.aperturescatterguard import ApertureScatterguard from dodal.devices.oav.oav_detector import OAV from dodal.devices.smargon import Smargon, StubPosition from dodal.devices.webcam import Webcam @@ -171,7 +171,7 @@ async def test_when_prepare_for_robot_load_called_then_moves_as_expected( aperture_scatterguard: ApertureScatterguard, smargon: Smargon, done_status ): smargon.stub_offsets.set = MagicMock(return_value=done_status) - aperture_scatterguard.set = MagicMock(return_value=done_status) + aperture_scatterguard.move_out.trigger = MagicMock(return_value=done_status) set_mock_value(smargon.x.user_readback, 10) set_mock_value(smargon.z.user_readback, 5) @@ -185,7 +185,7 @@ async def test_when_prepare_for_robot_load_called_then_moves_as_expected( assert await smargon.omega.user_readback.get_value() == 0 smargon.stub_offsets.set.assert_called_once_with(StubPosition.RESET_TO_ROBOT_LOAD) # type: ignore - aperture_scatterguard.set.assert_called_once_with(ApertureValue.ROBOT_LOAD) # type: ignore + aperture_scatterguard.move_out.trigger.assert_called_once_with() # type: ignore @patch( diff --git a/tests/unit_tests/hyperion/experiment_plans/test_rotation_scan_plan.py b/tests/unit_tests/hyperion/experiment_plans/test_rotation_scan_plan.py index f39e57a9d..253b26f2e 100644 --- a/tests/unit_tests/hyperion/experiment_plans/test_rotation_scan_plan.py +++ b/tests/unit_tests/hyperion/experiment_plans/test_rotation_scan_plan.py @@ -507,9 +507,8 @@ def test_rotation_snapshot_setup_called_to_move_backlight_in_aperture_out_before ) msgs = assert_message_and_return_remaining( msgs, - lambda msg: msg.command == "set" - and msg.obj.name == "aperture_scatterguard" - and msg.args[0] == ApertureValue.ROBOT_LOAD + lambda msg: msg.command == "trigger" + and msg.obj.name == "aperture_scatterguard-move_out" and msg.kwargs["group"] == CONST.WAIT.READY_FOR_OAV, ) msgs = assert_message_and_return_remaining( From 4eaff9ed2b944c9f34727835cb22652e211b5a37 Mon Sep 17 00:00:00 2001 From: Dominic Oram Date: Fri, 29 Nov 2024 16:29:33 +0000 Subject: [PATCH 2/5] Fix linting --- tests/system_tests/hyperion/external_interaction/conftest.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/system_tests/hyperion/external_interaction/conftest.py b/tests/system_tests/hyperion/external_interaction/conftest.py index c7104ea00..e96235b2e 100644 --- a/tests/system_tests/hyperion/external_interaction/conftest.py +++ b/tests/system_tests/hyperion/external_interaction/conftest.py @@ -321,7 +321,9 @@ def fgs_composite_for_fake_zocalo( zocalo_for_fake_zocalo: ZocaloResults, done_status: NullStatus, ) -> FlyScanXRayCentreComposite: - set_mock_value(fake_fgs_composite.aperture_scatterguard.aperture.z.user_setpoint, 2) + set_mock_value( + fake_fgs_composite.aperture_scatterguard._aperture.z.user_setpoint, 2 + ) fake_fgs_composite.eiger.unstage = MagicMock(return_value=done_status) # type: ignore fake_fgs_composite.smargon.stub_offsets.set = MagicMock(return_value=done_status) # type: ignore callback_on_mock_put( From 2d68795201710f5800c79b5e81ac8a10546fef96 Mon Sep 17 00:00:00 2001 From: Dominic Oram Date: Wed, 22 Jan 2025 17:02:55 +0000 Subject: [PATCH 3/5] Rename aperture/scatterguard to remove underscore --- tests/conftest.py | 18 +++++++++--------- .../hyperion/external_interaction/conftest.py | 4 +--- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index b26c35464..fe9964609 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -559,15 +559,15 @@ def aperture_scatterguard(RE): ): ap_sg = i03.aperture_scatterguard(fake_with_ophyd_sim=True) with ( - patch_async_motor(ap_sg._aperture.x), - patch_async_motor(ap_sg._aperture.y), - patch_async_motor(ap_sg._aperture.z, 2), - patch_async_motor(ap_sg._scatterguard.x), - patch_async_motor(ap_sg._scatterguard.y), + patch_async_motor(ap_sg.aperture().x), + patch_async_motor(ap_sg.aperture().y), + patch_async_motor(ap_sg.aperture().z, 2), + patch_async_motor(ap_sg.scatterguard.x), + patch_async_motor(ap_sg.scatterguard.y), ): RE(bps.abs_set(ap_sg, ApertureValue.SMALL)) - set_mock_value(ap_sg._aperture.small, 1) + set_mock_value(ap_sg.aperture().small, 1) yield ap_sg @@ -926,9 +926,9 @@ def assert_events_and_data_in_order( for event_data_keys in match_data_keys_list: docs = DocumentCapturer.get_docs_from(docs, "event") doc = docs.pop(0)[1]["data"] - assert all( - k in doc.keys() for k in event_data_keys - ), f"One of {event_data_keys=} not in {doc}" + assert all(k in doc.keys() for k in event_data_keys), ( + f"One of {event_data_keys=} not in {doc}" + ) @pytest.fixture diff --git a/tests/system_tests/hyperion/external_interaction/conftest.py b/tests/system_tests/hyperion/external_interaction/conftest.py index e96235b2e..c7104ea00 100644 --- a/tests/system_tests/hyperion/external_interaction/conftest.py +++ b/tests/system_tests/hyperion/external_interaction/conftest.py @@ -321,9 +321,7 @@ def fgs_composite_for_fake_zocalo( zocalo_for_fake_zocalo: ZocaloResults, done_status: NullStatus, ) -> FlyScanXRayCentreComposite: - set_mock_value( - fake_fgs_composite.aperture_scatterguard._aperture.z.user_setpoint, 2 - ) + set_mock_value(fake_fgs_composite.aperture_scatterguard.aperture.z.user_setpoint, 2) fake_fgs_composite.eiger.unstage = MagicMock(return_value=done_status) # type: ignore fake_fgs_composite.smargon.stub_offsets.set = MagicMock(return_value=done_status) # type: ignore callback_on_mock_put( From 9960e5c8e9996485a6cef779c190a0c8b2341d1e Mon Sep 17 00:00:00 2001 From: Dominic Oram Date: Fri, 24 Jan 2025 09:38:34 +0000 Subject: [PATCH 4/5] Update moving aperture_scatterguard to use newest interface --- .../grid_detect_then_xray_centre_plan.py | 4 ++-- .../hyperion/experiment_plans/oav_snapshot_plan.py | 6 ++++-- .../experiment_plans/robot_load_and_change_energy.py | 6 ++++-- .../hyperion/experiment_plans/rotation_scan_plan.py | 4 ++-- tests/conftest.py | 10 +++++----- .../device_setup_plans/test_manipulate_sample.py | 2 +- tests/unit_tests/hyperion/experiment_plans/conftest.py | 2 +- .../experiment_plans/test_flyscan_xray_centre_plan.py | 10 ---------- .../test_pin_centre_then_xray_centre_plan.py | 6 ++++-- .../test_robot_load_and_change_energy.py | 6 +++--- .../experiment_plans/test_rotation_scan_plan.py | 5 +++-- 11 files changed, 29 insertions(+), 32 deletions(-) diff --git a/src/mx_bluesky/hyperion/experiment_plans/grid_detect_then_xray_centre_plan.py b/src/mx_bluesky/hyperion/experiment_plans/grid_detect_then_xray_centre_plan.py index 5a800ba12..768f72136 100644 --- a/src/mx_bluesky/hyperion/experiment_plans/grid_detect_then_xray_centre_plan.py +++ b/src/mx_bluesky/hyperion/experiment_plans/grid_detect_then_xray_centre_plan.py @@ -144,8 +144,8 @@ def run_grid_detection_plan( if parameters.selected_aperture: # Start moving the aperture/scatterguard into position without moving it in - yield from bps.abs_set( - composite.aperture_scatterguard.aperture_outside_beam, + yield from bps.prepare( + composite.aperture_scatterguard, parameters.selected_aperture, group=CONST.WAIT.GRID_READY_FOR_DC, ) diff --git a/src/mx_bluesky/hyperion/experiment_plans/oav_snapshot_plan.py b/src/mx_bluesky/hyperion/experiment_plans/oav_snapshot_plan.py index bf1aea872..f269ff024 100644 --- a/src/mx_bluesky/hyperion/experiment_plans/oav_snapshot_plan.py +++ b/src/mx_bluesky/hyperion/experiment_plans/oav_snapshot_plan.py @@ -3,7 +3,7 @@ from bluesky import plan_stubs as bps from bluesky.utils import MsgGenerator -from dodal.devices.aperturescatterguard import ApertureScatterguard +from dodal.devices.aperturescatterguard import ApertureScatterguard, ApertureValue from dodal.devices.backlight import Backlight, BacklightPosition from dodal.devices.oav.oav_detector import OAV from dodal.devices.oav.oav_parameters import OAVParameters @@ -33,7 +33,9 @@ def setup_beamline_for_OAV( max_vel = yield from bps.rd(smargon.omega.max_velocity) yield from bps.abs_set(smargon.omega.velocity, max_vel, group=group) yield from bps.abs_set(backlight, BacklightPosition.IN, group=group) - yield from bps.trigger(aperture_scatterguard.move_out, group=group) + yield from bps.abs_set( + aperture_scatterguard, ApertureValue.OUT_OF_BEAM, group=group + ) def oav_snapshot_plan( diff --git a/src/mx_bluesky/hyperion/experiment_plans/robot_load_and_change_energy.py b/src/mx_bluesky/hyperion/experiment_plans/robot_load_and_change_energy.py index c0316f21e..8a62efbf4 100644 --- a/src/mx_bluesky/hyperion/experiment_plans/robot_load_and_change_energy.py +++ b/src/mx_bluesky/hyperion/experiment_plans/robot_load_and_change_energy.py @@ -10,7 +10,7 @@ import pydantic from blueapi.core import BlueskyContext from bluesky.utils import Msg -from dodal.devices.aperturescatterguard import ApertureScatterguard +from dodal.devices.aperturescatterguard import ApertureScatterguard, ApertureValue from dodal.devices.attenuator.attenuator import BinaryFilterAttenuator from dodal.devices.dcm import DCM from dodal.devices.focusing_mirror import FocusingMirrorWithStripes, MirrorVoltages @@ -94,7 +94,9 @@ def take_robot_snapshots(oav: OAV, webcam: Webcam, directory: Path): def prepare_for_robot_load( aperture_scatterguard: ApertureScatterguard, smargon: Smargon ): - yield from bps.trigger(aperture_scatterguard.move_out, group="prepare_robot_load") + yield from bps.abs_set( + aperture_scatterguard, ApertureValue.OUT_OF_BEAM, group="prepare_robot_load" + ) yield from bps.mv(smargon.stub_offsets, StubPosition.RESET_TO_ROBOT_LOAD) # type: ignore # See: https://github.com/bluesky/bluesky/issues/1809 diff --git a/src/mx_bluesky/hyperion/experiment_plans/rotation_scan_plan.py b/src/mx_bluesky/hyperion/experiment_plans/rotation_scan_plan.py index 422f3ea15..7fb9d9353 100644 --- a/src/mx_bluesky/hyperion/experiment_plans/rotation_scan_plan.py +++ b/src/mx_bluesky/hyperion/experiment_plans/rotation_scan_plan.py @@ -348,8 +348,8 @@ def _div_by_1000_if_not_none(num: float | None): ) yield from bps.wait(group=CONST.WAIT.READY_FOR_OAV) if params.selected_aperture: - yield from bps.abs_set( - composite.aperture_scatterguard.aperture_outside_beam, + yield from bps.prepare( + composite.aperture_scatterguard, params.selected_aperture, group=CONST.WAIT.ROTATION_READY_FOR_DC, ) diff --git a/tests/conftest.py b/tests/conftest.py index c7beb7ac0..e0506e284 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -579,7 +579,7 @@ def aperture_scatterguard(RE): scatterguard_y=14, radius=20, ), - ApertureValue.ROBOT_LOAD: AperturePosition( + ApertureValue.OUT_OF_BEAM: AperturePosition( aperture_x=15, aperture_y=16, aperture_z=2, @@ -606,15 +606,15 @@ def aperture_scatterguard(RE): ): ap_sg = i03.aperture_scatterguard(fake_with_ophyd_sim=True) with ( - patch_async_motor(ap_sg.aperture().x), - patch_async_motor(ap_sg.aperture().y), - patch_async_motor(ap_sg.aperture().z, 2), + patch_async_motor(ap_sg.aperture.x), + patch_async_motor(ap_sg.aperture.y), + patch_async_motor(ap_sg.aperture.z, 2), patch_async_motor(ap_sg.scatterguard.x), patch_async_motor(ap_sg.scatterguard.y), ): RE(bps.abs_set(ap_sg, ApertureValue.SMALL)) - set_mock_value(ap_sg.aperture().small, 1) + set_mock_value(ap_sg.aperture.small, 1) yield ap_sg diff --git a/tests/unit_tests/hyperion/device_setup_plans/test_manipulate_sample.py b/tests/unit_tests/hyperion/device_setup_plans/test_manipulate_sample.py index f9a8b3c85..9f135cfdc 100644 --- a/tests/unit_tests/hyperion/device_setup_plans/test_manipulate_sample.py +++ b/tests/unit_tests/hyperion/device_setup_plans/test_manipulate_sample.py @@ -20,7 +20,7 @@ [ (ApertureValue.SMALL), (ApertureValue.MEDIUM), - (ApertureValue.ROBOT_LOAD), + (ApertureValue.OUT_OF_BEAM), (ApertureValue.LARGE), ], ) diff --git a/tests/unit_tests/hyperion/experiment_plans/conftest.py b/tests/unit_tests/hyperion/experiment_plans/conftest.py index 9c5cf53d0..eb8b9c262 100644 --- a/tests/unit_tests/hyperion/experiment_plans/conftest.py +++ b/tests/unit_tests/hyperion/experiment_plans/conftest.py @@ -91,7 +91,7 @@ def make_event_doc(data, descriptor="abc123") -> Event: } BASIC_POST_SETUP_DOC = { - "aperture_scatterguard-selected_aperture": ApertureValue.ROBOT_LOAD, + "aperture_scatterguard-selected_aperture": ApertureValue.OUT_OF_BEAM, "aperture_scatterguard-radius": None, "aperture_scatterguard-aperture-x": 15, "aperture_scatterguard-aperture-y": 16, diff --git a/tests/unit_tests/hyperion/experiment_plans/test_flyscan_xray_centre_plan.py b/tests/unit_tests/hyperion/experiment_plans/test_flyscan_xray_centre_plan.py index b8712b89e..6763fb0a0 100644 --- a/tests/unit_tests/hyperion/experiment_plans/test_flyscan_xray_centre_plan.py +++ b/tests/unit_tests/hyperion/experiment_plans/test_flyscan_xray_centre_plan.py @@ -331,10 +331,6 @@ def test_read_hardware_for_ispyb_updates_from_ophyd_devices( ) # fmt: on - @patch( - "dodal.devices.aperturescatterguard._safe_move_whilst_in_beam", - return_value=NullStatus(), - ) @patch( "mx_bluesky.hyperion.experiment_plans.flyscan_xray_centre_plan.run_gridscan", autospec=True, @@ -342,7 +338,6 @@ def test_read_hardware_for_ispyb_updates_from_ophyd_devices( async def test_results_adjusted_and_event_raised( self, run_gridscan: MagicMock, - move_aperture: MagicMock, fgs_composite_with_panda_pcap: FlyScanXRayCentreComposite, test_fgs_params_panda_zebra: HyperionSpecifiedThreeDGridScan, feature_controlled: _FeatureControlled, @@ -468,10 +463,6 @@ def test_results_passed_to_move_motors( any_order=True, ) - @patch( - "dodal.devices.aperturescatterguard._safe_move_whilst_in_beam", - return_value=NullStatus(), - ) @patch( "mx_bluesky.hyperion.experiment_plans.flyscan_xray_centre_plan.run_gridscan", autospec=True, @@ -488,7 +479,6 @@ def test_individual_plans_triggered_once_and_only_once_in_composite_run( self, move_xyz: MagicMock, run_gridscan: MagicMock, - move_aperture: MagicMock, RE_with_subs: ReWithSubs, fgs_composite_with_panda_pcap: FlyScanXRayCentreComposite, test_fgs_params_panda_zebra: HyperionSpecifiedThreeDGridScan, diff --git a/tests/unit_tests/hyperion/experiment_plans/test_pin_centre_then_xray_centre_plan.py b/tests/unit_tests/hyperion/experiment_plans/test_pin_centre_then_xray_centre_plan.py index 9c402a95b..d47d8f63e 100644 --- a/tests/unit_tests/hyperion/experiment_plans/test_pin_centre_then_xray_centre_plan.py +++ b/tests/unit_tests/hyperion/experiment_plans/test_pin_centre_then_xray_centre_plan.py @@ -4,6 +4,7 @@ from bluesky.run_engine import RunEngine from bluesky.simulators import RunEngineSimulator, assert_message_and_return_remaining from bluesky.utils import Msg +from dodal.devices.aperturescatterguard import ApertureValue from dodal.devices.backlight import BacklightPosition from dodal.devices.detector.detector_motion import ShutterState from dodal.devices.i03.beamstop import BeamstopPositions @@ -293,8 +294,9 @@ def test_pin_centre_then_xray_centre_plan_sets_up_backlight_and_aperture( ) msgs = assert_message_and_return_remaining( msgs, - lambda msg: msg.command == "trigger" - and msg.obj.name == "aperture_scatterguard-move_out" + lambda msg: msg.command == "set" + and msg.obj.name == "aperture_scatterguard" + and msg.args == (ApertureValue.OUT_OF_BEAM,) and msg.kwargs["group"] == CONST.WAIT.READY_FOR_OAV, ) diff --git a/tests/unit_tests/hyperion/experiment_plans/test_robot_load_and_change_energy.py b/tests/unit_tests/hyperion/experiment_plans/test_robot_load_and_change_energy.py index 855eb94b0..0264ca49d 100644 --- a/tests/unit_tests/hyperion/experiment_plans/test_robot_load_and_change_energy.py +++ b/tests/unit_tests/hyperion/experiment_plans/test_robot_load_and_change_energy.py @@ -6,7 +6,7 @@ from bluesky.run_engine import RunEngine from bluesky.simulators import RunEngineSimulator, assert_message_and_return_remaining from bluesky.utils import Msg -from dodal.devices.aperturescatterguard import ApertureScatterguard +from dodal.devices.aperturescatterguard import ApertureScatterguard, ApertureValue from dodal.devices.oav.oav_detector import OAV from dodal.devices.smargon import Smargon, StubPosition from dodal.devices.webcam import Webcam @@ -150,7 +150,7 @@ async def test_when_prepare_for_robot_load_called_then_moves_as_expected( aperture_scatterguard: ApertureScatterguard, smargon: Smargon, done_status ): smargon.stub_offsets.set = MagicMock(return_value=done_status) - aperture_scatterguard.move_out.trigger = MagicMock(return_value=done_status) + aperture_scatterguard.set = MagicMock(return_value=done_status) set_mock_value(smargon.x.user_setpoint, 10) set_mock_value(smargon.z.user_setpoint, 5) @@ -164,7 +164,7 @@ async def test_when_prepare_for_robot_load_called_then_moves_as_expected( assert await smargon.omega.user_setpoint.get_value() == 0 smargon.stub_offsets.set.assert_called_once_with(StubPosition.RESET_TO_ROBOT_LOAD) # type: ignore - aperture_scatterguard.move_out.trigger.assert_called_once_with() # type: ignore + aperture_scatterguard.set.assert_called_once_with(ApertureValue.OUT_OF_BEAM) # type: ignore @patch( diff --git a/tests/unit_tests/hyperion/experiment_plans/test_rotation_scan_plan.py b/tests/unit_tests/hyperion/experiment_plans/test_rotation_scan_plan.py index 615da112b..b33ea3b16 100644 --- a/tests/unit_tests/hyperion/experiment_plans/test_rotation_scan_plan.py +++ b/tests/unit_tests/hyperion/experiment_plans/test_rotation_scan_plan.py @@ -509,8 +509,9 @@ def test_rotation_snapshot_setup_called_to_move_backlight_in_aperture_out_before ) msgs = assert_message_and_return_remaining( msgs, - lambda msg: msg.command == "trigger" - and msg.obj.name == "aperture_scatterguard-move_out" + lambda msg: msg.command == "set" + and msg.obj.name == "aperture_scatterguard" + and msg.args[0] == ApertureValue.OUT_OF_BEAM and msg.kwargs["group"] == CONST.WAIT.READY_FOR_OAV, ) msgs = assert_message_and_return_remaining( From 4f070db1018f4650da1b3418ba99334b9b4d2534 Mon Sep 17 00:00:00 2001 From: Dominic Oram Date: Fri, 24 Jan 2025 09:51:55 +0000 Subject: [PATCH 5/5] Pin dodal --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index f386531db..71e71aa41 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -46,7 +46,7 @@ dependencies = [ "ophyd == 1.9.0", "ophyd-async >= 0.8a5", "bluesky >= 1.13", - "dls-dodal @ git+https://github.com/DiamondLightSource/dodal.git@aba19ca8ff07d59b31d38c9bded30db86e15e9ce", + "dls-dodal @ git+https://github.com/DiamondLightSource/dodal.git@92a19d8c729e2317abce1c16a6a06e04e07e3df9", ]