Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test ophyd async speedup #895

Merged
merged 44 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from 42 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
9f75e38
Make pyright happy
rtuck99 Oct 4, 2024
e67444d
Remove get_processing_result()
rtuck99 Oct 10, 2024
02b9f23
Changes to support extracting the results from the event
rtuck99 Oct 14, 2024
7a5445a
Fix InvocationError due to usage of missing attribute centres_of_mass
rtuck99 Oct 23, 2024
ce5c634
Misc enum fixes, remove timeout from expected call args
rtuck99 Oct 22, 2024
2328324
Most unit tests now working
rtuck99 Oct 22, 2024
f6186ff
Pin to current head of ophyd-async PR branch
rtuck99 Oct 22, 2024
e688086
Re-enable disabled test now that naming is fixed
rtuck99 Oct 22, 2024
379c493
Fix various type linting issues
rtuck99 Oct 22, 2024
ba3beac
Fix panda instantiations
rtuck99 Oct 23, 2024
6be7cf6
Make private signals public
rtuck99 Oct 23, 2024
f665eb6
Change PMAC string signals to Movable devices
rtuck99 Oct 23, 2024
0396d23
Repin to latest ophyd-async branch
rtuck99 Oct 23, 2024
ee62dc9
Fix enum type for fluorescence detector
rtuck99 Oct 23, 2024
7cf58fb
Fix AperturePositions enum
rtuck99 Oct 25, 2024
3f1cec1
Fix more panda uri/prefix changes, beamstop enum
rtuck99 Oct 25, 2024
6f6d897
Fix PMAC to use new Reference wrapper
rtuck99 Oct 29, 2024
1ec93d6
Fix Thawer to use new Reference wrapper
rtuck99 Oct 29, 2024
14aba8b
Fix OAV to redis forwarder signal types
rtuck99 Oct 29, 2024
0467c38
Allow I10 devices to accept float64 from bluesky scan() plan
rtuck99 Oct 29, 2024
8469a37
Revert panda uri changes back to prefix
rtuck99 Oct 29, 2024
e02138f
Misc I10 fixes for ophyd-async type changes
rtuck99 Oct 29, 2024
7a89200
Revert uri/prefix mangling in device_instantiation()
rtuck99 Oct 29, 2024
2ed9ec3
Fix I10 unit tests by flattening devices
rtuck99 Oct 29, 2024
6441f1b
Make type-checking happy
rtuck99 Oct 29, 2024
9e19d2e
bump ophyd-async hash
rtuck99 Oct 29, 2024
aedc595
Remove nonsensical fgs counter mock set
rtuck99 Oct 29, 2024
12731a8
Bump dodal commit hash
rtuck99 Oct 29, 2024
643f3cc
Bump ophyd-async hash
rtuck99 Oct 30, 2024
da1e43b
Fix connection issue due to typing on xspress3
rtuck99 Oct 30, 2024
2397f4a
Document the aperturescatterguard radius. Make the attenuator fields …
rtuck99 Oct 30, 2024
7453069
Make mirror voltage attribs private again
rtuck99 Oct 31, 2024
a545004
Remove unneeded lint ignore
rtuck99 Oct 31, 2024
90cf17d
Make zebra shutter manual_position_setpoint private again
rtuck99 Oct 31, 2024
228cbde
Update comment with reference to the correct ophyd-async issue
rtuck99 Oct 31, 2024
4361da5
Remove superfluous calls to add_children_as_readables() in i10 device…
rtuck99 Oct 31, 2024
3136e41
Pin dodal to >=0.8.0a1
rtuck99 Oct 31, 2024
45fbfa2
Fix usage of deprecated ConfigSignal, HintedSignal etc in favour of S…
rtuck99 Nov 1, 2024
7dffb4e
Remove ignores for now-fixed deprecation warnings in ophyd-async, pin…
rtuck99 Nov 4, 2024
4d2bdc5
Merge branch 'main' into fixes_for_declarative_epics
DominicOram Nov 8, 2024
bac94f3
Pin to correct ophyd-async
DominicOram Nov 8, 2024
f8157dc
Fix tests against the faster ophyd-async
DominicOram Nov 8, 2024
511c4e9
Merge branch 'main' into test_ophyd_async_speedup
DominicOram Nov 12, 2024
de596e3
Remove accidentally added file
DominicOram Nov 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ description = "Ophyd devices and other utils that could be used across DLS beaml
dependencies = [
"click",
"ophyd",
"ophyd-async==0.8.0a2",
"ophyd-async @ git+https://github.com/bluesky/ophyd-async.git@connect-mock-speed",
"bluesky",
"pyepics",
"dataclasses-json",
Expand All @@ -24,10 +24,10 @@ dependencies = [
"requests",
"graypy",
"pydantic>=2.0",
"opencv-python-headless", # For pin-tip detection.
"aioca", # Required for CA support with ophyd-async.
"p4p", # Required for PVA support with ophyd-async.
"numpy<2.0", # Unpin when https://github.com/bluesky/ophyd-async/issues/387 resolved
"opencv-python-headless", # For pin-tip detection.
"aioca", # Required for CA support with ophyd-async.
"p4p", # Required for PVA support with ophyd-async.
"numpy<2.0", # Unpin when https://github.com/bluesky/ophyd-async/issues/387 resolved
"aiofiles",
"aiohttp",
"redis",
Expand Down Expand Up @@ -92,7 +92,7 @@ version_file = "src/dodal/_version.py"

[tool.pyright]
typeCheckingMode = "standard"
reportMissingImports = false # Ignore missing stubs in imported modules
reportMissingImports = false # Ignore missing stubs in imported modules

[tool.pytest.ini_options]
# Run pytest with all our checkers, and don't spam us with massive tracebacks on error
Expand Down
2 changes: 1 addition & 1 deletion src/dodal/devices/CTAB.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from ophyd_async.core import StandardReadable
from ophyd_async.epics.core import epics_signal_r
from ophyd_async.epics.motor import Motor
from ophyd_async.epics.signal import epics_signal_r


class CTAB(StandardReadable):
Expand Down
2 changes: 1 addition & 1 deletion src/dodal/devices/aperture.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from ophyd_async.core import StandardReadable
from ophyd_async.epics.core import epics_signal_r
from ophyd_async.epics.motor import Motor
from ophyd_async.epics.signal import epics_signal_r


class Aperture(StandardReadable):
Expand Down
4 changes: 2 additions & 2 deletions src/dodal/devices/aperturescatterguard.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
from bluesky.protocols import Movable
from ophyd_async.core import (
AsyncStatus,
HintedSignal,
StandardReadable,
StandardReadableFormat,
StrictEnum,
)
from pydantic import BaseModel, Field
Expand Down Expand Up @@ -132,7 +132,7 @@ def __init__(
self.radius,
],
)
with self.add_children_as_readables(HintedSignal):
with self.add_children_as_readables(StandardReadableFormat.HINTED_SIGNAL):
self.selected_aperture = create_hardware_backed_soft_signal(
ApertureValue, self._get_current_aperture_position
)
Expand Down
54 changes: 27 additions & 27 deletions src/dodal/devices/apple2_undulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
from bluesky.protocols import Movable
from ophyd_async.core import (
AsyncStatus,
ConfigSignal,
HintedSignal,
Reference,
StandardReadable,
StandardReadableFormat,
StrictEnum,
soft_signal_r_and_setter,
wait_for_value,
)
from ophyd_async.epics.signal import epics_signal_r, epics_signal_rw, epics_signal_w
from ophyd_async.epics.core import epics_signal_r, epics_signal_rw, epics_signal_w
from pydantic import BaseModel, ConfigDict, RootModel

from dodal.log import LOGGER
Expand Down Expand Up @@ -128,12 +128,12 @@ def __init__(self, prefix: str, name: str = ""):
)
# This is calculated acceleration from speed
self.acceleration_time = epics_signal_r(float, prefix + "IDGSETACC")
with self.add_children_as_readables(ConfigSignal):
with self.add_children_as_readables(StandardReadableFormat.CONFIG_SIGNAL):
# Unit
self.motor_egu = epics_signal_r(str, prefix + "BLGAPMTR.EGU")
# Gap velocity
self.velocity = epics_signal_rw(float, prefix + "BLGSETVEL")
with self.add_children_as_readables(HintedSignal):
with self.add_children_as_readables(StandardReadableFormat.HINTED_SIGNAL):
# Gap readback value
self.user_readback = epics_signal_r(float, prefix + "CURRGAPD")
super().__init__(name)
Expand Down Expand Up @@ -187,10 +187,10 @@ def __init__(self, prefix: str, infix: str, name: str = ""):
self.user_setpoint_demand_readback = epics_signal_r(float, fullPV + "DMD")

fullPV = fullPV + "MTR"
with self.add_children_as_readables(HintedSignal):
with self.add_children_as_readables(StandardReadableFormat.HINTED_SIGNAL):
self.user_setpoint_readback = epics_signal_r(float, fullPV + ".RBV")

with self.add_children_as_readables(ConfigSignal):
with self.add_children_as_readables(StandardReadableFormat.CONFIG_SIGNAL):
self.motor_egu = epics_signal_r(str, fullPV + ".EGU")
self.velocity = epics_signal_rw(float, fullPV + ".VELO")

Expand Down Expand Up @@ -388,10 +388,9 @@ def __init__(

# Attributes are set after super call so they are not renamed to
# <name>-undulator, etc.
with self.add_children_as_readables():
self.gap = id_gap
self.phase = id_phase
with self.add_children_as_readables(HintedSignal):
self.gap = Reference(id_gap)
self.phase = Reference(id_phase)
with self.add_children_as_readables(StandardReadableFormat.HINTED_SIGNAL):
# Store the polarisation for readback.
self.polarisation, self._polarisation_set = soft_signal_r_and_setter(
str, initial_value=None
Expand Down Expand Up @@ -437,27 +436,29 @@ async def _set(self, value: Apple2Val, energy: float) -> None:
"""

# Only need to check gap as the phase motors share both fault and gate with gap.
await self.gap.check_id_status()
await self.gap().check_id_status()
await asyncio.gather(
self.phase.top_outer.user_setpoint.set(value=value.top_outer),
self.phase.top_inner.user_setpoint.set(value=value.top_inner),
self.phase.btm_inner.user_setpoint.set(value=value.btm_inner),
self.phase.btm_outer.user_setpoint.set(value=value.btm_outer),
self.gap.user_setpoint.set(value=value.gap),
self.phase().top_outer.user_setpoint.set(value=value.top_outer),
self.phase().top_inner.user_setpoint.set(value=value.top_inner),
self.phase().btm_inner.user_setpoint.set(value=value.btm_inner),
self.phase().btm_outer.user_setpoint.set(value=value.btm_outer),
self.gap().user_setpoint.set(value=value.gap),
)
timeout = np.max(
await asyncio.gather(self.gap.get_timeout(), self.phase.get_timeout())
await asyncio.gather(self.gap().get_timeout(), self.phase().get_timeout())
)
LOGGER.info(
f"Moving f{self.name} energy and polorisation to {energy}, {self.pol}"
+ f"with motor position {value}, timeout = {timeout}"
)

await asyncio.gather(
self.gap.set_move.set(value=1, timeout=timeout),
self.phase.set_move.set(value=1, timeout=timeout),
self.gap().set_move.set(value=1, timeout=timeout),
self.phase().set_move.set(value=1, timeout=timeout),
)
await wait_for_value(
self.gap().gate, UndulatorGateStatus.close, timeout=timeout
)
await wait_for_value(self.gap.gate, UndulatorGateStatus.close, timeout=timeout)
self._energy_set(energy) # Update energy for after move for readback.

def _get_id_gap_phase(self, energy: float) -> tuple[float, float]:
Expand Down Expand Up @@ -522,12 +523,11 @@ async def determinePhaseFromHardware(self) -> tuple[str | None, float]:
(May be for future one can use the inverse poly to work out the energy and try to match it with the current energy
to workout the polarisation but during my test the inverse poly is too unstable for general use.)
"""
cur_loc = await self.read()
top_outer = cur_loc[self.phase.top_outer.user_setpoint_readback.name]["value"]
top_inner = cur_loc[self.phase.top_inner.user_setpoint_readback.name]["value"]
btm_inner = cur_loc[self.phase.btm_inner.user_setpoint_readback.name]["value"]
btm_outer = cur_loc[self.phase.btm_outer.user_setpoint_readback.name]["value"]
gap = cur_loc[self.gap.user_readback.name]["value"]
top_outer = await self.phase().top_outer.user_setpoint_readback.get_value()
top_inner = await self.phase().top_inner.user_setpoint_readback.get_value()
btm_inner = await self.phase().btm_inner.user_setpoint_readback.get_value()
btm_outer = await self.phase().btm_outer.user_setpoint_readback.get_value()
gap = await self.gap().user_readback.get_value()
if gap > MAXIMUM_GAP_MOTOR_POSITION:
raise RuntimeError(
f"{self.name} is not in use, close gap or set polarisation to use this ID"
Expand Down
2 changes: 1 addition & 1 deletion src/dodal/devices/areadetector/plugins/CAM.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from ophyd_async.core import StandardReadable, StrictEnum
from ophyd_async.epics.signal import epics_signal_r, epics_signal_rw
from ophyd_async.epics.core import epics_signal_r, epics_signal_rw


class ColorMode(StrictEnum):
Expand Down
2 changes: 1 addition & 1 deletion src/dodal/devices/areadetector/plugins/MJPG.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from aiohttp import ClientSession
from bluesky.protocols import Triggerable
from ophyd_async.core import AsyncStatus, StandardReadable, soft_signal_rw
from ophyd_async.epics.signal import epics_signal_r, epics_signal_rw
from ophyd_async.epics.core import epics_signal_r, epics_signal_rw
from PIL import Image

from dodal.log import LOGGER
Expand Down
2 changes: 1 addition & 1 deletion src/dodal/devices/attenuator.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
StandardReadable,
wait_for_value,
)
from ophyd_async.epics.signal import epics_signal_r, epics_signal_rw, epics_signal_x
from ophyd_async.epics.core import epics_signal_r, epics_signal_rw, epics_signal_x

from dodal.log import LOGGER

Expand Down
2 changes: 1 addition & 1 deletion src/dodal/devices/backlight.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from bluesky.protocols import Movable
from ophyd_async.core import AsyncStatus, StandardReadable, StrictEnum
from ophyd_async.epics.signal import epics_signal_rw
from ophyd_async.epics.core import epics_signal_rw


class BacklightPower(StrictEnum):
Expand Down
2 changes: 1 addition & 1 deletion src/dodal/devices/cryostream.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from ophyd_async.core import StandardReadable, StrictEnum
from ophyd_async.epics.signal import epics_signal_r, epics_signal_rw
from ophyd_async.epics.core import epics_signal_r, epics_signal_rw


class InOut(StrictEnum):
Expand Down
2 changes: 1 addition & 1 deletion src/dodal/devices/dcm.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import numpy as np
from numpy.typing import NDArray
from ophyd_async.core import StandardReadable, soft_signal_r_and_setter
from ophyd_async.epics.core import epics_signal_r
from ophyd_async.epics.motor import Motor
from ophyd_async.epics.signal import epics_signal_r

from dodal.common.crystal_metadata import (
CrystalMetadata,
Expand Down
2 changes: 1 addition & 1 deletion src/dodal/devices/detector/detector_motion.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from ophyd_async.core import Device, StrictEnum
from ophyd_async.epics.core import epics_signal_r, epics_signal_rw
from ophyd_async.epics.motor import Motor
from ophyd_async.epics.signal import epics_signal_r, epics_signal_rw


class ShutterState(StrictEnum):
Expand Down
2 changes: 1 addition & 1 deletion src/dodal/devices/diamond_filter.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from typing import Generic, TypeVar

from ophyd_async.core import StandardReadable, StrictEnum
from ophyd_async.epics.core import epics_signal_rw
from ophyd_async.epics.motor import Motor
from ophyd_async.epics.signal import epics_signal_rw


class _Filters(StrictEnum):
Expand Down
2 changes: 1 addition & 1 deletion src/dodal/devices/fast_grid_scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
StandardReadable,
wait_for_value,
)
from ophyd_async.epics.signal import (
from ophyd_async.epics.core import (
epics_signal_r,
epics_signal_rw,
epics_signal_rw_rbv,
Expand Down
2 changes: 1 addition & 1 deletion src/dodal/devices/fluorescence_detector_motion.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from ophyd_async.core import StandardReadable, StrictEnum
from ophyd_async.epics.signal import epics_signal_r
from ophyd_async.epics.core import epics_signal_r


class FluorescenceDetectorControlState(StrictEnum):
Expand Down
14 changes: 8 additions & 6 deletions src/dodal/devices/focusing_mirror.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
from ophyd_async.core import (
AsyncStatus,
ConfigSignal,
Device,
DeviceVector,
HintedSignal,
StandardReadable,
StandardReadableFormat,
StrictEnum,
observe_value,
soft_signal_r_and_setter,
)
from ophyd_async.epics.motor import Motor
from ophyd_async.epics.signal import (
from ophyd_async.epics.core import (
epics_signal_r,
epics_signal_rw,
epics_signal_x,
)
from ophyd_async.epics.motor import Motor

from dodal.log import LOGGER

Expand Down Expand Up @@ -150,8 +149,11 @@ def __init__(
# regardless of orientation of the mirror
self.incident_angle = Motor(prefix + "PITCH")

self.add_readables([self.incident_angle.user_readback], wrapper=HintedSignal)
self.add_readables([self.type], wrapper=ConfigSignal)
self.add_readables(
[self.incident_angle.user_readback],
format=StandardReadableFormat.HINTED_SIGNAL,
)
self.add_readables([self.type], format=StandardReadableFormat.CONFIG_SIGNAL)
super().__init__(name)


Expand Down
2 changes: 1 addition & 1 deletion src/dodal/devices/hutch_shutter.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
StrictEnum,
wait_for_value,
)
from ophyd_async.epics.signal import epics_signal_r, epics_signal_w
from ophyd_async.epics.core import epics_signal_r, epics_signal_w

HUTCH_SAFE_FOR_OPERATIONS = 0 # Hutch is locked and can't be entered

Expand Down
14 changes: 7 additions & 7 deletions src/dodal/devices/i10/i10_apple2.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
from bluesky.protocols import Movable
from ophyd_async.core import (
AsyncStatus,
HintedSignal,
Reference,
StandardReadable,
StandardReadableFormat,
soft_signal_r_and_setter,
soft_signal_rw,
)
Expand Down Expand Up @@ -119,7 +119,7 @@ def __init__(
name=name,
)
with self.add_children_as_readables():
self.id_jaw_phase = id_jaw_phase
self.id_jaw_phase = Reference(id_jaw_phase)

@AsyncStatus.wrap
async def set(self, value: SupportsFloat) -> None:
Expand Down Expand Up @@ -148,8 +148,8 @@ async def set(self, value: SupportsFloat) -> None:
LOGGER.info(f"Setting polarisation to {self.pol}, with {id_set_val}")
await self._set(value=id_set_val, energy=value)
if self.pol != "la":
await self.id_jaw_phase.set(0)
await self.id_jaw_phase.set_move.set(1)
await self.id_jaw_phase().set(0)
await self.id_jaw_phase().set_move.set(1)

def update_lookuptable(self):
"""
Expand Down Expand Up @@ -199,7 +199,7 @@ def __init__(
super().__init__(name=name)
self.id_ref = Reference(id)
self.pgm_ref = Reference(pgm)
with self.add_children_as_readables(HintedSignal):
with self.add_children_as_readables(StandardReadableFormat.HINTED_SIGNAL):
self.energy_offset = soft_signal_rw(float, initial_value=0)

@AsyncStatus.wrap
Expand Down Expand Up @@ -278,7 +278,7 @@ def __init__(
self.jaw_phase_from_angle = np.poly1d(jaw_phase_poly_param)
self.angle_threshold_deg = angle_threshold_deg
self.jaw_phase_limit = jaw_phase_limit
with self.add_children_as_readables(HintedSignal):
with self.add_children_as_readables(StandardReadableFormat.HINTED_SIGNAL):
self.angle, self._angle_set = soft_signal_r_and_setter(
float, initial_value=None
)
Expand All @@ -299,7 +299,7 @@ async def set(self, value: SupportsFloat) -> None:
f"jaw_phase position for angle ({value}) is outside permitted range"
f" [-{self.jaw_phase_limit}, {self.jaw_phase_limit}]"
)
await self.id_ref().id_jaw_phase.set(jaw_phase)
await self.id_ref().id_jaw_phase().set(jaw_phase)
self._angle_set(value)


Expand Down
6 changes: 3 additions & 3 deletions src/dodal/devices/i22/dcm.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
from event_model.documents.event_descriptor import DataKey
from ophyd_async.core import (
Array1D,
ConfigSignal,
StandardReadable,
StandardReadableFormat,
soft_signal_r_and_setter,
)
from ophyd_async.epics.core import epics_signal_r
from ophyd_async.epics.motor import Motor
from ophyd_async.epics.signal import epics_signal_r

from dodal.common.crystal_metadata import CrystalMetadata

Expand Down Expand Up @@ -61,7 +61,7 @@ def __init__(

# Soft metadata
# If supplied include crystal details in output of read_configuration
with self.add_children_as_readables(ConfigSignal):
with self.add_children_as_readables(StandardReadableFormat.CONFIG_SIGNAL):
self.crystal_1_usage, _ = soft_signal_r_and_setter(
str, initial_value=crystal_1_metadata.usage
)
Expand Down
Loading
Loading