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

Move panda save load into plan stubs #352

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
16 changes: 0 additions & 16 deletions src/ophyd_async/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,6 @@
TriggerInfo,
)
from .device import Device, DeviceCollector, DeviceVector
from .device_save_loader import (
get_signal_values,
load_device,
load_from_yaml,
save_device,
save_to_yaml,
set_signal_values,
walk_rw_signals,
)
from .flyer import HardwareTriggeredFlyable, TriggerLogic
from .mock_signal_backend import MockSignalBackend
from .mock_signal_utils import (
Expand Down Expand Up @@ -119,13 +110,6 @@
"get_unique",
"merge_gathered_dicts",
"wait_for_connection",
"get_signal_values",
"load_from_yaml",
"save_to_yaml",
"set_signal_values",
"walk_rw_signals",
"load_device",
"save_device",
"assert_reading",
"assert_value",
"assert_configuration",
Expand Down
8 changes: 7 additions & 1 deletion src/ophyd_async/plan_stubs/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
from .device_save_loader import (
load_device,
save_device,
)
from .ensure_connected import ensure_connected
from .fly import (
fly_and_collect,
Expand All @@ -6,8 +10,10 @@
)

__all__ = [
"load_device",
"save_device",
"ensure_connected",
"fly_and_collect",
"prepare_static_seq_table_flyer_and_detectors_with_same_trigger",
"time_resolved_fly_and_collect_with_static_seq_table",
"ensure_connected",
]
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
from bluesky.protocols import Location
from bluesky.utils import Msg

from .device import Device
from .signal import SignalRW
from ..core.device import Device
from ..core.signal import SignalRW


def ndarray_representer(dumper: yaml.Dumper, array: npt.NDArray[Any]) -> yaml.Node:
Expand Down
3 changes: 2 additions & 1 deletion tests/epics/test_signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from aioca import CANothing, purge_channel_caches
from bluesky.protocols import DataKey, Reading

from ophyd_async.core import SignalBackend, T, load_from_yaml, save_to_yaml
from ophyd_async.core import SignalBackend, T
from ophyd_async.core.utils import NotConnected
from ophyd_async.epics._backend.common import LimitPair, Limits
from ophyd_async.epics.signal._epics_transport import EpicsTransport
Expand All @@ -31,6 +31,7 @@
epics_signal_w,
epics_signal_x,
)
from ophyd_async.plan_stubs.device_save_loader import load_from_yaml, save_to_yaml

RECORDS = str(Path(__file__).parent / "test_records.db")
PV_PREFIX = "".join(random.choice(string.ascii_lowercase) for _ in range(12))
Expand Down
4 changes: 2 additions & 2 deletions tests/panda/test_panda_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
import pytest
from bluesky import RunEngine

from ophyd_async.core import save_device
from ophyd_async.core.device import DeviceCollector
from ophyd_async.core.utils import DEFAULT_TIMEOUT
from ophyd_async.epics.pvi import fill_pvi_entries
from ophyd_async.epics.signal import epics_signal_rw
from ophyd_async.panda import CommonPandaBlocks, TimeUnits
from ophyd_async.panda._common_blocks import DataBlock
from ophyd_async.panda._utils import phase_sorter
from ophyd_async.plan_stubs import save_device


@pytest.fixture
Expand All @@ -35,7 +35,7 @@ async def connect(self, mock: bool = False, timeout: float = DEFAULT_TIMEOUT):
yield mock_panda


@patch("ophyd_async.core.device_save_loader.save_to_yaml")
@patch("ophyd_async.plan_stubs.device_save_loader.save_to_yaml")
async def test_save_panda(mock_save_to_yaml, mock_panda, RE: RunEngine):
RE(save_device(mock_panda, "path", sorter=phase_sorter))
mock_save_to_yaml.assert_called_once()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
Device,
SignalR,
SignalRW,
)
from ophyd_async.epics.signal import epics_signal_r, epics_signal_rw
from ophyd_async.plan_stubs.device_save_loader import (
all_at_once,
get_signal_values,
load_device,
load_from_yaml,
Expand All @@ -21,8 +25,6 @@
set_signal_values,
walk_rw_signals,
)
from ophyd_async.core.device_save_loader import all_at_once
from ophyd_async.epics.signal import epics_signal_r, epics_signal_rw


class DummyChildDevice(Device):
Expand Down Expand Up @@ -276,9 +278,9 @@ async def test_set_signal_values_restores_value(RE: RunEngine, device, tmp_path)
assert np.array_equal(array_value, np.array([1, 1, 1, 1, 1]))


@patch("ophyd_async.core.device_save_loader.load_from_yaml")
@patch("ophyd_async.core.device_save_loader.walk_rw_signals")
@patch("ophyd_async.core.device_save_loader.set_signal_values")
@patch("ophyd_async.plan_stubs.device_save_loader.load_from_yaml")
@patch("ophyd_async.plan_stubs.device_save_loader.walk_rw_signals")
@patch("ophyd_async.plan_stubs.device_save_loader.set_signal_values")
async def test_load_device(
mock_set_signal_values, mock_walk_rw_signals, mock_load_from_yaml, device
):
Expand Down
Loading