Skip to content

Commit fad3f79

Browse files
authored
Merge pull request #271 from ISISComputingGroup/update_ophyd_async
Update ophyd-async to v0.13.4; drop python 3.10; add python 3.13
2 parents 3fd7956 + 7ce01b3 commit fad3f79

File tree

5 files changed

+21
-28
lines changed

5 files changed

+21
-28
lines changed

.github/workflows/Lint-and-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jobs:
66
strategy:
77
matrix:
88
os: [ "ubuntu-latest", "windows-latest" ]
9-
version: ['3.10', '3.11', '3.12']
9+
version: ['3.11', '3.12', '3.13']
1010
fail-fast: false
1111
steps:
1212
- uses: actions/checkout@v5

doc/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
intersphinx_mapping = {
8080
"python": ("https://docs.python.org/3", None),
8181
"bluesky": ("https://blueskyproject.io/bluesky/main/", None),
82-
"ophyd_async": ("https://blueskyproject.io/ophyd-async/v0.12.3/", None),
82+
"ophyd_async": ("https://blueskyproject.io/ophyd-async/v0.13.4/", None),
8383
"event_model": ("https://blueskyproject.io/event-model/main/", None),
8484
"scipp": ("https://scipp.github.io/", None),
8585
"scippneutron": ("https://scipp.github.io/scippneutron/", None),

pyproject.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ name = "ibex-bluesky-core" # REQUIRED, is the only field that cannot be marked
88
dynamic = ["version"]
99
description = "Core bluesky plan stubs & devices for use at ISIS"
1010
readme = "README.md"
11-
requires-python = ">=3.10"
11+
requires-python = ">=3.11"
1212
license-files = ["LICENSE"]
1313

1414
authors = [
@@ -33,15 +33,15 @@ classifiers = [
3333
# that you indicate you support Python 3. These classifiers are *not*
3434
# checked by "pip install". See instead "requires-python" key in this file.
3535
"Programming Language :: Python :: 3",
36-
"Programming Language :: Python :: 3.10",
3736
"Programming Language :: Python :: 3.11",
3837
"Programming Language :: Python :: 3.12",
38+
"Programming Language :: Python :: 3.13",
3939
"Programming Language :: Python :: 3 :: Only",
4040
]
4141

4242
dependencies = [
4343
"bluesky", # Bluesky framework
44-
"ophyd-async[ca] == 0.12.3", # Device abstraction. When changing, also change in doc/conf.py
44+
"ophyd-async[ca] == 0.13.4", # Device abstraction. When changing, also change in doc/conf.py
4545
"matplotlib", # Plotting
4646
"lmfit", # Fitting
4747
"scipy", # Definitions of erf/erfc functions

src/ibex_bluesky_core/devices/block.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import asyncio
44
import logging
5-
import sys
65
from collections.abc import Callable
76
from dataclasses import dataclass
87
from typing import Generic, TypeVar
@@ -58,8 +57,6 @@
5857
# looking at the global moving flag.
5958
GLOBAL_MOVING_FLAG_PRE_WAIT = 0.1
6059

61-
aio_timeout_error = asyncio.exceptions.TimeoutError if sys.version_info < (3, 11) else TimeoutError
62-
6360

6461
@dataclass(kw_only=True, frozen=True)
6562
class BlockWriteConfig(Generic[T]):
@@ -286,7 +283,7 @@ async def set_and_settle(setpoint: T) -> None:
286283
else:
287284
try:
288285
await set_and_settle(value)
289-
except aio_timeout_error as e:
286+
except TimeoutError as e:
290287
logger.info(
291288
"block set %s value=%s failed with %s, but continuing anyway because "
292289
"continue_on_failed_write is set.",

tests/devices/test_block.py

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
# pyright: reportMissingParameterType=false
2-
import asyncio
3-
import sys
42
from contextlib import nullcontext
53
from unittest.mock import ANY, MagicMock, call, patch
64

@@ -25,11 +23,6 @@
2523
)
2624
from tests.conftest import MOCK_PREFIX
2725

28-
if sys.version_info < (3, 11):
29-
aio_timeout_error = asyncio.exceptions.TimeoutError
30-
else:
31-
aio_timeout_error = TimeoutError
32-
3326

3427
async def _make_block(clazz):
3528
block = clazz(float, MOCK_PREFIX, "float_block")
@@ -192,7 +185,7 @@ async def test_block_set_with_timeout():
192185

193186
set_mock_value(block.readback, 10)
194187

195-
with pytest.raises(aio_timeout_error):
188+
with pytest.raises(TimeoutError):
196189
await block.set(20)
197190

198191
func.assert_called_once_with(20, 10)
@@ -234,7 +227,7 @@ async def test_block_set_waiting_for_global_moving_flag_timeout():
234227

235228
set_mock_value(block.global_moving, True)
236229
with patch("ibex_bluesky_core.devices.block.asyncio.sleep") as mock_aio_sleep:
237-
with pytest.raises(aio_timeout_error):
230+
with pytest.raises(TimeoutError):
238231
await block.set(10)
239232
# Only check first call, as wait_for_value from ophyd_async gives us a few more...
240233
assert mock_aio_sleep.mock_calls[0] == call(GLOBAL_MOVING_FLAG_PRE_WAIT)
@@ -359,33 +352,36 @@ async def test_block_mot_set_within_limits(mot_block):
359352
get_mock_put(mot_block.user_setpoint).assert_called_once_with(20, wait=True)
360353

361354

362-
@pytest.mark.skipif(
363-
ophyd_async._version.version_tuple < (0, 13, 2),
364-
reason="Exception only raised in ophyd_async >= 0.13.2",
365-
)
366355
async def test_block_mot_set_outside_limits(mot_block):
367356
# Local import as API not available in older ophyd_async versions
368-
from ophyd_async.epics.motor import MotorLimitsException # noqa PLC0415
357+
if ophyd_async._version.version_tuple >= (0, 13, 5):
358+
from ophyd_async.epics.motor import MotorLimitsError # pyright: ignore # noqa PLC0415
359+
360+
err = MotorLimitsError
361+
else:
362+
from ophyd_async.epics.motor import MotorLimitsException # pyright: ignore # noqa PLC0415
363+
364+
err = MotorLimitsException
369365

370366
set_mock_value(mot_block.user_setpoint, 10)
371367
set_mock_value(mot_block.velocity, 10)
372368
set_mock_value(mot_block.high_limit_travel, 15)
373369
set_mock_value(mot_block.low_limit_travel, 5)
374-
with pytest.raises(MotorLimitsException):
370+
with pytest.raises(err):
375371
await mot_block.set(20)
376372

377373

378374
@pytest.mark.parametrize("timeout_is_error", [True, False])
379375
async def test_block_failing_write(timeout_is_error):
380376
block = await _block_with_write_config(BlockWriteConfig(timeout_is_error=timeout_is_error))
381377

382-
get_mock_put(block.setpoint).side_effect = aio_timeout_error
378+
get_mock_put(block.setpoint).side_effect = TimeoutError
383379

384-
with pytest.raises(aio_timeout_error) if timeout_is_error else nullcontext():
380+
with pytest.raises(TimeoutError) if timeout_is_error else nullcontext():
385381
await block.set(1)
386382

387383

388384
async def test_block_failing_write_with_default_write_config(writable_block):
389-
get_mock_put(writable_block.setpoint).side_effect = aio_timeout_error
390-
with pytest.raises(aio_timeout_error):
385+
get_mock_put(writable_block.setpoint).side_effect = TimeoutError
386+
with pytest.raises(TimeoutError):
391387
await writable_block.set(1)

0 commit comments

Comments
 (0)