Skip to content

Commit

Permalink
moved save and load to plan stubs
Browse files Browse the repository at this point in the history
  • Loading branch information
evalott100 committed Jun 3, 2024
1 parent b2b8bba commit c3635f7
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 27 deletions.
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 @@ -10,8 +10,8 @@
from bluesky.utils import Msg
from epicscorelibs.ca.dbr import ca_array, ca_float, ca_int, ca_str

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

CaType = Union[ca_float, ca_int, ca_str, ca_array]

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 @@ -28,7 +28,7 @@
from aioca import CANothing, purge_channel_caches
from bluesky.protocols import Reading

from ophyd_async.core import SignalBackend, T, get_dtype, load_from_yaml, save_to_yaml
from ophyd_async.core import SignalBackend, T, get_dtype
from ophyd_async.core.utils import NotConnected
from ophyd_async.epics.signal._epics_transport import EpicsTransport
from ophyd_async.epics.signal.signal import (
Expand All @@ -39,6 +39,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 @@ -178,9 +180,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

0 comments on commit c3635f7

Please sign in to comment.