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

Commit

Permalink
Merge pull request #1253 from DiamondLightSource/1251_ophyd_async_syc…
Browse files Browse the repository at this point in the history
…hrotron

Use ophyd_async version of synchrotron
  • Loading branch information
DominicOram authored Mar 26, 2024
2 parents 242b283 + 5a8e5b8 commit 2a303e9
Show file tree
Hide file tree
Showing 14 changed files with 34 additions and 194 deletions.
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ install_requires =
xarray
doct
databroker
dls-dodal @ git+https://github.com/DiamondLightSource/dodal.git@a8034f3e170720cb7078a2d08871c5cb06b8cc54
dls-dodal @ git+https://github.com/DiamondLightSource/dodal.git@32b5cbdb635c270491e8cad2274f238f67702ce5
pydantic<2.0 # See https://github.com/DiamondLightSource/hyperion/issues/774
scipy
pyzmq<25 # See https://github.com/DiamondLightSource/hyperion/issues/1103
Expand Down
81 changes: 0 additions & 81 deletions src/hyperion/device_setup_plans/check_topup.py

This file was deleted.

2 changes: 1 addition & 1 deletion src/hyperion/device_setup_plans/read_hardware_for_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def read_hardware_for_ispyb_pre_collection(
name=CONST.PLAN.ISPYB_HARDWARE_READ
) # gives name to event *descriptor* document
yield from bps.read(undulator.current_gap)
yield from bps.read(synchrotron.machine_status.synchrotron_mode)
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(aperture_scatterguard)
Expand Down
2 changes: 1 addition & 1 deletion src/hyperion/experiment_plans/flyscan_xray_centre_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
ZocaloResults,
get_processing_result,
)
from dodal.plans.check_topup import check_topup_and_wait_if_necessary
from ophyd_async.panda import PandA

from hyperion.device_setup_plans.check_topup import check_topup_and_wait_if_necessary
from hyperion.device_setup_plans.manipulate_sample import move_x_y_z
from hyperion.device_setup_plans.read_hardware_for_setup import (
read_hardware_for_ispyb_during_collection,
Expand Down
2 changes: 1 addition & 1 deletion src/hyperion/experiment_plans/rotation_scan_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
from dodal.devices.synchrotron import Synchrotron
from dodal.devices.undulator import Undulator
from dodal.devices.zebra import RotationDirection, Zebra
from dodal.plans.check_topup import check_topup_and_wait_if_necessary

from hyperion.device_setup_plans.check_topup import check_topup_and_wait_if_necessary
from hyperion.device_setup_plans.manipulate_sample import (
cleanup_sample_environment,
move_x_y_z,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def activity_gated_event(self, doc: Event) -> Event:
"undulator_current_gap"
]
self.params.hyperion_params.ispyb_params.synchrotron_mode = doc["data"][
"synchrotron_machine_status_synchrotron_mode"
"synchrotron-synchrotron_mode"
]
self.params.hyperion_params.ispyb_params.slit_gap_size_x = doc["data"][
"s4_slit_gaps_xgap"
Expand Down
8 changes: 6 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from dodal.devices.robot import BartRobot
from dodal.devices.s4_slit_gaps import S4SlitGaps
from dodal.devices.smargon import Smargon
from dodal.devices.synchrotron import Synchrotron
from dodal.devices.synchrotron import Synchrotron, SynchrotronMode
from dodal.devices.undulator import Undulator
from dodal.devices.zebra import Zebra
from dodal.log import LOGGER as dodal_logger
Expand Down Expand Up @@ -270,7 +270,11 @@ def s4_slit_gaps():

@pytest.fixture
def synchrotron():
return i03.synchrotron(fake_with_ophyd_sim=True)
RunEngine() # A RE is needed to start the bluesky loop
synchrotron = i03.synchrotron(fake_with_ophyd_sim=True)
set_sim_value(synchrotron.synchrotron_mode, SynchrotronMode.USER)
set_sim_value(synchrotron.topup_start_countdown, 10)
return synchrotron


@pytest.fixture
Expand Down
5 changes: 3 additions & 2 deletions tests/system_tests/experiment_plans/test_plan_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@


@pytest.mark.s03
def test_getting_data_for_ispyb():
@pytest.mark.asyncio
async def test_getting_data_for_ispyb():
undulator = Undulator(
f"{CONST.SIM.INSERTION_PREFIX}-MO-SERVC-01:", name="undulator"
)
Expand All @@ -28,7 +29,7 @@ def test_getting_data_for_ispyb():
)

undulator.wait_for_connection()
synchrotron.wait_for_connection()
await synchrotron.connect()
slit_gaps.wait_for_connection()
attenuator.wait_for_connection()
flux.wait_for_connection()
Expand Down
93 changes: 0 additions & 93 deletions tests/unit_tests/device_setup_plans/test_topup_plan.py

This file was deleted.

2 changes: 1 addition & 1 deletion tests/unit_tests/experiment_plans/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def make_event_doc(data, descriptor="abc123") -> Event:
BASIC_PRE_SETUP_DOC = {
"undulator_current_gap": 0,
"undulator_gap": 0,
"synchrotron_machine_status_synchrotron_mode": 0,
"synchrotron-synchrotron_mode": 0,
"s4_slit_gaps_xgap": 0,
"s4_slit_gaps_ygap": 0,
"robot-barcode": "BARCODE",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
EIGER_TYPE_EIGER2_X_16M,
)
from dodal.devices.fast_grid_scan import FastGridScan
from dodal.devices.synchrotron import SynchrotronMode
from dodal.devices.zocalo import ZocaloStartInfo
from ophyd.sim import make_fake_device
from ophyd.status import Status
Expand Down Expand Up @@ -177,9 +178,9 @@ def test_read_hardware_for_ispyb_updates_from_ophyd_devices(

fake_fgs_composite.undulator.current_gap.sim_put(undulator_test_value) # type: ignore

synchrotron_test_value = "test"
fake_fgs_composite.synchrotron.machine_status.synchrotron_mode.sim_put( # type: ignore
synchrotron_test_value
synchrotron_test_value = SynchrotronMode.USER
set_sim_value(
fake_fgs_composite.synchrotron.synchrotron_mode, synchrotron_test_value
)

transmission_test_value = 0.01
Expand Down Expand Up @@ -229,7 +230,7 @@ def test_read_hardware_for_ispyb_updates_from_ophyd_devices(
assert hyperion_params.ispyb_params.undulator_gap == undulator_test_value # type: ignore
assert (
hyperion_params.ispyb_params.synchrotron_mode # type: ignore
== synchrotron_test_value
== synchrotron_test_value.value
)
assert hyperion_params.ispyb_params.slit_gap_size_x == xgap_test_value # type: ignore
assert hyperion_params.ispyb_params.slit_gap_size_y == ygap_test_value # type: ignore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
EIGER_TYPE_EIGER2_X_16M,
)
from dodal.devices.panda_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
Expand Down Expand Up @@ -140,9 +141,9 @@ def test_read_hardware_for_ispyb_updates_from_ophyd_devices(

fake_fgs_composite.undulator.current_gap.sim_put(undulator_test_value) # type: ignore

synchrotron_test_value = "test"
fake_fgs_composite.synchrotron.machine_status.synchrotron_mode.sim_put( # type: ignore
synchrotron_test_value
synchrotron_test_value = SynchrotronMode.USER
set_sim_value(
fake_fgs_composite.synchrotron.synchrotron_mode, synchrotron_test_value
)

transmission_test_value = 0.01
Expand Down Expand Up @@ -184,7 +185,7 @@ def test_read_hardware_for_ispyb_updates_from_ophyd_devices(
assert params.hyperion_params.ispyb_params.undulator_gap == undulator_test_value # type: ignore
assert (
params.hyperion_params.ispyb_params.synchrotron_mode # type: ignore
== synchrotron_test_value
== synchrotron_test_value.value
)
assert params.hyperion_params.ispyb_params.slit_gap_size_x == xgap_test_value # type: ignore
assert params.hyperion_params.ispyb_params.slit_gap_size_y == ygap_test_value # type: ignore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from bluesky.utils import Msg
from dodal.devices.detector.detector_motion import ShutterState
from dodal.devices.fast_grid_scan import GridScanParams
from dodal.devices.synchrotron import SynchrotronMode

from hyperion.experiment_plans.pin_centre_then_xray_centre_plan import (
create_parameters_for_grid_detection,
Expand Down Expand Up @@ -122,6 +123,12 @@ def test_when_pin_centre_xray_centre_called_then_detector_positioned(
add_simple_pin_tip_centre_handlers(sim_run_engine)
add_simple_oav_mxsc_callback_handlers(sim_run_engine)

sim_run_engine.add_handler(
"read",
"synchrotron-synchrotron_mode",
lambda msg_: {"values": {"value": SynchrotronMode.SHUTDOWN}},
)

def add_handlers_to_simulate_detector_motion(msg: Msg):
sim_run_engine.add_handler(
"read",
Expand Down
4 changes: 2 additions & 2 deletions tests/unit_tests/external_interaction/callbacks/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class TestData:
"data": {
"s4_slit_gaps_xgap": 0.1234,
"s4_slit_gaps_ygap": 0.2345,
"synchrotron_machine_status_synchrotron_mode": "test",
"synchrotron-synchrotron_mode": "test",
"undulator_current_gap": 1.234,
"robot-barcode": "BARCODE",
},
Expand Down Expand Up @@ -138,7 +138,7 @@ class TestData:
"data": {
"s4_slit_gaps_xgap": 0.1234,
"s4_slit_gaps_ygap": 0.2345,
"synchrotron_machine_status_synchrotron_mode": "test",
"synchrotron-synchrotron_mode": "test",
"undulator_current_gap": 1.234,
"robot-barcode": "BARCODE",
},
Expand Down

0 comments on commit 2a303e9

Please sign in to comment.