Skip to content

Commit

Permalink
Remove @skip_device decorator usage for i03
Browse files Browse the repository at this point in the history
  • Loading branch information
rtuck99 committed Jan 10, 2025
1 parent 4097722 commit 7ec1f74
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 20 deletions.
29 changes: 10 additions & 19 deletions src/dodal/beamlines/i03.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
from dodal.devices.zebra_controlled_shutter import ZebraShutter
from dodal.devices.zocalo import ZocaloResults
from dodal.log import set_beamline as set_log_beamline
from dodal.utils import BeamlinePrefix, get_beamline_name, skip_device
from dodal.utils import BeamlinePrefix, get_beamline_name

ZOOM_PARAMS_FILE = (
"/dls_sw/i03/software/gda/configurations/i03-config/xml/jCameraManZoomLevels.xml"
Expand Down Expand Up @@ -105,8 +105,7 @@ def dcm() -> DCM:
)


@device_factory()
@skip_device(lambda: BL == "s03")
@device_factory(skip=BL == "s03")
def vfm() -> FocusingMirrorWithStripes:
return FocusingMirrorWithStripes(
prefix=f"{PREFIX.beamline_prefix}-OP-VFM-01:",
Expand All @@ -118,8 +117,7 @@ def vfm() -> FocusingMirrorWithStripes:
)


@device_factory()
@skip_device(lambda: BL == "s03")
@device_factory(skip=BL == "s03")
def mirror_voltages() -> MirrorVoltages:
return MirrorVoltages(
name="mirror_voltages",
Expand All @@ -138,8 +136,7 @@ def backlight(
return Backlight(prefix=PREFIX.beamline_prefix, name="backlight")


@device_factory()
@skip_device(lambda: BL == "s03")
@device_factory(skip=BL == "s03")
def detector_motion() -> DetectorMotion:
"""Get the i03 detector motion device, instantiate it if it hasn't already been.
If this is called when already instantiated in i03, it will return the existing object.
Expand All @@ -150,8 +147,7 @@ def detector_motion() -> DetectorMotion:
)


@device_factory()
@skip_device(lambda: BL == "s03")
@device_factory(skip=BL == "s03")
def eiger(mock: bool = False) -> EigerDetector:
"""Get the i03 Eiger device, instantiate it if it hasn't already been.
If this is called when already instantiated in i03, it will return the existing object.
Expand Down Expand Up @@ -189,8 +185,7 @@ def panda_fast_grid_scan() -> PandAFastGridScan:
)


@device_factory()
@skip_device(lambda: BL == "s03")
@device_factory(skip=BL == "s03")
def oav(
params: OAVConfig | None = None,
) -> OAV:
Expand All @@ -204,8 +199,7 @@ def oav(
)


@device_factory()
@skip_device(lambda: BL == "s03")
@device_factory(skip=BL == "s03")
def pin_tip_detection() -> PinTipDetection:
"""Get the i03 pin tip detection device, instantiate it if it hasn't already been.
If this is called when already instantiated in i03, it will return the existing object.
Expand Down Expand Up @@ -238,8 +232,7 @@ def s4_slit_gaps(mock: bool = False) -> S4SlitGaps:
)


@device_factory()
@skip_device(lambda: BL == "s03")
@device_factory(skip=BL == "s03")
def synchrotron() -> Synchrotron:
"""Get the i03 synchrotron device, instantiate it if it hasn't already been.
If this is called when already instantiated in i03, it will return the existing object.
Expand Down Expand Up @@ -307,8 +300,7 @@ def panda() -> HDFPanda:
)


@device_factory()
@skip_device(lambda: BL == "s03")
@device_factory(skip=BL == "s03")
def sample_shutter() -> ZebraShutter:
"""Get the i03 sample shutter device, instantiate it if it hasn't already been.
If this is called when already instantiated in i03, it will return the existing object.
Expand All @@ -319,8 +311,7 @@ def sample_shutter() -> ZebraShutter:
)


@device_factory()
@skip_device(lambda: BL == "s03")
@device_factory(skip=BL == "s03")
def flux(mock: bool = False) -> Flux:
"""Get the i03 flux device, instantiate it if it hasn't already been.
If this is called when already instantiated in i03, it will return the existing object.
Expand Down
7 changes: 6 additions & 1 deletion tests/common/beamlines/test_beamline_utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import asyncio
import functools
import os
from unittest.mock import ANY, AsyncMock, MagicMock, patch

import pytest
Expand Down Expand Up @@ -37,6 +38,8 @@ def flush_event_loop_on_finish(event_loop):
def setup():
beamline_utils.clear_devices()
mock_beamline_module_filepaths("i03", i03)
with patch.dict(os.environ, {"BEAMLINE": "i03"}):
yield


def test_instantiate_function_makes_supplied_device():
Expand Down Expand Up @@ -84,7 +87,9 @@ def test_instantiate_v2_function_fake_makes_fake():


def test_clear_devices(RE):
devices, exceptions = make_all_devices(i03, fake_with_ophyd_sim=True)
devices, exceptions = make_all_devices(
i03, fake_with_ophyd_sim=True, include_skipped=True
)
assert (
# These are the only 3 devices remaining in i03 that are still OphydV1
len(beamline_utils.ACTIVE_DEVICES) == len(["flux", "s4_slit_gaps", "eiger"])
Expand Down

0 comments on commit 7ec1f74

Please sign in to comment.