Skip to content
This repository has been archived by the owner on Sep 2, 2024. It is now read-only.

Commit

Permalink
(#794) Center stub offsets after an XRC also adds tests
Browse files Browse the repository at this point in the history
  • Loading branch information
DominicOram committed Nov 9, 2023
1 parent ebc0169 commit bb6a762
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ install_requires =
xarray
doct
databroker
dls-dodal @ git+https://github.com/DiamondLightSource/dodal.git@b58451b5902db75b9d7cf1c40740bdeac3e53348
dls-dodal @ git+https://github.com/DiamondLightSource/dodal.git@f5e79547b3a94ddb54a81cdc6205f244a2be80ea
pydantic<2.0 # See https://github.com/DiamondLightSource/hyperion/issues/774
scipy

Expand Down
4 changes: 2 additions & 2 deletions src/hyperion/experiment_plans/flyscan_xray_centre_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from dodal.devices.fast_grid_scan import set_fast_grid_scan_params as set_flyscan_params
from dodal.devices.flux import Flux
from dodal.devices.s4_slit_gaps import S4SlitGaps
from dodal.devices.smargon import Smargon
from dodal.devices.smargon import Smargon, StubPosition
from dodal.devices.synchrotron import Synchrotron
from dodal.devices.undulator import Undulator
from dodal.devices.xbpm_feedback import XBPMFeedback
Expand Down Expand Up @@ -247,7 +247,7 @@ def run_gridscan_and_move(

hyperion.log.LOGGER.info("Recentring smargon co-ordinate system to this point.")
yield from bps.mv(
fgs_composite.sample_motors.stub_offsets.center_at_current_position, 1
fgs_composite.sample_motors.stub_offsets, StubPosition.CURRENT_AS_CENTER
)


Expand Down
6 changes: 6 additions & 0 deletions src/hyperion/experiment_plans/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ def smargon() -> Smargon:
smargon.z.user_setpoint._use_limits = False
smargon.omega.user_setpoint._use_limits = False

# Initial positions, needed for stub_offsets
smargon.stub_offsets.center_at_current_position.disp.sim_put(0)
smargon.x.user_readback.sim_put(0.0)
smargon.y.user_readback.sim_put(0.0)
smargon.z.user_readback.sim_put(0.0)

with patch_motor(smargon.omega), patch_motor(smargon.x), patch_motor(
smargon.y
), patch_motor(smargon.z):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,10 @@ def test_when_gridscan_finished_then_smargon_stub_offsets_are_set(
mock_subscriptions,
)
)
assert fake_fgs_composite.smargon.stub_offsets.center_at_current_position.get() == 1
assert (
fake_fgs_composite.smargon.stub_offsets.center_at_current_position.proc.get()
== 1
)


@patch("hyperion.experiment_plans.flyscan_xray_centre_plan.run_gridscan", autospec=True)
Expand All @@ -360,19 +363,25 @@ def test_given_gridscan_fails_to_centre_then_stub_offsets_not_set(
test_fgs_params: GridscanInternalParameters,
RE: RunEngine,
):
move_xyz.side_effect = Exception()
class MoveException(Exception):
pass

move_xyz.side_effect = MoveException()
mock_subscriptions = MagicMock()
mock_subscriptions.zocalo_handler.wait_for_results.return_value = ((0, 0, 0), None)

with pytest.raises(Exception):
with pytest.raises(MoveException):
RE(
run_gridscan_and_move(
fake_fgs_composite,
test_fgs_params,
mock_subscriptions,
)
)
assert fake_fgs_composite.smargon.stub_offsets.center_at_current_position.get() == 0
assert (
fake_fgs_composite.smargon.stub_offsets.center_at_current_position.proc.get()
== 0
)


@patch("hyperion.experiment_plans.flyscan_xray_centre_plan.bps.sleep", autospec=True)
Expand Down

0 comments on commit bb6a762

Please sign in to comment.