Skip to content

Commit

Permalink
Update to Pydantic2 and ophyd_async 0.5.x (#764)
Browse files Browse the repository at this point in the history
* Update to Pydantic2 and ophyd_async 0.5.x

* Update to Pydantic2 and ophyd_async 0.5.2

* Simplify DetectorParams and add test to serialise and deserialise a DetectorParams

* Extract common behaviour of VisitServiceClient

* Revert filesystem metadata test throw

* Adjust test for DetectorParams

* Add tests on RemoteDirectoryServiceClient

---------

Co-authored-by: Dominic Oram <[email protected]>
  • Loading branch information
DiamondJoseph and DominicOram authored Sep 6, 2024
1 parent c4051ba commit 350ca72
Show file tree
Hide file tree
Showing 64 changed files with 665 additions and 462 deletions.
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ description = "Ophyd devices and other utils that could be used across DLS beaml
dependencies = [
"click",
"ophyd",
"ophyd-async<0.4.0", # Need to pin to <0.4.0 as this requires pydantic>2.0 see https://github.com/DiamondLightSource/dodal/issues/679
"ophyd-async>=0.5.2",
"bluesky",
"pyepics",
"dataclasses-json",
"pillow",
"zocalo>=0.32.0,<1.0.0", # TODO remove pin against <1.0.0, see #679
"zocalo>=1.0.0",
"requests",
"graypy",
"pydantic",
"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.
Expand Down
12 changes: 6 additions & 6 deletions src/dodal/beamlines/i03.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
from ophyd_async.panda import HDFPanda
from ophyd_async.fastcs.panda import HDFPanda

from dodal.common.beamlines.beamline_parameters import get_beamline_parameters
from dodal.common.beamlines.beamline_utils import (
device_instantiation,
get_directory_provider,
set_directory_provider,
get_path_provider,
set_path_provider,
)
from dodal.common.beamlines.beamline_utils import set_beamline as set_utils_beamline
from dodal.common.udc_directory_provider import PandASubdirectoryProvider
from dodal.common.udc_directory_provider import PandASubpathProvider
from dodal.devices.aperturescatterguard import (
AperturePosition,
ApertureScatterguard,
Expand Down Expand Up @@ -52,7 +52,7 @@
set_log_beamline(BL)
set_utils_beamline(BL)

set_directory_provider(PandASubdirectoryProvider())
set_path_provider(PandASubpathProvider())


def aperture_scatterguard(
Expand Down Expand Up @@ -378,7 +378,7 @@ def panda(
"-EA-PANDA-01:",
wait_for_connection,
fake_with_ophyd_sim,
directory_provider=get_directory_provider(),
path_provider=get_path_provider(),
)


Expand Down
14 changes: 7 additions & 7 deletions src/dodal/beamlines/i13_1.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
from pathlib import Path

from ophyd_async.epics.areadetector.aravis import AravisDetector
from ophyd_async.epics.adaravis import AravisDetector

from dodal.common.beamlines.beamline_utils import (
device_instantiation,
get_directory_provider,
set_directory_provider,
get_path_provider,
set_path_provider,
)
from dodal.common.beamlines.beamline_utils import set_beamline as set_utils_beamline
from dodal.common.visit import StaticVisitDirectoryProvider
from dodal.common.visit import StaticVisitPathProvider
from dodal.devices.motors import XYZPositioner
from dodal.log import set_beamline as set_log_beamline
from dodal.utils import get_beamline_name

BL = get_beamline_name("i13-1")
set_log_beamline(BL)
set_utils_beamline(BL)
set_directory_provider(
StaticVisitDirectoryProvider(
set_path_provider(
StaticVisitPathProvider(
BL,
Path("/data/2024/cm37257-4/"), # latest commissioning visit
)
Expand Down Expand Up @@ -60,7 +60,7 @@ def side_camera(
bl_prefix=False,
drv_suffix="CAM:",
hdf_suffix="HDF5:",
directory_provider=get_directory_provider(),
path_provider=get_path_provider(),
wait=wait_for_connection,
fake=fake_with_ophyd_sim,
)
35 changes: 18 additions & 17 deletions src/dodal/beamlines/i22.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
from pathlib import Path

from ophyd_async.epics.areadetector import AravisDetector, PilatusDetector
from ophyd_async.panda import HDFPanda
from ophyd_async.epics.adaravis import AravisDetector
from ophyd_async.epics.adpilatus import PilatusDetector
from ophyd_async.fastcs.panda import HDFPanda

from dodal.common.beamlines.beamline_utils import (
device_instantiation,
get_directory_provider,
set_directory_provider,
get_path_provider,
set_path_provider,
)
from dodal.common.beamlines.beamline_utils import set_beamline as set_utils_beamline
from dodal.common.beamlines.device_helpers import numbered_slits
from dodal.common.visit import DirectoryServiceClient, StaticVisitDirectoryProvider
from dodal.common.visit import RemoteDirectoryServiceClient, StaticVisitPathProvider
from dodal.devices.focusing_mirror import FocusingMirror
from dodal.devices.i22.dcm import CrystalMetadata, DoubleCrystalMonochromator
from dodal.devices.i22.fswitch import FSwitch
Expand All @@ -32,11 +33,11 @@
# Communication with GDA is also WIP so for now we determine an arbitrary scan number
# locally and write the commissioning directory. The scan number is not guaranteed to
# be unique and the data is at risk - this configuration is for testing only.
set_directory_provider(
StaticVisitDirectoryProvider(
set_path_provider(
StaticVisitPathProvider(
BL,
Path("/dls/i22/data/2024/cm37271-2/bluesky"),
client=DirectoryServiceClient("http://i22-control:8088/api"),
client=RemoteDirectoryServiceClient("http://i22-control:8088/api"),
)
)

Expand All @@ -61,7 +62,7 @@ def saxs(
sensor_thickness=(0.45, "mm"),
distance=(4711.833684146172, "mm"),
),
directory_provider=get_directory_provider(),
path_provider=get_path_provider(),
)


Expand Down Expand Up @@ -97,7 +98,7 @@ def waxs(
sensor_thickness=(0.45, "mm"),
distance=(175.4199417092314, "mm"),
),
directory_provider=get_directory_provider(),
path_provider=get_path_provider(),
)


Expand All @@ -112,7 +113,7 @@ def i0(
wait_for_connection,
fake_with_ophyd_sim,
type="Cividec Diamond XBPM",
directory_provider=get_directory_provider(),
path_provider=get_path_provider(),
)


Expand All @@ -127,7 +128,7 @@ def it(
wait_for_connection,
fake_with_ophyd_sim,
type="PIN Diode",
directory_provider=get_directory_provider(),
path_provider=get_path_provider(),
)


Expand Down Expand Up @@ -295,7 +296,7 @@ def panda1(
"-EA-PANDA-01:",
wait_for_connection,
fake_with_ophyd_sim,
directory_provider=get_directory_provider(),
path_provider=get_path_provider(),
)


Expand All @@ -310,7 +311,7 @@ def panda2(
"-EA-PANDA-02:",
wait_for_connection,
fake_with_ophyd_sim,
directory_provider=get_directory_provider(),
path_provider=get_path_provider(),
)


Expand All @@ -325,7 +326,7 @@ def panda3(
"-EA-PANDA-03:",
wait_for_connection,
fake_with_ophyd_sim,
directory_provider=get_directory_provider(),
path_provider=get_path_provider(),
)


Expand All @@ -340,7 +341,7 @@ def panda4(
"-EA-PANDA-04:",
wait_for_connection,
fake_with_ophyd_sim,
directory_provider=get_directory_provider(),
path_provider=get_path_provider(),
)


Expand All @@ -361,7 +362,7 @@ def oav(
description="AVT Mako G-507B",
distance=(-1.0, "m"),
),
directory_provider=get_directory_provider(),
path_provider=get_path_provider(),
)


Expand Down
28 changes: 14 additions & 14 deletions src/dodal/beamlines/p38.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
from pathlib import Path

from ophyd_async.epics.areadetector import AravisDetector
from ophyd_async.panda import HDFPanda
from ophyd_async.epics.adaravis import AravisDetector
from ophyd_async.fastcs.panda import HDFPanda

from dodal.common.beamlines.beamline_utils import (
device_instantiation,
get_directory_provider,
set_directory_provider,
get_path_provider,
set_path_provider,
)
from dodal.common.beamlines.beamline_utils import set_beamline as set_utils_beamline
from dodal.common.beamlines.device_helpers import numbered_slits
from dodal.common.visit import LocalDirectoryServiceClient, StaticVisitDirectoryProvider
from dodal.common.visit import LocalDirectoryServiceClient, StaticVisitPathProvider
from dodal.devices.focusing_mirror import FocusingMirror
from dodal.devices.i22.dcm import CrystalMetadata, DoubleCrystalMonochromator
from dodal.devices.i22.fswitch import FSwitch
Expand All @@ -30,8 +30,8 @@
# Communication with GDA is also WIP so for now we determine an arbitrary scan number
# locally and write the commissioning directory. The scan number is not guaranteed to
# be unique and the data is at risk - this configuration is for testing only.
set_directory_provider(
StaticVisitDirectoryProvider(
set_path_provider(
StaticVisitPathProvider(
BL,
Path("/dls/p38/data/2024/cm37282-2/bluesky"),
client=LocalDirectoryServiceClient(),
Expand All @@ -50,7 +50,7 @@ def d3(
fake_with_ophyd_sim,
drv_suffix="DET:",
hdf_suffix="HDF5:",
directory_provider=get_directory_provider(),
path_provider=get_path_provider(),
)


Expand All @@ -67,7 +67,7 @@ def d11(
fake_with_ophyd_sim,
drv_suffix="DET:",
hdf_suffix="HDF5:",
directory_provider=get_directory_provider(),
path_provider=get_path_provider(),
)


Expand All @@ -82,7 +82,7 @@ def d12(
fake_with_ophyd_sim,
drv_suffix="DET:",
hdf_suffix="HDF5:",
directory_provider=get_directory_provider(),
path_provider=get_path_provider(),
)


Expand All @@ -96,7 +96,7 @@ def i0(
"-EA-XBPM-01:",
wait_for_connection,
fake_with_ophyd_sim,
directory_provider=get_directory_provider(),
path_provider=get_path_provider(),
)


Expand Down Expand Up @@ -273,7 +273,7 @@ def panda1(
"-EA-PANDA-01:",
wait_for_connection,
fake_with_ophyd_sim,
directory_provider=get_directory_provider(),
path_provider=get_path_provider(),
)


Expand All @@ -288,7 +288,7 @@ def panda2(
"-EA-PANDA-02:",
wait_for_connection,
fake_with_ophyd_sim,
directory_provider=get_directory_provider(),
path_provider=get_path_provider(),
)


Expand All @@ -303,7 +303,7 @@ def panda3(
"-EA-PANDA-03:",
wait_for_connection,
fake_with_ophyd_sim,
directory_provider=get_directory_provider(),
path_provider=get_path_provider(),
)


Expand Down
22 changes: 11 additions & 11 deletions src/dodal/beamlines/p45.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
from pathlib import Path

from ophyd_async.epics.areadetector import AravisDetector
from ophyd_async.panda import HDFPanda
from ophyd_async.epics.adaravis import AravisDetector
from ophyd_async.fastcs.panda import HDFPanda

from dodal.common.beamlines.beamline_utils import (
device_instantiation,
get_directory_provider,
set_directory_provider,
get_path_provider,
set_path_provider,
)
from dodal.common.beamlines.beamline_utils import set_beamline as set_utils_beamline
from dodal.common.visit import StaticVisitDirectoryProvider
from dodal.common.visit import StaticVisitPathProvider
from dodal.devices.p45 import Choppers, TomoStageWithStretchAndSkew
from dodal.log import set_beamline as set_log_beamline
from dodal.utils import get_beamline_name, skip_device

BL = get_beamline_name("p45")
set_log_beamline(BL)
set_utils_beamline(BL)
set_directory_provider(
StaticVisitDirectoryProvider(
set_path_provider(
StaticVisitPathProvider(
BL,
Path("/data/2024/cm37283-2/"), # latest commissioning visit
)
Expand Down Expand Up @@ -62,7 +62,7 @@ def det(
fake_with_ophyd_sim,
drv_suffix="DET:",
hdf_suffix="HDF5:",
directory_provider=get_directory_provider(),
path_provider=get_path_provider(),
)


Expand All @@ -79,7 +79,7 @@ def diff(
fake_with_ophyd_sim,
drv_suffix="DET:",
hdf_suffix="HDF5:",
directory_provider=get_directory_provider(),
path_provider=get_path_provider(),
)


Expand All @@ -97,7 +97,7 @@ def panda1(
"-MO-PANDA-01:",
wait_for_connection,
fake_with_ophyd_sim,
directory_provider=get_directory_provider(),
path_provider=get_path_provider(),
)


Expand All @@ -112,5 +112,5 @@ def panda2(
"-MO-PANDA-02:",
wait_for_connection,
fake_with_ophyd_sim,
directory_provider=get_directory_provider(),
path_provider=get_path_provider(),
)
Loading

0 comments on commit 350ca72

Please sign in to comment.