diff --git a/src/hyperion/experiment_plans/experiment_registry.py b/src/hyperion/experiment_plans/experiment_registry.py index 038371b98..28bfa7ba0 100644 --- a/src/hyperion/experiment_plans/experiment_registry.py +++ b/src/hyperion/experiment_plans/experiment_registry.py @@ -2,7 +2,7 @@ from typing import Callable, TypedDict, Union -from dodal.devices.fast_grid_scan import GridScanParams, PandAGridScanParams +from dodal.devices.fast_grid_scan import PandAGridScanParams, ZebraGridScanParams from dodal.parameters.experiment_parameter_base import AbstractExperimentWithBeamParams import hyperion.experiment_plans.flyscan_xray_centre_plan as flyscan_xray_centre_plan @@ -61,7 +61,7 @@ class ExperimentRegistryEntry(TypedDict): callbacks_factory: CallbacksFactory -EXPERIMENT_TYPES = Union[GridScanParams, RotationScanParams] +EXPERIMENT_TYPES = Union[ZebraGridScanParams, RotationScanParams] PLAN_REGISTRY: dict[str, ExperimentRegistryEntry] = { "panda_flyscan_xray_centre": { "setup": panda_flyscan_xray_centre_plan.create_devices, @@ -72,7 +72,7 @@ class ExperimentRegistryEntry(TypedDict): "flyscan_xray_centre": { "setup": flyscan_xray_centre_plan.create_devices, "internal_param_type": ThreeDGridScan, - "experiment_param_type": GridScanParams, + "experiment_param_type": ZebraGridScanParams, "callbacks_factory": create_gridscan_callbacks, }, "grid_detect_then_xray_centre": { diff --git a/src/hyperion/experiment_plans/flyscan_xray_centre_plan.py b/src/hyperion/experiment_plans/flyscan_xray_centre_plan.py index 1043733c2..690d30c62 100755 --- a/src/hyperion/experiment_plans/flyscan_xray_centre_plan.py +++ b/src/hyperion/experiment_plans/flyscan_xray_centre_plan.py @@ -18,6 +18,7 @@ from dodal.devices.fast_grid_scan import ( FastGridScanCommon, PandAFastGridScan, + ZebraFastGridScan, ) from dodal.devices.fast_grid_scan import set_fast_grid_scan_params as set_flyscan_params from dodal.devices.flux import Flux @@ -65,7 +66,7 @@ from hyperion.utils.context import device_composite_from_context if TYPE_CHECKING: - PandaOrZebraGridscan = FastGridScan | PandAFastGridScan + PandaOrZebraGridscan = ZebraFastGridScan | PandAFastGridScan from scanspec.core import AxesPoints, Axis @@ -78,7 +79,7 @@ class FlyScanXRayCentreComposite: backlight: Backlight dcm: DCM eiger: EigerDetector - fast_grid_scan: FastGridScan + zebra_fast_grid_scan: ZebraFastGridScan flux: Flux s4_slit_gaps: S4SlitGaps smargon: Smargon @@ -239,7 +240,7 @@ def run_gridscan( ) yield from read_hardware_for_nexus_writer(fgs_composite.eiger) - fgs_motors = fgs_composite.fast_grid_scan + fgs_motors = fgs_composite.zebra_fast_grid_scan LOGGER.info("Setting fgs params") yield from set_flyscan_params(fgs_motors, parameters.experiment_params) 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 e0f6bc670..67bb4dfee 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 @@ -53,7 +53,7 @@ from hyperion.parameters.gridscan import GridScanWithEdgeDetect from hyperion.parameters.plan_specific.gridscan_internal_params import ( GridscanInternalParameters, - GridScanParams, + ZebraGridScanParams, ) from hyperion.parameters.plan_specific.panda.panda_gridscan_internal_params import ( PandAGridscanInternalParameters, @@ -75,7 +75,7 @@ class GridDetectThenXRayCentreComposite: dcm: DCM detector_motion: DetectorMotion eiger: EigerDetector - fast_grid_scan: ZebraFastGridScan + zebra_fast_grid_scan: ZebraFastGridScan flux: Flux oav: OAV pin_tip_detection: PinTipDetection @@ -103,7 +103,7 @@ def create_devices(context: BlueskyContext) -> GridDetectThenXRayCentreComposite def create_parameters_for_flyscan_xray_centre( grid_scan_with_edge_params: GridScanWithEdgeDetect, - grid_parameters: GridScanParams, + grid_parameters: ZebraGridScanParams, ) -> GridscanInternalParameters: old_params = grid_scan_with_edge_params.old_parameters() params_json = json.loads(old_params.json()) @@ -203,7 +203,7 @@ def run_grid_detection_plan( zebra=composite.zebra, zocalo=composite.zocalo, panda=composite.panda, - fast_grid_scan=composite.fast_grid_scan, + zebra_fast_grid_scan=composite.zebra_fast_grid_scan, dcm=composite.dcm, robot=composite.robot, ) 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 b31c9d3f5..d32ba4294 100644 --- a/src/hyperion/experiment_plans/robot_load_then_centre_plan.py +++ b/src/hyperion/experiment_plans/robot_load_then_centre_plan.py @@ -15,7 +15,7 @@ from dodal.devices.detector.det_resolution import resolution from dodal.devices.detector.detector_motion import DetectorMotion from dodal.devices.eiger import EigerDetector -from dodal.devices.fast_grid_scan import FastGridScan, PandAFastGridScan +from dodal.devices.fast_grid_scan import PandAFastGridScan, ZebraFastGridScan from dodal.devices.flux import Flux from dodal.devices.focusing_mirror import FocusingMirror, VFMMirrorVoltages from dodal.devices.oav.oav_detector import OAV @@ -68,7 +68,7 @@ class RobotLoadThenCentreComposite: backlight: Backlight detector_motion: DetectorMotion eiger: EigerDetector - fast_grid_scan: FastGridScan + zebra_fast_grid_scan: ZebraFastGridScan flux: Flux oav: OAV pin_tip_detection: PinTipDetection diff --git a/src/hyperion/external_interaction/callbacks/grid_detection_callback.py b/src/hyperion/external_interaction/callbacks/grid_detection_callback.py index 45cd5c17e..06076ce91 100644 --- a/src/hyperion/external_interaction/callbacks/grid_detection_callback.py +++ b/src/hyperion/external_interaction/callbacks/grid_detection_callback.py @@ -1,6 +1,6 @@ import numpy as np from bluesky.callbacks import CallbackBase -from dodal.devices.fast_grid_scan import GridScanParams, PandAGridScanParams +from dodal.devices.fast_grid_scan import PandAGridScanParams, ZebraGridScanParams from dodal.devices.oav.oav_detector import OAVConfigParams from event_model.documents import Event @@ -61,8 +61,8 @@ def event(self, doc: Event): self.z_step_size_mm = box_width_px * self.oav_params.micronsPerYPixel / 1000 return doc - def get_grid_parameters(self) -> GridScanParams: - return GridScanParams( + def get_grid_parameters(self) -> ZebraGridScanParams: + return ZebraGridScanParams( transmission_fraction=1.0, dwell_time_ms=self.exposure_time * 1000, x_start=self.start_positions[0][0], diff --git a/src/hyperion/parameters/gridscan.py b/src/hyperion/parameters/gridscan.py index 8da34a3ac..6744db273 100644 --- a/src/hyperion/parameters/gridscan.py +++ b/src/hyperion/parameters/gridscan.py @@ -4,8 +4,7 @@ import numpy as np from dodal.devices.detector import DetectorDistanceToBeamXYConverter, DetectorParams -from dodal.devices.fast_grid_scan import GridScanParams -from dodal.devices.panda_fast_grid_scan import PandAGridScanParams +from dodal.devices.fast_grid_scan import PandAGridScanParams, ZebraGridScanParams from pydantic import Field from scanspec.core import Path as ScanPath from scanspec.specs import Line, Static @@ -205,8 +204,8 @@ class ThreeDGridScan(SpecifiedGridScan, SplitScan): z_steps: int = Field(gt=0) @property - def FGS_params(self) -> GridScanParams: - return GridScanParams( + def FGS_params(self) -> ZebraGridScanParams: + return ZebraGridScanParams( x_steps=self.x_steps, y_steps=self.y_steps, z_steps=self.z_steps, diff --git a/src/hyperion/parameters/plan_specific/gridscan_internal_params.py b/src/hyperion/parameters/plan_specific/gridscan_internal_params.py index 22ffcff7f..d91fa8131 100644 --- a/src/hyperion/parameters/plan_specific/gridscan_internal_params.py +++ b/src/hyperion/parameters/plan_specific/gridscan_internal_params.py @@ -4,7 +4,7 @@ import numpy as np from dodal.devices.detector import DetectorParams, TriggerMode -from dodal.devices.fast_grid_scan import GridAxis, GridScanParams +from dodal.devices.fast_grid_scan import GridAxis, ZebraGridScanParams from pydantic import validator from scanspec.core import Path as ScanPath from scanspec.specs import Line @@ -40,7 +40,7 @@ class Config: class GridscanInternalParameters(InternalParameters): - experiment_params: GridScanParams + experiment_params: ZebraGridScanParams hyperion_params: GridscanHyperionParameters class Config: @@ -64,11 +64,11 @@ def _preprocess_experiment_params( cls, experiment_params: dict[str, Any], ): - if isinstance(experiment_params, GridScanParams): + if isinstance(experiment_params, ZebraGridScanParams): return experiment_params - return GridScanParams( + return ZebraGridScanParams( **extract_experiment_params_from_flat_dict( - GridScanParams, experiment_params + ZebraGridScanParams, experiment_params ) ) @@ -78,7 +78,7 @@ def _preprocess_hyperion_params( ): if isinstance(all_params.get("hyperion_params"), GridscanHyperionParameters): return all_params["hyperion_params"] - experiment_params: GridScanParams = values["experiment_params"] + experiment_params: ZebraGridScanParams = values["experiment_params"] all_params["num_images"] = experiment_params.get_num_images() all_params["position"] = np.array(all_params["position"]) all_params["omega_increment"] = 0 diff --git a/tests/conftest.py b/tests/conftest.py index 2406f6869..d208e15b7 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,3 +1,4 @@ +import asyncio import json import logging import sys @@ -580,7 +581,7 @@ async def fake_fgs_composite( dcm=dcm, # We don't use the eiger fixture here because .unstage() is used in some tests eiger=i03.eiger(fake_with_ophyd_sim=True), - fast_grid_scan=i03.fast_grid_scan(fake_with_ophyd_sim=True), + zebra_fast_grid_scan=i03.zebra_fast_grid_scan(fake_with_ophyd_sim=True), flux=i03.flux(fake_with_ophyd_sim=True), s4_slit_gaps=i03.s4_slit_gaps(fake_with_ophyd_sim=True), smargon=smargon, @@ -636,8 +637,8 @@ async def mock_complete(result): side_effect=partial(mock_complete, test_result) ) # type: ignore fake_composite.zocalo.timeout_s = 3 - set_sim_value(fake_composite.fast_grid_scan.scan_invalid, False) - set_sim_value(fake_composite.fast_grid_scan.position_counter, 0) + set_sim_value(fake_composite.zebra_fast_grid_scan.scan_invalid, False) + set_sim_value(fake_composite.zebra_fast_grid_scan.position_counter, 0) fake_composite.smargon.x.max_velocity.sim_put(10) # type: ignore set_sim_value(fake_composite.robot.barcode.bare_signal, ["BARCODE"]) diff --git a/tests/system_tests/experiment_plans/test_fgs_plan.py b/tests/system_tests/experiment_plans/test_fgs_plan.py index 0b1fd4ef1..6acbc632e 100644 --- a/tests/system_tests/experiment_plans/test_fgs_plan.py +++ b/tests/system_tests/experiment_plans/test_fgs_plan.py @@ -87,7 +87,7 @@ async def fxc_composite(): backlight=i03.backlight(), dcm=i03.dcm(fake_with_ophyd_sim=True), eiger=i03.eiger(), - fast_grid_scan=i03.fast_grid_scan(), + zebra_fast_grid_scan=i03.zebra_fast_grid_scan(), flux=i03.flux(fake_with_ophyd_sim=True), robot=i03.robot(fake_with_ophyd_sim=True), panda=i03.panda(fake_with_ophyd_sim=True), @@ -308,8 +308,8 @@ def test_complete_xray_centre_plan_with_no_callbacks_falls_back_to_centre( callbacks, done_status, ): - fxc_composite.fast_grid_scan.kickoff = MagicMock(return_value=done_status) - fxc_composite.fast_grid_scan.complete = MagicMock(return_value=done_status) + fxc_composite.zebra_fast_grid_scan.kickoff = MagicMock(return_value=done_status) + fxc_composite.zebra_fast_grid_scan.complete = MagicMock(return_value=done_status) params.hyperion_params.detector_params.directory = "./tmp" params.hyperion_params.detector_params.prefix = str(uuid.uuid1()) @@ -346,8 +346,8 @@ def test_complete_xray_centre_plan_with_callbacks_moves_to_centre( callbacks, done_status, ): - fxc_composite.fast_grid_scan.kickoff = MagicMock(return_value=done_status) - fxc_composite.fast_grid_scan.complete = MagicMock(return_value=done_status) + fxc_composite.zebra_fast_grid_scan.kickoff = MagicMock(return_value=done_status) + fxc_composite.zebra_fast_grid_scan.complete = MagicMock(return_value=done_status) params.hyperion_params.detector_params.directory = "./tmp" params.hyperion_params.detector_params.prefix = str(uuid.uuid1()) diff --git a/tests/unit_tests/device_setup_plans/test_setup_panda.py b/tests/unit_tests/device_setup_plans/test_setup_panda.py index 5618097b5..39c796de0 100644 --- a/tests/unit_tests/device_setup_plans/test_setup_panda.py +++ b/tests/unit_tests/device_setup_plans/test_setup_panda.py @@ -2,6 +2,8 @@ import numpy as np import pytest +from bluesky.plan_stubs import null +from bluesky.run_engine import RunEngine from dodal.devices.fast_grid_scan import PandAGridScanParams from ophyd_async.panda import SeqTrigger @@ -177,7 +179,9 @@ def assert_set_table_has_been_waited_on(*args, **kwargs): ), patch( "hyperion.device_setup_plans.setup_panda.bps.wait", MagicMock(side_effect=handle_wait), - ), patch("hyperion.device_setup_plans.setup_panda.load_device"), patch( + ), patch( + "hyperion.device_setup_plans.setup_panda.load_device" + ), patch( "hyperion.device_setup_plans.setup_panda.bps.abs_set" ): RE( diff --git a/tests/unit_tests/experiment_plans/conftest.py b/tests/unit_tests/experiment_plans/conftest.py index 7926b8caf..79c135cb1 100644 --- a/tests/unit_tests/experiment_plans/conftest.py +++ b/tests/unit_tests/experiment_plans/conftest.py @@ -4,7 +4,7 @@ import pytest from bluesky.utils import Msg -from dodal.devices.fast_grid_scan import FastGridScan +from dodal.devices.fast_grid_scan import ZebraFastGridScan from dodal.devices.oav.oav_detector import OAVConfigParams from dodal.devices.synchrotron import SynchrotronMode from dodal.devices.zocalo import ZocaloResults, ZocaloTrigger @@ -165,8 +165,8 @@ def simple_beamline(detector_motion, oav, smargon, synchrotron, test_config_file magic_mock.detector_motion = detector_motion magic_mock.zocalo = make_fake_device(ZocaloResults)() magic_mock.dcm = dcm - scan = make_fake_device(FastGridScan)("prefix", name="fake_fgs") - magic_mock.fast_grid_scan = scan + scan = make_fake_device(ZebraFastGridScan)("prefix", name="fake_fgs") + magic_mock.zebra_fast_grid_scan = scan magic_mock.synchrotron = synchrotron oav.zoom_controller.frst.set("7.5x") oav.parameters = OAVConfigParams( 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 9109549f6..279f214a9 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 @@ -15,7 +15,7 @@ EIGER_TYPE_EIGER2_X_4M, EIGER_TYPE_EIGER2_X_16M, ) -from dodal.devices.fast_grid_scan import FastGridScan +from dodal.devices.fast_grid_scan import ZebraFastGridScan from dodal.devices.synchrotron import SynchrotronMode from dodal.devices.zocalo import ZocaloStartInfo from ophyd.status import Status @@ -489,8 +489,8 @@ def test_waits_for_motion_program( done_status, ): fake_fgs_composite.eiger.unstage = MagicMock(return_value=done_status) - clear_device("fast_grid_scan") - fgs = i03.fast_grid_scan(fake_with_ophyd_sim=True) + clear_device("zebra_fast_grid_scan") + fgs = i03.zebra_fast_grid_scan(fake_with_ophyd_sim=True) fgs.KICKOFF_TIMEOUT = 0.1 fgs.complete = MagicMock(return_value=done_status) set_sim_value(fgs.motion_program.running, 1) @@ -523,7 +523,7 @@ def test_waits_for_motion_program( ) ) assert res.exit_status == "success" - clear_device("fast_grid_scan") + clear_device("zebra_fast_grid_scan") @patch( "hyperion.experiment_plans.flyscan_xray_centre_plan.run_gridscan", autospec=True @@ -669,7 +669,7 @@ def wrapped_gridscan_and_move(): def test_GIVEN_scan_already_valid_THEN_wait_for_GRIDSCAN_returns_immediately( self, patch_sleep: MagicMock, RE: RunEngine ): - test_fgs: FastGridScan = i03.fast_grid_scan(fake_with_ophyd_sim=True) + test_fgs: ZebraFastGridScan = i03.zebra_fast_grid_scan(fake_with_ophyd_sim=True) set_sim_value(test_fgs.position_counter, 0) set_sim_value(test_fgs.scan_invalid, False) @@ -684,7 +684,7 @@ def test_GIVEN_scan_already_valid_THEN_wait_for_GRIDSCAN_returns_immediately( def test_GIVEN_scan_not_valid_THEN_wait_for_GRIDSCAN_raises_and_sleeps_called( self, patch_sleep: MagicMock, RE: RunEngine ): - test_fgs: FastGridScan = i03.fast_grid_scan(fake_with_ophyd_sim=True) + test_fgs: ZebraFastGridScan = i03.zebra_fast_grid_scan(fake_with_ophyd_sim=True) set_sim_value(test_fgs.scan_invalid, True) set_sim_value(test_fgs.position_counter, 0) @@ -860,7 +860,7 @@ def test_kickoff_and_complete_gridscan_triggers_zocalo( RE.subscribe(ispyb_cb) RE( kickoff_and_complete_gridscan( - fake_fgs_composite.fast_grid_scan, + fake_fgs_composite.zebra_fast_grid_scan, fake_fgs_composite.eiger, fake_fgs_composite.synchrotron, zocalo_env, diff --git a/tests/unit_tests/experiment_plans/test_grid_detect_then_xray_centre_plan.py b/tests/unit_tests/experiment_plans/test_grid_detect_then_xray_centre_plan.py index 9b05d9adf..043e18fa2 100644 --- a/tests/unit_tests/experiment_plans/test_grid_detect_then_xray_centre_plan.py +++ b/tests/unit_tests/experiment_plans/test_grid_detect_then_xray_centre_plan.py @@ -61,7 +61,7 @@ def grid_detect_devices(aperture_scatterguard, backlight, detector_motion): backlight=backlight, detector_motion=detector_motion, eiger=MagicMock(), - fast_grid_scan=MagicMock(), + zebra_fast_grid_scan=MagicMock(), flux=MagicMock(), oav=MagicMock(), pin_tip_detection=MagicMock(), 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 45ce57155..4a64f0922 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 @@ -7,6 +7,7 @@ import numpy as np import pytest from bluesky.run_engine import RunEngine +from dodal.beamlines import i03 from dodal.devices.detector.det_dim_constants import ( EIGER2_X_4M_DIMENSION, EIGER_TYPE_EIGER2_X_4M, @@ -14,7 +15,6 @@ ) from dodal.devices.fast_grid_scan import PandAFastGridScan from dodal.devices.synchrotron import SynchrotronMode -from ophyd.sim import make_fake_device from ophyd.status import Status from ophyd_async.core import set_sim_value @@ -73,6 +73,8 @@ "tests/test_data/parameter_json_files/panda_test_parameters.json" ) +ReWithSubs = tuple[RunEngine, Tuple[GridscanNexusFileCallback, GridscanISPyBCallback]] + @pytest.fixture def RE_with_subs(RE: RunEngine, mock_subscriptions): @@ -515,6 +517,14 @@ def wrapped_run_gridscan_and_move(): call = app_to_comment.call_args_list[0] assert "Zocalo found no crystals in this gridscan" in call.args[1] + @patch( + "hyperion.experiment_plans.panda_flyscan_xray_centre_plan.bps.complete", + autospec=True, + ) + @patch( + "hyperion.experiment_plans.panda_flyscan_xray_centre_plan.bps.kickoff", + autospec=True, + ) @patch( "hyperion.experiment_plans.panda_flyscan_xray_centre_plan.bps.mv", autospec=True ) @@ -528,12 +538,12 @@ def wrapped_run_gridscan_and_move(): ) def test_GIVEN_no_results_from_zocalo_WHEN_communicator_wait_for_results_called_THEN_fallback_centre_used( self, - mock_setup_panda_for_flyscan: MagicMock, + mock_setup_panda: MagicMock, move_xyz: MagicMock, mock_mv: MagicMock, - RE_with_subs: tuple[ - RunEngine, Tuple[GridscanNexusFileCallback, GridscanISPyBCallback] - ], + mock_kickoff: MagicMock, + mock_complete: MagicMock, + RE_with_subs: ReWithSubs, test_panda_fgs_params: PandAGridscanInternalParameters, fake_fgs_composite: FlyScanXRayCentreComposite, done_status, @@ -550,7 +560,6 @@ def test_GIVEN_no_results_from_zocalo_WHEN_communicator_wait_for_results_called_ fake_fgs_composite.smargon.x.user_readback.sim_put(initial_x_y_z[0]) # type: ignore fake_fgs_composite.smargon.y.user_readback.sim_put(initial_x_y_z[1]) # type: ignore fake_fgs_composite.smargon.z.user_readback.sim_put(initial_x_y_z[2]) # type: ignore - mock_zocalo_trigger(fake_fgs_composite.zocalo, []) def wrapped_run_gridscan_and_move(): run_generic_ispyb_handler_setup(ispyb_cb, test_panda_fgs_params) @@ -559,6 +568,8 @@ def wrapped_run_gridscan_and_move(): test_panda_fgs_params, ) + mock_zocalo_trigger(fake_fgs_composite.zocalo, []) + RE( ispyb_activation_wrapper( wrapped_run_gridscan_and_move(), test_panda_fgs_params @@ -656,12 +667,10 @@ def wrapped_run_gridscan_and_move(): def test_GIVEN_scan_already_valid_THEN_wait_for_GRIDSCAN_returns_immediately( self, patch_sleep: MagicMock, RE: RunEngine ): - test_fgs: PandAFastGridScan = make_fake_device(PandAFastGridScan)( - "prefix", name="fake_fgs" - ) + test_fgs: PandAFastGridScan = i03.panda_fast_grid_scan(fake_with_ophyd_sim=True) - test_fgs.scan_invalid.sim_put(False) # type: ignore - test_fgs.position_counter.sim_put(0) # type: ignore + set_sim_value(test_fgs.position_counter, 0) + set_sim_value(test_fgs.scan_invalid, False) RE(wait_for_gridscan_valid(test_fgs)) @@ -674,12 +683,10 @@ def test_GIVEN_scan_already_valid_THEN_wait_for_GRIDSCAN_returns_immediately( def test_GIVEN_scan_not_valid_THEN_wait_for_GRIDSCAN_raises_and_sleeps_called( self, patch_sleep: MagicMock, RE: RunEngine ): - test_fgs: PandAFastGridScan = make_fake_device(PandAFastGridScan)( - "prefix", name="fake_fgs" - ) + test_fgs: PandAFastGridScan = i03.panda_fast_grid_scan(fake_with_ophyd_sim=True) - test_fgs.scan_invalid.sim_put(True) # type: ignore - test_fgs.position_counter.sim_put(0) # type: ignore + set_sim_value(test_fgs.scan_invalid, True) + set_sim_value(test_fgs.position_counter, 0) with pytest.raises(WarningException): RE(wait_for_gridscan_valid(test_fgs)) @@ -771,8 +778,12 @@ def test_when_grid_scan_ran_then_eiger_disarmed_before_zocalo_end( "hyperion.experiment_plans.panda_flyscan_xray_centre_plan.bps.complete", autospec=True, ) + @patch( + "hyperion.experiment_plans.flyscan_xray_centre_plan.bps.kickoff", autospec=True + ) def test_fgs_arms_eiger_without_grid_detect( self, + mock_kickoff, mock_complete, mock_wait, fake_fgs_composite: FlyScanXRayCentreComposite, @@ -786,6 +797,9 @@ def test_fgs_arms_eiger_without_grid_detect( fake_fgs_composite.eiger.stage.assert_called_once() fake_fgs_composite.eiger.unstage.assert_called_once() + @patch( + "hyperion.experiment_plans.flyscan_xray_centre_plan.bps.kickoff", autospec=True + ) @patch( "hyperion.experiment_plans.panda_flyscan_xray_centre_plan.bps.wait", autospec=True, @@ -798,6 +812,7 @@ def test_when_grid_scan_fails_then_detector_disarmed_and_correct_exception_retur self, mock_complete, mock_wait, + mock_kickoff, fake_fgs_composite: FlyScanXRayCentreComposite, test_panda_fgs_params: PandAGridscanInternalParameters, RE: RunEngine, diff --git a/tests/unit_tests/experiment_plans/test_pin_centre_then_xray_centre_plan.py b/tests/unit_tests/experiment_plans/test_pin_centre_then_xray_centre_plan.py index 5451e3799..e44fb1f16 100644 --- a/tests/unit_tests/experiment_plans/test_pin_centre_then_xray_centre_plan.py +++ b/tests/unit_tests/experiment_plans/test_pin_centre_then_xray_centre_plan.py @@ -4,7 +4,7 @@ from bluesky.run_engine import RunEngine from bluesky.utils import Msg from dodal.devices.detector.detector_motion import ShutterState -from dodal.devices.fast_grid_scan import GridScanParams +from dodal.devices.fast_grid_scan import ZebraGridScanParams from dodal.devices.synchrotron import SynchrotronMode from hyperion.experiment_plans.pin_centre_then_xray_centre_plan import ( @@ -80,21 +80,23 @@ def test_when_pin_centre_xray_centre_called_then_detector_positioned( test_config_files, sim_run_engine, ): - mock_grid_callback.return_value.get_grid_parameters.return_value = GridScanParams( - transmission_fraction=0.01, - dwell_time_ms=0, - x_start=0, - y1_start=0, - y2_start=0, - z1_start=0, - z2_start=0, - x_steps=10, - y_steps=10, - z_steps=10, - x_step_size=0.1, - y_step_size=0.1, - z_step_size=0.1, - set_stub_offsets=False, + mock_grid_callback.return_value.get_grid_parameters.return_value = ( + ZebraGridScanParams( + transmission_fraction=0.01, + dwell_time_ms=0, + x_start=0, + y1_start=0, + y2_start=0, + z1_start=0, + z2_start=0, + x_steps=10, + y_steps=10, + z_steps=10, + x_step_size=0.1, + y_step_size=0.1, + z_step_size=0.1, + set_stub_offsets=False, + ) ) sim_run_engine.add_handler_for_callback_subscribes() diff --git a/tests/unit_tests/external_interaction/nexus/test_write_nexus.py b/tests/unit_tests/external_interaction/nexus/test_write_nexus.py index 591f2ad14..694238c52 100644 --- a/tests/unit_tests/external_interaction/nexus/test_write_nexus.py +++ b/tests/unit_tests/external_interaction/nexus/test_write_nexus.py @@ -6,7 +6,7 @@ import h5py import numpy as np import pytest -from dodal.devices.fast_grid_scan import GridAxis, GridScanParams +from dodal.devices.fast_grid_scan import GridAxis, ZebraGridScanParams from hyperion.external_interaction.nexus.nexus_utils import ( create_beam_and_attenuator_parameters, @@ -117,7 +117,7 @@ def test_given_dummy_data_then_datafile_written_correctly( dummy_nexus_writers: tuple[NexusWriter, NexusWriter], ): nexus_writer_1, nexus_writer_2 = dummy_nexus_writers - grid_scan_params: GridScanParams = test_fgs_params.experiment_params + grid_scan_params: ZebraGridScanParams = test_fgs_params.experiment_params nexus_writer_1.create_nexus_file(np.uint16) for filename in [nexus_writer_1.nexus_file, nexus_writer_1.master_file]: @@ -213,7 +213,7 @@ def assert_x_data_stride_correct(data_path, grid_scan_params, varying_axis_steps def assert_varying_axis_stride_correct( - axis_data, grid_scan_params: GridScanParams, varying_axis: GridAxis + axis_data, grid_scan_params: ZebraGridScanParams, varying_axis: GridAxis ): assert len(axis_data) == (grid_scan_params.x_steps) * (varying_axis.full_steps) assert axis_data[grid_scan_params.x_steps + 1] - axis_data[0] == pytest.approx( diff --git a/tests/unit_tests/parameters/plan_specific/test_fgs_internal_parameters.py b/tests/unit_tests/parameters/plan_specific/test_fgs_internal_parameters.py index d10fedf1a..04d751b8d 100644 --- a/tests/unit_tests/parameters/plan_specific/test_fgs_internal_parameters.py +++ b/tests/unit_tests/parameters/plan_specific/test_fgs_internal_parameters.py @@ -1,6 +1,6 @@ import numpy as np from dodal.devices.detector.det_dim_constants import EIGER2_X_16M_SIZE -from dodal.devices.fast_grid_scan import GridScanParams +from dodal.devices.fast_grid_scan import ZebraGridScanParams from hyperion.parameters.plan_specific.gridscan_internal_params import ( GridscanInternalParameters, @@ -16,7 +16,7 @@ def test_FGS_parameters_load_from_file(): internal_parameters = GridscanInternalParameters(**params) internal_parameters.json() - assert isinstance(internal_parameters.experiment_params, GridScanParams) + assert isinstance(internal_parameters.experiment_params, ZebraGridScanParams) ispyb_params = internal_parameters.hyperion_params.ispyb_params diff --git a/tests/unit_tests/parameters/test_internal_parameters.py b/tests/unit_tests/parameters/test_internal_parameters.py index 3ce60e297..475af880a 100644 --- a/tests/unit_tests/parameters/test_internal_parameters.py +++ b/tests/unit_tests/parameters/test_internal_parameters.py @@ -4,7 +4,7 @@ import numpy as np import pytest from dodal.devices.detector import DetectorParams -from dodal.devices.fast_grid_scan import GridScanParams +from dodal.devices.fast_grid_scan import ZebraGridScanParams from pydantic import ValidationError from hyperion.external_interaction.ispyb.ispyb_dataclass import ( @@ -176,10 +176,10 @@ def test_hyperion_params_eq(raw_params): def test_get_extracted_experiment_and_flat_hyperion_params(raw_params): flat_params = flatten_dict(raw_params) processed_params = get_extracted_experiment_and_flat_hyperion_params( - GridScanParams, flat_params + ZebraGridScanParams, flat_params ) assert processed_params.get("experiment_params") not in [None, {}] - experiment_params = GridScanParams(**processed_params.get("experiment_params")) + experiment_params = ZebraGridScanParams(**processed_params.get("experiment_params")) assert experiment_params.x_steps == flat_params["x_steps"] assert experiment_params.y_steps == flat_params["y_steps"] assert experiment_params.z_steps == flat_params["z_steps"]