From 617f58ad328d100303d2e004f7da5d056ed6afcc Mon Sep 17 00:00:00 2001 From: Oliver Silvester Date: Mon, 20 May 2024 16:13:58 +0100 Subject: [PATCH] Use dodal slits and not s4 slits --- setup.cfg | 2 +- .../read_hardware_for_setup.py | 8 +++---- .../flyscan_xray_centre_plan.py | 4 ++-- .../grid_detect_then_xray_centre_plan.py | 4 ++-- .../robot_load_then_centre_plan.py | 4 ++-- .../experiment_plans/rotation_scan_plan.py | 4 ++-- .../callbacks/ispyb_callback_base.py | 4 ++-- tests/conftest.py | 4 ++-- .../experiment_plans/test_plan_system.py | 10 ++++----- .../test_ispyb_dev_connection.py | 22 ++++++++++++------- tests/unit_tests/experiment_plans/conftest.py | 4 ++-- .../test_flyscan_xray_centre_plan.py | 13 +++++++---- .../test_panda_flyscan_xray_centre_plan.py | 12 ++++++---- .../callbacks/conftest.py | 4 ++-- 14 files changed, 57 insertions(+), 42 deletions(-) diff --git a/setup.cfg b/setup.cfg index 2db7b72e1..396221496 100644 --- a/setup.cfg +++ b/setup.cfg @@ -45,7 +45,7 @@ install_requires = ophyd-async >= 0.3a3 bluesky >= 1.13.0a3 blueapi >= 0.4.3-a1 - dls-dodal @ git+https://github.com/DiamondLightSource/dodal.git + dls-dodal @ git+https://github.com/DiamondLightSource/dodal.git@b140cb94d11dbe657afa2ae47414c7d84365f2ea [options.entry_points] console_scripts = 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 1e6aeb111..2c57b93a8 100644 --- a/src/hyperion/device_setup_plans/read_hardware_for_setup.py +++ b/src/hyperion/device_setup_plans/read_hardware_for_setup.py @@ -7,7 +7,7 @@ from dodal.devices.eiger import EigerDetector from dodal.devices.flux import Flux from dodal.devices.robot import BartRobot -from dodal.devices.s4_slit_gaps import S4SlitGaps +from dodal.devices.slits import Slits from dodal.devices.synchrotron import Synchrotron from dodal.devices.undulator import Undulator @@ -18,7 +18,7 @@ def read_hardware_for_ispyb_pre_collection( undulator: Undulator, synchrotron: Synchrotron, - s4_slit_gaps: S4SlitGaps, + s4_slit_gaps: Slits, aperture_scatterguard: ApertureScatterguard, robot: BartRobot, ): @@ -28,8 +28,8 @@ def read_hardware_for_ispyb_pre_collection( ) # gives name to event *descriptor* document yield from bps.read(undulator.current_gap) yield from bps.read(synchrotron.synchrotron_mode) - yield from bps.read(s4_slit_gaps.xgap) - yield from bps.read(s4_slit_gaps.ygap) + yield from bps.read(s4_slit_gaps.x_gap) + yield from bps.read(s4_slit_gaps.y_gap) yield from bps.read(aperture_scatterguard) yield from bps.save() diff --git a/src/hyperion/experiment_plans/flyscan_xray_centre_plan.py b/src/hyperion/experiment_plans/flyscan_xray_centre_plan.py index 723f023ae..57784af2d 100755 --- a/src/hyperion/experiment_plans/flyscan_xray_centre_plan.py +++ b/src/hyperion/experiment_plans/flyscan_xray_centre_plan.py @@ -21,7 +21,7 @@ from dodal.devices.flux import Flux from dodal.devices.panda_fast_grid_scan import PandAFastGridScan from dodal.devices.robot import BartRobot -from dodal.devices.s4_slit_gaps import S4SlitGaps +from dodal.devices.slits import Slits from dodal.devices.smargon import Smargon, StubPosition from dodal.devices.synchrotron import Synchrotron from dodal.devices.undulator import Undulator @@ -76,7 +76,7 @@ class FlyScanXRayCentreComposite: eiger: EigerDetector fast_grid_scan: FastGridScan flux: Flux - s4_slit_gaps: S4SlitGaps + s4_slit_gaps: Slits smargon: Smargon undulator: Undulator synchrotron: Synchrotron diff --git a/src/hyperion/experiment_plans/grid_detect_then_xray_centre_plan.py b/src/hyperion/experiment_plans/grid_detect_then_xray_centre_plan.py index 45a7799ac..79f83556b 100644 --- a/src/hyperion/experiment_plans/grid_detect_then_xray_centre_plan.py +++ b/src/hyperion/experiment_plans/grid_detect_then_xray_centre_plan.py @@ -19,7 +19,7 @@ from dodal.devices.oav.pin_image_recognition import PinTipDetection from dodal.devices.panda_fast_grid_scan import PandAFastGridScan from dodal.devices.robot import BartRobot -from dodal.devices.s4_slit_gaps import S4SlitGaps +from dodal.devices.slits import Slits from dodal.devices.smargon import Smargon from dodal.devices.synchrotron import Synchrotron from dodal.devices.undulator import Undulator @@ -75,7 +75,7 @@ class GridDetectThenXRayCentreComposite: pin_tip_detection: PinTipDetection smargon: Smargon synchrotron: Synchrotron - s4_slit_gaps: S4SlitGaps + s4_slit_gaps: Slits undulator: Undulator xbpm_feedback: XBPMFeedback zebra: Zebra diff --git a/src/hyperion/experiment_plans/robot_load_then_centre_plan.py b/src/hyperion/experiment_plans/robot_load_then_centre_plan.py index 6903b2e86..27e42f4a3 100644 --- a/src/hyperion/experiment_plans/robot_load_then_centre_plan.py +++ b/src/hyperion/experiment_plans/robot_load_then_centre_plan.py @@ -21,7 +21,7 @@ from dodal.devices.oav.pin_image_recognition import PinTipDetection from dodal.devices.panda_fast_grid_scan import PandAFastGridScan from dodal.devices.robot import BartRobot, SampleLocation -from dodal.devices.s4_slit_gaps import S4SlitGaps +from dodal.devices.slits import Slits from dodal.devices.smargon import Smargon, StubPosition from dodal.devices.synchrotron import Synchrotron from dodal.devices.undulator import Undulator @@ -68,7 +68,7 @@ class RobotLoadThenCentreComposite: pin_tip_detection: PinTipDetection smargon: Smargon synchrotron: Synchrotron - s4_slit_gaps: S4SlitGaps + s4_slit_gaps: Slits undulator: Undulator zebra: Zebra zocalo: ZocaloResults diff --git a/src/hyperion/experiment_plans/rotation_scan_plan.py b/src/hyperion/experiment_plans/rotation_scan_plan.py index ca2c5bb52..53fc4f2fa 100644 --- a/src/hyperion/experiment_plans/rotation_scan_plan.py +++ b/src/hyperion/experiment_plans/rotation_scan_plan.py @@ -13,7 +13,7 @@ from dodal.devices.eiger import EigerDetector from dodal.devices.flux import Flux from dodal.devices.robot import BartRobot -from dodal.devices.s4_slit_gaps import S4SlitGaps +from dodal.devices.slits import Slits from dodal.devices.smargon import Smargon from dodal.devices.synchrotron import Synchrotron from dodal.devices.undulator import Undulator @@ -59,7 +59,7 @@ class RotationScanComposite: smargon: Smargon undulator: Undulator synchrotron: Synchrotron - s4_slit_gaps: S4SlitGaps + s4_slit_gaps: Slits zebra: Zebra diff --git a/src/hyperion/external_interaction/callbacks/ispyb_callback_base.py b/src/hyperion/external_interaction/callbacks/ispyb_callback_base.py index f13d5e300..4dbf65c75 100644 --- a/src/hyperion/external_interaction/callbacks/ispyb_callback_base.py +++ b/src/hyperion/external_interaction/callbacks/ispyb_callback_base.py @@ -118,8 +118,8 @@ def _handle_ispyb_hardware_read(self, doc) -> Sequence[ScanDataInfo]: hwscan_data_collection_info = DataCollectionInfo( undulator_gap1=doc["data"]["undulator-current_gap"], synchrotron_mode=synchrotron_mode.value, - slitgap_horizontal=doc["data"]["s4_slit_gaps_xgap"], - slitgap_vertical=doc["data"]["s4_slit_gaps_ygap"], + slitgap_horizontal=doc["data"]["s4_slit_gaps-x_gap"], + slitgap_vertical=doc["data"]["s4_slit_gaps-y_gap"], ) scan_data_infos = self.populate_info_for_update( hwscan_data_collection_info, self.params diff --git a/tests/conftest.py b/tests/conftest.py index bc05e7c22..61ce74b85 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -31,7 +31,7 @@ from dodal.devices.flux import Flux from dodal.devices.oav.oav_detector import OAVConfigParams from dodal.devices.robot import BartRobot -from dodal.devices.s4_slit_gaps import S4SlitGaps +from dodal.devices.slits import Slits from dodal.devices.smargon import Smargon from dodal.devices.synchrotron import Synchrotron, SynchrotronMode from dodal.devices.undulator import Undulator @@ -535,7 +535,7 @@ def fake_create_rotation_devices( undulator: Undulator, aperture_scatterguard: ApertureScatterguard, synchrotron: Synchrotron, - s4_slit_gaps: S4SlitGaps, + s4_slit_gaps: Slits, dcm: DCM, robot: BartRobot, done_status, diff --git a/tests/system_tests/experiment_plans/test_plan_system.py b/tests/system_tests/experiment_plans/test_plan_system.py index 8a1d9aeeb..1b5ea8dd6 100644 --- a/tests/system_tests/experiment_plans/test_plan_system.py +++ b/tests/system_tests/experiment_plans/test_plan_system.py @@ -3,7 +3,7 @@ from bluesky.run_engine import RunEngine from dodal.beamlines import i03 from dodal.devices.aperturescatterguard import ApertureScatterguard -from dodal.devices.s4_slit_gaps import S4SlitGaps +from dodal.devices.slits import Slits from dodal.devices.undulator import Undulator from hyperion.device_setup_plans.read_hardware_for_setup import ( @@ -20,7 +20,7 @@ async def test_getting_data_for_ispyb(): f"{CONST.SIM.INSERTION_PREFIX}-MO-SERVC-01:", name="undulator" ) synchrotron = i03.synchrotron(fake_with_ophyd_sim=True) - slit_gaps = S4SlitGaps(f"{CONST.SIM.BEAMLINE}-AL-SLITS-04:", name="slits") + slit_gaps = Slits(f"{CONST.SIM.BEAMLINE}-AL-SLITS-04:", name="slits") attenuator = i03.attenuator(fake_with_ophyd_sim=True) flux = i03.flux(fake_with_ophyd_sim=True) dcm = i03.dcm(fake_with_ophyd_sim=True) @@ -28,12 +28,12 @@ async def test_getting_data_for_ispyb(): prefix=f"{CONST.SIM.BEAMLINE}-AL-APSG-04:", name="ao_sg" ) - undulator.wait_for_connection() + await undulator.connect() await synchrotron.connect() - slit_gaps.wait_for_connection() + await slit_gaps.connect() attenuator.wait_for_connection() flux.wait_for_connection() - aperture_scatterguard.wait_for_connection() + await aperture_scatterguard.connect() robot = i03.robot(fake_with_ophyd_sim=True) RE = RunEngine() 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 b2c128525..cde16615d 100644 --- a/tests/system_tests/external_interaction/test_ispyb_dev_connection.py +++ b/tests/system_tests/external_interaction/test_ispyb_dev_connection.py @@ -12,7 +12,7 @@ from bluesky.run_engine import RunEngine from dodal.devices.attenuator import Attenuator from dodal.devices.flux import Flux -from dodal.devices.s4_slit_gaps import S4SlitGaps +from dodal.devices.slits import Slits from dodal.devices.synchrotron import Synchrotron, SynchrotronMode from dodal.devices.undulator import Undulator from ophyd.status import Status @@ -611,8 +611,12 @@ def test_ispyb_deposition_in_gridscan( fetch_datacollection_position_attribute: Callable[..., Any], ): os.environ["ISPYB_CONFIG_PATH"] = CONST.SIM.DEV_ISPYB_DATABASE_CFG - grid_detect_then_xray_centre_composite.s4_slit_gaps.xgap.user_readback.sim_put(0.1) # type: ignore - grid_detect_then_xray_centre_composite.s4_slit_gaps.ygap.user_readback.sim_put(0.1) # type: ignore + set_mock_value( + grid_detect_then_xray_centre_composite.s4_slit_gaps.x_gap.user_readback, 0.1 + ) + set_mock_value( + grid_detect_then_xray_centre_composite.s4_slit_gaps.y_gap.user_readback, 0.1 + ) ispyb_callback = GridscanISPyBCallback() RE.subscribe(ispyb_callback) RE( @@ -812,7 +816,7 @@ def test_ispyb_deposition_in_rotation_plan( undulator: Undulator, attenuator: Attenuator, synchrotron: Synchrotron, - s4_slit_gaps: S4SlitGaps, + s4_slit_gaps: Slits, flux: Flux, robot, fake_create_devices: dict[str, Any], @@ -847,11 +851,13 @@ def test_ispyb_deposition_in_rotation_plan( fake_create_rotation_devices.synchrotron.topup_start_countdown, # pyright: ignore -1, ) - fake_create_rotation_devices.s4_slit_gaps.xgap.user_readback.sim_put( # pyright: ignore - test_slit_gap_horiz + set_mock_value( + fake_create_rotation_devices.s4_slit_gaps.x_gap.user_readback, + test_slit_gap_horiz, ) - fake_create_rotation_devices.s4_slit_gaps.ygap.user_readback.sim_put( # pyright: ignore - test_slit_gap_vert + set_mock_value( + fake_create_rotation_devices.s4_slit_gaps.y_gap.user_readback, + test_slit_gap_vert, ) test_rotation_params.detector_params.expected_energy_ev = energy_ev diff --git a/tests/unit_tests/experiment_plans/conftest.py b/tests/unit_tests/experiment_plans/conftest.py index e5e19dbf9..42bb3d3ee 100644 --- a/tests/unit_tests/experiment_plans/conftest.py +++ b/tests/unit_tests/experiment_plans/conftest.py @@ -40,8 +40,8 @@ def make_event_doc(data, descriptor="abc123") -> Event: BASIC_PRE_SETUP_DOC = { "undulator-current_gap": 0, "synchrotron-synchrotron_mode": SynchrotronMode.USER, - "s4_slit_gaps_xgap": 0, - "s4_slit_gaps_ygap": 0, + "s4_slit_gaps-x_gap": 0, + "s4_slit_gaps-y_gap": 0, } 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 a92ddd443..584326262 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 @@ -199,8 +199,13 @@ def test_read_hardware_for_ispyb_updates_from_ophyd_devices( xgap_test_value = 0.1234 ygap_test_value = 0.2345 - fake_fgs_composite.s4_slit_gaps.xgap.user_readback.sim_put(xgap_test_value) # type: ignore - fake_fgs_composite.s4_slit_gaps.ygap.user_readback.sim_put(ygap_test_value) # type: ignore + set_mock_value( + fake_fgs_composite.s4_slit_gaps.x_gap.user_readback, xgap_test_value + ) + set_mock_value( + fake_fgs_composite.s4_slit_gaps.y_gap.user_readback, ygap_test_value + ) + flux_test_value = 10.0 fake_fgs_composite.flux.flux_reading.sim_put(flux_test_value) # type: ignore @@ -246,8 +251,8 @@ def test_read_hardware_for_ispyb_updates_from_ophyd_devices( { "undulator-current_gap": undulator_test_value, "synchrotron-synchrotron_mode": synchrotron_test_value.value, - "s4_slit_gaps_xgap": xgap_test_value, - "s4_slit_gaps_ygap": ygap_test_value, + "s4_slit_gaps-x_gap": xgap_test_value, + "s4_slit_gaps-y_gap": ygap_test_value, }, ) 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 4f34106e4..58e1cedbd 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 @@ -144,8 +144,12 @@ def test_read_hardware_for_ispyb_updates_from_ophyd_devices( xgap_test_value = 0.1234 ygap_test_value = 0.2345 - fake_fgs_composite.s4_slit_gaps.xgap.user_readback.sim_put(xgap_test_value) # type: ignore - fake_fgs_composite.s4_slit_gaps.ygap.user_readback.sim_put(ygap_test_value) # type: ignore + set_mock_value( + fake_fgs_composite.s4_slit_gaps.x_gap.user_readback, xgap_test_value + ) + set_mock_value( + fake_fgs_composite.s4_slit_gaps.y_gap.user_readback, ygap_test_value + ) flux_test_value = 10.0 fake_fgs_composite.flux.flux_reading.sim_put(flux_test_value) # type: ignore @@ -183,8 +187,8 @@ def test_read_hardware_for_ispyb_updates_from_ophyd_devices( { "undulator-current_gap": undulator_test_value, "synchrotron-synchrotron_mode": synchrotron_test_value.value, - "s4_slit_gaps_xgap": xgap_test_value, - "s4_slit_gaps_ygap": ygap_test_value, + "s4_slit_gaps-x_gap": xgap_test_value, + "s4_slit_gaps-y_gap": ygap_test_value, }, ) assert_event( diff --git a/tests/unit_tests/external_interaction/callbacks/conftest.py b/tests/unit_tests/external_interaction/callbacks/conftest.py index 6ddc22872..00cf6bad1 100644 --- a/tests/unit_tests/external_interaction/callbacks/conftest.py +++ b/tests/unit_tests/external_interaction/callbacks/conftest.py @@ -193,8 +193,8 @@ class TestData: "descriptor": "bd45c2e5-2b85-4280-95d7-a9a15800a78b", "time": 1666604299.828203, "data": { - "s4_slit_gaps_xgap": 0.1234, - "s4_slit_gaps_ygap": 0.2345, + "s4_slit_gaps-x_gap": 0.1234, + "s4_slit_gaps-y_gap": 0.2345, "synchrotron-synchrotron_mode": SynchrotronMode.USER, "undulator-current_gap": 1.234, },