Skip to content

Commit 1562381

Browse files
Updated dodal to be compatible with ophyd-async 0.13.5 and above (#1666)
* Updated dodal to be compatible with latest ophyd-async release * Pinned to 0.13.5 and above
1 parent ff45e68 commit 1562381

File tree

6 files changed

+16
-13
lines changed

6 files changed

+16
-13
lines changed

pyproject.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ description = "Ophyd devices and other utils that could be used across DLS beaml
1414
dependencies = [
1515
"click",
1616
"ophyd",
17-
# pin new ophyd-async can be built
18-
"ophyd-async[ca,pva]==0.13.4",
17+
"ophyd-async[ca,pva]>=0.13.5",
1918
"bluesky>=1.14.5",
2019
"pyepics",
2120
"dataclasses-json",

src/dodal/cli.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import click
66
from bluesky.run_engine import RunEngine
7-
from ophyd_async.core import NotConnected, StaticPathProvider, UUIDFilenameProvider
7+
from ophyd_async.core import NotConnectedError, StaticPathProvider, UUIDFilenameProvider
88
from ophyd_async.plan_stubs import ensure_connected
99

1010
from dodal.beamlines import all_beamline_names, module_name_for_beamline
@@ -79,7 +79,7 @@ def connect(beamline: str, all: bool, sim_backend: bool) -> None:
7979
# If exceptions have occurred, this will print details of the relevant PVs
8080
exceptions = {**instance_exceptions, **connect_exceptions}
8181
if len(exceptions) > 0:
82-
raise NotConnected(exceptions)
82+
raise NotConnectedError(exceptions)
8383

8484

8585
def _report_successful_devices(
@@ -113,7 +113,7 @@ def _connect_devices(
113113
# Connect ophyd-async devices
114114
try:
115115
run_engine(ensure_connected(*ophyd_async_devices.values(), mock=sim_backend))
116-
except NotConnected as ex:
116+
except NotConnectedError as ex:
117117
exceptions = {**exceptions, **ex.sub_errors}
118118

119119
# Only return the subset of devices that haven't raised an exception

tests/common/beamlines/test_device_instantiation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from typing import Any
22

33
import pytest
4-
from ophyd_async.core import NotConnected
4+
from ophyd_async.core import NotConnectedError
55

66
from dodal.beamlines import all_beamline_modules
77
from dodal.utils import BLUESKY_PROTOCOLS, make_all_devices
@@ -23,7 +23,7 @@ def test_device_creation(module_and_devices_for_beamline):
2323
"""
2424
_, devices, exceptions = module_and_devices_for_beamline
2525
if len(exceptions) > 0:
26-
raise NotConnected(exceptions)
26+
raise NotConnectedError(exceptions)
2727
devices_not_following_bluesky_protocols = [
2828
name
2929
for name, device in devices.items()

tests/devices/i04/test_transfocator.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from unittest.mock import AsyncMock, patch
33

44
import pytest
5+
from bluesky.protocols import Reading
56
from ophyd_async.core import (
67
init_devices,
78
wait_for_value,
@@ -19,10 +20,13 @@ async def fake_transfocator() -> Transfocator:
1920

2021

2122
def given_predicted_lenses_is_half_of_beamsize(transfocator: Transfocator):
22-
def lens_number_is_half_beamsize(value, *args, **kwargs):
23+
def lens_number_is_half_beamsize(
24+
reading: dict[str, Reading[float]], *args, **kwargs
25+
):
26+
value = reading[transfocator.beamsize_set_microns.name]["value"]
2327
set_mock_value(transfocator.predicted_vertical_num_lenses, int(value / 2))
2428

25-
transfocator.beamsize_set_microns.subscribe_value(lens_number_is_half_beamsize)
29+
transfocator.beamsize_set_microns.subscribe_reading(lens_number_is_half_beamsize)
2630

2731

2832
async def set_beamsize_to_same_value_as_mock_signal(

tests/devices/test_smargon.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from bluesky import plan_stubs as bps
66
from bluesky.run_engine import RunEngine
77
from ophyd_async.core import init_devices, observe_value
8-
from ophyd_async.epics.motor import MotorLimitsException
8+
from ophyd_async.epics.motor import MotorLimitsError
99
from ophyd_async.testing import get_mock_put, set_mock_value
1010

1111
from dodal.devices.smargon import CombinedMove, DeferMoves, Smargon, StubPosition
@@ -121,7 +121,7 @@ async def test_given_set_with_value_outside_motor_limit(
121121
set_mock_value(smargon.chi.high_limit_travel, 1999)
122122
set_mock_value(smargon.phi.high_limit_travel, 1999)
123123

124-
with pytest.raises(MotorLimitsException):
124+
with pytest.raises(MotorLimitsError):
125125
await smargon.set(
126126
CombinedMove(
127127
x=test_x,

tests/test_cli.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from ophyd_async.core import (
88
DEFAULT_TIMEOUT,
99
LazyMock,
10-
NotConnected,
10+
NotConnectedError,
1111
)
1212

1313
from dodal import __version__
@@ -282,7 +282,7 @@ def test_cli_connect_when_devices_error(
282282
runner: CliRunner,
283283
devices: tuple[dict[str, AnyDevice], dict[str, Exception]],
284284
):
285-
with pytest.raises(NotConnected):
285+
with pytest.raises(NotConnectedError):
286286
_mock_connect(
287287
EXAMPLE_BEAMLINE,
288288
runner=runner,

0 commit comments

Comments
 (0)