Skip to content

Commit

Permalink
Fix issues from testing (#796)
Browse files Browse the repository at this point in the history
* Use correct PV for checking robot light curtain and do it in the device

* Make sure multi rotations are staging eiger correctly

* Pin dodal

* Fix test
  • Loading branch information
DominicOram authored Feb 13, 2025
1 parent 788b3fe commit 2aff797
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 47 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ dependencies = [
"ophyd == 1.9.0",
"ophyd-async >= 0.9.0a2",
"bluesky >= 1.13",
"dls-dodal @ git+https://github.com/DiamondLightSource/dodal.git",
"dls-dodal @ git+https://github.com/DiamondLightSource/dodal.git@61d2eb609245cb96184c9dbfb8d9af8adef50447",
]


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,6 @@ def do_robot_load(
demand_energy_ev: float | None,
thawing_time: float,
):
error_code = yield from bps.rd(composite.robot.controller_error.code)
# Reset robot if light curtains were tripped
if error_code == 40:
yield from bps.trigger(composite.robot.reset, wait=True)

yield from bps.abs_set(
composite.robot,
sample_location,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,6 @@ def multi_rotation_scan(
],
}
)
@bpp.stage_decorator([eiger])
@transmission_and_xbpm_feedback_for_collection_decorator(
composite.undulator,
composite.xbpm_feedback,
Expand Down Expand Up @@ -471,3 +470,4 @@ def rotation_scan_core(
_multi_rotation_scan(),
group=CONST.WAIT.ROTATION_READY_FOR_DC,
)
yield from bps.unstage(eiger)
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from bluesky.simulators import RunEngineSimulator, assert_message_and_return_remaining
from dodal.devices.oav.oav_parameters import OAVParameters
from dodal.devices.synchrotron import SynchrotronMode
from ophyd.status import Status
from ophyd_async.testing import set_mock_value

from mx_bluesky.common.external_interaction.ispyb.ispyb_store import StoreInIspyb
Expand Down Expand Up @@ -84,7 +85,7 @@ async def test_multi_rotation_plan_runs_multiple_plans_in_one_arm(
)

msgs = assert_message_and_return_remaining(
msgs, lambda msg: msg.command == "stage" and msg.obj.name == "eiger"
msgs, lambda msg: msg.command == "set" and msg.obj.name == "eiger_do_arm"
)[1:]

msgs_within_arming = list(
Expand Down Expand Up @@ -480,3 +481,33 @@ def test_full_multi_rotation_plan_ispyb_interaction_end_to_end(
fourth_upsert_data = upsert_calls[3].args[0]
assert fourth_upsert_data[9] # timestamp
assert fourth_upsert_data[10] == "DataCollection Successful"


@patch(
"mx_bluesky.hyperion.experiment_plans.rotation_scan_plan.check_topup_and_wait_if_necessary",
autospec=True,
)
def test_full_multi_rotation_plan_arms_eiger_asynchronously_and_disarms(
_,
RE: RunEngine,
test_multi_rotation_params: MultiRotationScan,
fake_create_rotation_devices: RotationScanComposite,
oav_parameters_for_rotation: OAVParameters,
):
eiger = fake_create_rotation_devices.eiger
eiger.stage = MagicMock(return_value=Status(done=True, success=True))
eiger.unstage = MagicMock(return_value=Status(done=True, success=True))
eiger.do_arm.set = MagicMock(return_value=Status(done=True, success=True))

_run_multi_rotation_plan(
RE,
test_multi_rotation_params,
fake_create_rotation_devices,
[],
oav_parameters_for_rotation,
)
# Stage will arm the eiger synchonously
eiger.stage.assert_not_called()

eiger.do_arm.set.assert_called_once()
eiger.unstage.assert_called_once()
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@

from mx_bluesky.hyperion.experiment_plans.robot_load_and_change_energy import (
RobotLoadAndEnergyChangeComposite,
SampleLocation,
do_robot_load,
prepare_for_robot_load,
robot_load_and_change_energy_plan,
take_robot_snapshots,
Expand Down Expand Up @@ -167,43 +165,6 @@ async def test_when_prepare_for_robot_load_called_then_moves_as_expected(
aperture_scatterguard.set.assert_called_once_with(ApertureValue.OUT_OF_BEAM) # type: ignore


@patch(
"mx_bluesky.hyperion.experiment_plans.robot_load_and_change_energy.set_energy_plan",
MagicMock(return_value=iter([])),
)
@patch(
"mx_bluesky.hyperion.experiment_plans.robot_load_and_change_energy.bps.trigger",
)
async def test_when_error_40_reset_robot_before_load(
mock_reset_error: MagicMock,
robot_load_and_energy_change_composite: RobotLoadAndEnergyChangeComposite,
robot_load_and_energy_change_params: RobotLoadAndEnergyChange,
):
assert robot_load_and_energy_change_params.sample_puck is not None
assert robot_load_and_energy_change_params.sample_pin is not None

sample_location = SampleLocation(
robot_load_and_energy_change_params.sample_puck,
robot_load_and_energy_change_params.sample_pin,
)

demand_energy_ev = robot_load_and_energy_change_params.demand_energy_ev

set_mock_value(
robot_load_and_energy_change_composite.robot.controller_error.code, 40
)

RE = RunEngine()
RE(
# Thawing time set to arbitrary value
do_robot_load(
robot_load_and_energy_change_composite, sample_location, demand_energy_ev, 0
)
)

mock_reset_error.assert_called_once()


@patch(
"mx_bluesky.hyperion.external_interaction.callbacks.robot_load.ispyb_callback.ExpeyeInteraction"
)
Expand Down

0 comments on commit 2aff797

Please sign in to comment.