From 3564e163aa892a7c084e9136f4d91cf6156520d4 Mon Sep 17 00:00:00 2001 From: Dominic Oram Date: Tue, 11 Jun 2024 16:37:21 +0100 Subject: [PATCH 1/6] Thaw for a set time straight after robot load --- src/hyperion/experiment_plans/robot_load_then_centre_plan.py | 4 ++++ src/hyperion/parameters/constants.py | 1 + src/hyperion/parameters/gridscan.py | 2 ++ 3 files changed, 7 insertions(+) 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 f6c23550a..e7e1f1bf4 100644 --- a/src/hyperion/experiment_plans/robot_load_then_centre_plan.py +++ b/src/hyperion/experiment_plans/robot_load_then_centre_plan.py @@ -23,6 +23,7 @@ from dodal.devices.s4_slit_gaps import S4SlitGaps from dodal.devices.smargon import Smargon, StubPosition from dodal.devices.synchrotron import Synchrotron +from dodal.devices.thawer import Thawer from dodal.devices.undulator import Undulator from dodal.devices.undulator_dcm import UndulatorDCM from dodal.devices.webcam import Webcam @@ -73,6 +74,7 @@ class RobotLoadThenCentreComposite: zocalo: ZocaloResults panda: HDFPanda panda_fast_grid_scan: PandAFastGridScan + thawer: Thawer # SetEnergyComposite fields vfm: FocusingMirrorWithStripes @@ -182,6 +184,8 @@ def robot_load(): yield from bps.wait("robot_load") + yield from bps.abs_set(composite.thawer.thaw_for_time_s, params.thawing_time) + yield from take_robot_snapshots( composite.oav, composite.webcam, params.snapshot_directory ) diff --git a/src/hyperion/parameters/constants.py b/src/hyperion/parameters/constants.py index c01efcc26..9d1c145ef 100644 --- a/src/hyperion/parameters/constants.py +++ b/src/hyperion/parameters/constants.py @@ -95,6 +95,7 @@ class I03Constants: SHUTTER_TIME_S = 0.06 USE_PANDA_FOR_GRIDSCAN = False USE_GPU_FOR_GRIDSCAN_ANALYSIS = False + THAWING_TIME = 20 @dataclass(frozen=True) diff --git a/src/hyperion/parameters/gridscan.py b/src/hyperion/parameters/gridscan.py index f462f43ad..92ccb4e69 100644 --- a/src/hyperion/parameters/gridscan.py +++ b/src/hyperion/parameters/gridscan.py @@ -108,6 +108,8 @@ class PinTipCentreThenXrayCentre(GridCommon): class RobotLoadThenCentre(GridCommon): + thawing_time: float = Field(default=CONST.I03.THAWING_TIME) + def pin_centre_then_xray_centre_params(self): params = PinTipCentreThenXrayCentre(**self.dict()) return params From 0f53a0124cb90aaed6b485968b0ef3015317fcb7 Mon Sep 17 00:00:00 2001 From: Dominic Oram Date: Tue, 11 Jun 2024 16:39:16 +0100 Subject: [PATCH 2/6] Pin dodal --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 916a359c7..ad1b8f320 100644 --- a/setup.cfg +++ b/setup.cfg @@ -45,7 +45,7 @@ install_requires = ophyd-async >= 0.3a5 bluesky >= 1.13.0a3 blueapi >= 0.4.3-rc1 - dls-dodal @ git+https://github.com/DiamondLightSource/dodal.git@8e62a4db4fc07e1d873f84a155c85105a986649b + dls-dodal @ git+https://github.com/DiamondLightSource/dodal.git@ad2ce126691f10726242ee5f7488eee58ec01ce1 [options.entry_points] console_scripts = From dd6e089d2589ddbfa7e68add58328da2f28641e6 Mon Sep 17 00:00:00 2001 From: Dominic Oram Date: Tue, 11 Jun 2024 16:47:52 +0100 Subject: [PATCH 3/6] Fix tests --- src/hyperion/parameters/gridscan.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/hyperion/parameters/gridscan.py b/src/hyperion/parameters/gridscan.py index 92ccb4e69..9c1e3858f 100644 --- a/src/hyperion/parameters/gridscan.py +++ b/src/hyperion/parameters/gridscan.py @@ -111,8 +111,9 @@ class RobotLoadThenCentre(GridCommon): thawing_time: float = Field(default=CONST.I03.THAWING_TIME) def pin_centre_then_xray_centre_params(self): - params = PinTipCentreThenXrayCentre(**self.dict()) - return params + my_params = self.dict() + del my_params["thawing_time"] + return PinTipCentreThenXrayCentre(**my_params) class SpecifiedGridScan(GridCommon, XyzStarts, WithScan): From 9ed62a6bc1a30dfd79d434c82134b8c5faed463b Mon Sep 17 00:00:00 2001 From: Dominic Oram Date: Mon, 17 Jun 2024 11:29:13 +0100 Subject: [PATCH 4/6] Added test to confirm thawing is turned on for robot_load --- tests/conftest.py | 6 +++ .../test_wait_for_robot_load_then_centre.py | 39 ++++++++++++++++++- 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/tests/conftest.py b/tests/conftest.py index c4616e991..81ba57a89 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -36,6 +36,7 @@ from dodal.devices.s4_slit_gaps import S4SlitGaps from dodal.devices.smargon import Smargon from dodal.devices.synchrotron import Synchrotron, SynchrotronMode +from dodal.devices.thawer import Thawer from dodal.devices.undulator import Undulator from dodal.devices.webcam import Webcam from dodal.devices.zebra import Zebra @@ -444,6 +445,11 @@ def webcam(RE) -> Generator[Webcam, Any, Any]: yield webcam +@pytest.fixture +def thawer(RE) -> Generator[Thawer, Any, Any]: + yield i03.thawer(fake_with_ophyd_sim=True) + + @pytest.fixture def aperture_scatterguard(RE): AperturePositions.LARGE = SingleAperturePosition( diff --git a/tests/unit_tests/experiment_plans/test_wait_for_robot_load_then_centre.py b/tests/unit_tests/experiment_plans/test_wait_for_robot_load_then_centre.py index 54d6da184..31d6133d9 100644 --- a/tests/unit_tests/experiment_plans/test_wait_for_robot_load_then_centre.py +++ b/tests/unit_tests/experiment_plans/test_wait_for_robot_load_then_centre.py @@ -28,7 +28,7 @@ @pytest.fixture def robot_load_composite( - smargon, dcm, robot, aperture_scatterguard, oav, webcam + smargon, dcm, robot, aperture_scatterguard, oav, webcam, thawer ) -> RobotLoadThenCentreComposite: composite: RobotLoadThenCentreComposite = MagicMock() composite.smargon = smargon @@ -40,6 +40,7 @@ def robot_load_composite( composite.aperture_scatterguard.set = MagicMock(return_value=NullStatus()) composite.oav = oav composite.webcam = webcam + composite.thawer = thawer return composite @@ -353,3 +354,39 @@ async def test_when_take_snapshots_called_then_filename_and_directory_set_and_de webcam.trigger.assert_called_once() assert (await webcam.filename.get_value()) == "TIME_webcam_after_load" assert (await webcam.directory.get_value()) == TEST_DIRECTORY + + +@patch( + "hyperion.experiment_plans.robot_load_then_centre_plan.pin_centre_then_xray_centre_plan" +) +@patch( + "hyperion.experiment_plans.robot_load_then_centre_plan.set_energy_plan", + MagicMock(return_value=iter([])), +) +def test_when_plan_run_then_thawing_turned_on_for_expected_time( + mock_centring_plan: MagicMock, + robot_load_composite: RobotLoadThenCentreComposite, + robot_load_then_centre_params_no_energy: RobotLoadThenCentre, + sim_run_engine, +): + robot_load_then_centre_params_no_energy.thawing_time = (thaw_time := 50) + + sim_run_engine.add_handler( + "read", + "dcm-energy_in_kev", + lambda msg: {"dcm-energy_in_kev": {"value": 11.105}}, + ) + + messages = sim_run_engine.simulate_plan( + robot_load_then_centre( + robot_load_composite, + robot_load_then_centre_params_no_energy, + ) + ) + + sim_run_engine.assert_message_and_return_remaining( + messages, + lambda msg: msg.command == "set" + and msg.obj.name == "thawer-thaw_for_time_s" + and msg.args[0] == thaw_time, + ) From f631b74cd127ce07dc44222195148e9b2b36d4e9 Mon Sep 17 00:00:00 2001 From: Dominic Oram Date: Mon, 17 Jun 2024 11:33:34 +0100 Subject: [PATCH 5/6] Pin dodal --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index ad1b8f320..86b40c6c6 100644 --- a/setup.cfg +++ b/setup.cfg @@ -45,7 +45,7 @@ install_requires = ophyd-async >= 0.3a5 bluesky >= 1.13.0a3 blueapi >= 0.4.3-rc1 - dls-dodal @ git+https://github.com/DiamondLightSource/dodal.git@ad2ce126691f10726242ee5f7488eee58ec01ce1 + dls-dodal @ git+https://github.com/DiamondLightSource/dodal.git@aea730cbf97bda5ef1d4b4fe9266c3ac472fdcdc [options.entry_points] console_scripts = From f9d9c60d9532cc6970a55ca028502e7904cc4614 Mon Sep 17 00:00:00 2001 From: Dominic Oram Date: Wed, 26 Jun 2024 11:45:26 +0100 Subject: [PATCH 6/6] Update dodal --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 08128a5e4..3f5cfdc5c 100644 --- a/setup.cfg +++ b/setup.cfg @@ -45,7 +45,7 @@ install_requires = ophyd-async >= 0.3a5 bluesky >= 1.13.0a3 blueapi >= 0.4.3-rc1 - dls-dodal @ git+https://github.com/DiamondLightSource/dodal.git@f20a885e9a7882adaf61ba46cbdaa9828c0dab3c + dls-dodal @ git+https://github.com/DiamondLightSource/dodal.git@a9a116d289abc9e67ce8db08f978ff502705b464 [options.entry_points] console_scripts =