From 11a8fafe1f5c437e5a384c5380bf768eb2e1ebdb Mon Sep 17 00:00:00 2001 From: "Ware, Joseph (DLSLtd,RAL,LSCI)" Date: Fri, 25 Oct 2024 12:49:30 +0100 Subject: [PATCH] Revert "Add deprecation warning to inject (#854)" This reverts commit 0f8989ef5d146a8710fd7eb10d6ba096330137f1. --- docs/how-to/include-devices-in-plans.md | 37 ------------------------- src/dodal/common/coordination.py | 20 ------------- tests/common/test_coordination.py | 16 ----------- 3 files changed, 73 deletions(-) delete mode 100644 docs/how-to/include-devices-in-plans.md diff --git a/docs/how-to/include-devices-in-plans.md b/docs/how-to/include-devices-in-plans.md deleted file mode 100644 index 644265d06d..0000000000 --- a/docs/how-to/include-devices-in-plans.md +++ /dev/null @@ -1,37 +0,0 @@ -# Include Devices in Plans - -There are two main ways to include dodal devices in plans - -## 1. Pass as Argument - -```python -import bluesky.plans as bp - -from bluesky.protocols import Readable -from bluesky.utils import MsgGenerator -from dodal.beamlines import i22 - -def my_plan(detector: Readable) -> MsgGenerator: - yield from bp.count([detector]) - -RE(my_plan(i22.saxs())) -``` - -This is useful for generic plans that can run on a variety of devices and are not designed with any specific device in mind. - -## 2. Pass as Default Argument - -```python -import bluesky.plans as bp - -from bluesky.protocols import Readable -from bluesky.utils import MsgGenerator -from dodal.beamlines import i22 - -def my_plan(detector: Readable = i22.saxs(connect_immediately=False)) -> MsgGenerator: - yield from bp.count([detector]) - -RE(my_plan())) -``` - -This is useful for plans that will usually, but not exclusively, use the same device or that are designed to only ever work with a specific device. diff --git a/src/dodal/common/coordination.py b/src/dodal/common/coordination.py index 9aa8242849..e04edefc21 100644 --- a/src/dodal/common/coordination.py +++ b/src/dodal/common/coordination.py @@ -1,6 +1,4 @@ import uuid -import warnings -from textwrap import dedent from typing import Any from dodal.common.types import Group @@ -39,22 +37,4 @@ def scan(x: Movable = inject("stage_x"), start: float = 0.0 ...) """ - warnings.warn( - dedent(""" - Inject is deprecated, users are now expected to call the device factory - functions in dodal directly, these will cache devices as singletons after - they have been called once. For example: - - from bluesky.protocols import Readable - from bluesky.utils import MsgGenerator - from dodal.beamlines import i22 - - def my_plan(detector: Readable = i22.saxs(connect_immediately=False)) -> MsgGenerator: - ... - - Where previously the default would have been inject("saxs") - """), - DeprecationWarning, - stacklevel=2, - ) return name diff --git a/tests/common/test_coordination.py b/tests/common/test_coordination.py index d206d89c80..8c0ec6adad 100644 --- a/tests/common/test_coordination.py +++ b/tests/common/test_coordination.py @@ -16,12 +16,6 @@ def test_group_uid(group: str): assert not gid.endswith(f"{group}-") -@pytest.mark.filterwarnings("ignore::DeprecationWarning") -def test_inject_returns_value(): - assert inject("foo") == "foo" - - -@pytest.mark.filterwarnings("ignore::DeprecationWarning") def test_type_checking_ignores_inject(): def example_function(x: Movable = inject("foo")) -> MsgGenerator: # noqa: B008 yield from {} @@ -31,13 +25,3 @@ def example_function(x: Movable = inject("foo")) -> MsgGenerator: # noqa: B008 x: Parameter = signature(example_function).parameters["x"] assert x.annotation == Movable assert x.default == "foo" - - -def test_inject_is_deprecated(): - with pytest.raises( - DeprecationWarning, - match="Inject is deprecated, users are now expected to call the device factory", - ): - - def example_function(x: Movable = inject("foo")) -> MsgGenerator: # noqa: B008 - yield from {}