From e68d1a8ea758839ec9f0c34f227e2222e7ca9c8e Mon Sep 17 00:00:00 2001 From: glopesdev Date: Wed, 12 Aug 2026 12:24:58 +0100 Subject: [PATCH] Split harp.device into core, client and schema harp.device becomes a PEP 420 namespace so a device package can be harp.device.. The core register set and REGISTER_MAP move to harp.device.core, the device runtime and transport to harp.device.client, and the device.yml machinery to harp.device.schema. Every import of harp.device moves to the portion that owns the name. --- README.md | 5 +- docs/api/device.md | 28 +++++------ .../create_device_module.py | 3 +- docs/examples/get_info/get_info.py | 3 +- .../read_and_write_from_registers.py | 4 +- .../read_data_to_dataframe.py | 2 +- docs/examples/read_dataset/read_dataset.py | 4 +- .../subscribing_to_events.py | 6 +-- src/packages/harp-data/README.md | 4 +- .../harp-data/src/harp/data/_dataset.py | 8 +-- src/packages/harp-device/README.md | 7 +-- .../src/harp/device/_schema/__init__.py | 50 ------------------- .../src/harp/device/client/__init__.py | 14 ++++++ .../src/harp/device/{ => client}/_device.py | 6 +-- .../src/harp/device/{ => client}/_framer.py | 0 .../harp/device/{ => client}/_transport.py | 2 +- .../src/harp/device/{ => core}/__init__.py | 20 ++------ .../harp/device/{ => core}/_register_map.py | 0 .../src/harp/device/{ => core}/_registers.py | 0 .../src/harp/device/schema/__init__.py | 12 +++++ .../harp/device/{_schema => schema}/_emit.py | 0 .../harp/device/{_schema => schema}/_model.py | 0 .../{_emit_module.py => schema/_module.py} | 5 +- .../device/{_schema => schema}/_naming.py | 0 src/packages/harp-serial/README.md | 3 +- .../harp-serial/src/harp/serial/_serial.py | 4 +- tests/conformance.py | 12 ++--- tests/data/test_dataset.py | 3 +- tests/device/expected_device.py | 2 +- tests/device/test_create_device_module.py | 13 ++--- tests/device/test_emit.py | 2 +- tests/device/test_naming.py | 2 +- tests/device/test_schema.py | 3 +- tests/protocol/test_framer.py | 2 +- 34 files changed, 96 insertions(+), 133 deletions(-) delete mode 100644 src/packages/harp-device/src/harp/device/_schema/__init__.py create mode 100644 src/packages/harp-device/src/harp/device/client/__init__.py rename src/packages/harp-device/src/harp/device/{ => client}/_device.py (98%) rename src/packages/harp-device/src/harp/device/{ => client}/_framer.py (100%) rename src/packages/harp-device/src/harp/device/{ => client}/_transport.py (89%) rename src/packages/harp-device/src/harp/device/{ => core}/__init__.py (69%) rename src/packages/harp-device/src/harp/device/{ => core}/_register_map.py (100%) rename src/packages/harp-device/src/harp/device/{ => core}/_registers.py (100%) create mode 100644 src/packages/harp-device/src/harp/device/schema/__init__.py rename src/packages/harp-device/src/harp/device/{_schema => schema}/_emit.py (100%) rename src/packages/harp-device/src/harp/device/{_schema => schema}/_model.py (100%) rename src/packages/harp-device/src/harp/device/{_emit_module.py => schema/_module.py} (96%) rename src/packages/harp-device/src/harp/device/{_schema => schema}/_naming.py (100%) diff --git a/README.md b/README.md index 5aadd64..ab7070e 100644 --- a/README.md +++ b/README.md @@ -58,7 +58,8 @@ serial connection, or reading **data recorded to disk**. **Talk to a live device.** Open a connection and read/write registers by class: ```python -from harp.device import Device, WhoAmI, OperationControl, OperationControlPayload, OperationMode +from harp.device.core import OperationControl, OperationControlPayload, OperationMode, WhoAmI +from harp.device.client import Device from harp.serial import open_serial_device # Use "COMx" on Windows, "/dev/ttyUSBx" on Linux. @@ -86,7 +87,7 @@ does under the hood: ```python from pathlib import Path -from harp.device import create_device_module +from harp.device.schema import create_device_module behavior = create_device_module(Path("device.yml").read_bytes()) AnalogData = behavior.AnalogData # registers are reached by name... diff --git a/docs/api/device.md b/docs/api/device.md index f1ea7a1..17b854d 100644 --- a/docs/api/device.md +++ b/docs/api/device.md @@ -2,17 +2,17 @@ --- -::: harp.device.Device -::: harp.device.create_device_module -::: harp.device.parse_device_schema -::: harp.device.ConverterContext -::: harp.device.HarpFramer -::: harp.device.ITransport -::: harp.device.TransportError -::: harp.device.REGISTER_MAP -::: harp.device.OperationControl -::: harp.device.OperationMode -::: harp.device.ResetDevice -::: harp.device.ResetFlags -::: harp.device.ClockConfiguration -::: harp.device.ClockConfigurationFlags +::: harp.device.client.Device +::: harp.device.client.HarpFramer +::: harp.device.client.ITransport +::: harp.device.client.TransportError +::: harp.device.schema.create_device_module +::: harp.device.schema.parse_device_schema +::: harp.device.schema.ConverterContext +::: harp.device.core.REGISTER_MAP +::: harp.device.core.OperationControl +::: harp.device.core.OperationMode +::: harp.device.core.ResetDevice +::: harp.device.core.ResetFlags +::: harp.device.core.ClockConfiguration +::: harp.device.core.ClockConfigurationFlags diff --git a/docs/examples/create_device_module/create_device_module.py b/docs/examples/create_device_module/create_device_module.py index e51bc0a..1d55e3e 100644 --- a/docs/examples/create_device_module/create_device_module.py +++ b/docs/examples/create_device_module/create_device_module.py @@ -1,7 +1,8 @@ from pathlib import Path from harp.data import parse_to_dataframe -from harp.device import Device, create_device_module +from harp.device.client import Device +from harp.device.schema import create_device_module from harp.serial import open_serial_device SERIAL_PORT = "/dev/ttyUSB0" # or "COMx" in Windows ("x" is the number of the serial port) diff --git a/docs/examples/get_info/get_info.py b/docs/examples/get_info/get_info.py index cc0c350..6446c38 100755 --- a/docs/examples/get_info/get_info.py +++ b/docs/examples/get_info/get_info.py @@ -1,4 +1,5 @@ -from harp.device import REGISTER_MAP, Device, WhoAmI +from harp.device.core import REGISTER_MAP, WhoAmI +from harp.device.client import Device from harp.serial import open_serial_device SERIAL_PORT = "/dev/ttyUSB0" # or "COMx" in Windows ("x" is the number of the serial port) diff --git a/docs/examples/read_and_write_from_registers/read_and_write_from_registers.py b/docs/examples/read_and_write_from_registers/read_and_write_from_registers.py index 8b735ae..43bcf29 100755 --- a/docs/examples/read_and_write_from_registers/read_and_write_from_registers.py +++ b/docs/examples/read_and_write_from_registers/read_and_write_from_registers.py @@ -1,11 +1,11 @@ -from harp.device import ( - Device, +from harp.device.core import ( EnableFlag, OperationControl, OperationControlPayload, OperationMode, WhoAmI, ) +from harp.device.client import Device from harp.serial import open_serial_device SERIAL_PORT = "/dev/ttyUSB0" # or "COMx" in Windows ("x" is the number of the serial port) diff --git a/docs/examples/read_data_to_dataframe/read_data_to_dataframe.py b/docs/examples/read_data_to_dataframe/read_data_to_dataframe.py index df67c2c..a08731b 100644 --- a/docs/examples/read_data_to_dataframe/read_data_to_dataframe.py +++ b/docs/examples/read_data_to_dataframe/read_data_to_dataframe.py @@ -1,5 +1,5 @@ from harp.data import parse_to_dataframe -from harp.device import OperationControl +from harp.device.core import OperationControl # Parse a single register's binary dump into a pandas DataFrame — one row per # frame, one column per field. The register class tells `parse_to_dataframe` how diff --git a/docs/examples/read_dataset/read_dataset.py b/docs/examples/read_dataset/read_dataset.py index 4a350c4..f7d769e 100644 --- a/docs/examples/read_dataset/read_dataset.py +++ b/docs/examples/read_dataset/read_dataset.py @@ -1,5 +1,5 @@ from harp.data import REFERENCE_EPOCH, create_dataset_reader -from harp.device import OperationControl +from harp.device.core import OperationControl # A Harp acquisition is usually saved as a de-multiplexed dataset folder — one # `.bin` file per register, named "_
.bin", next to the @@ -39,7 +39,7 @@ # can drive the reader directly — construct `DatasetReader(module, folder)`: # # from harp.data import DatasetReader -# from harp.device import create_device_module +# from harp.device.schema import create_device_module # from pathlib import Path # # behavior = create_device_module((Path("session.harp") / "device.yml").read_bytes()) diff --git a/docs/examples/subscribing_to_events/subscribing_to_events.py b/docs/examples/subscribing_to_events/subscribing_to_events.py index 42ccca6..25a98cd 100644 --- a/docs/examples/subscribing_to_events/subscribing_to_events.py +++ b/docs/examples/subscribing_to_events/subscribing_to_events.py @@ -1,13 +1,13 @@ import numpy as np -from harp.device import ( - REGISTER_MAP, - Device, +from harp.device.core import ( EnableFlag, OperationControl, OperationControlPayload, OperationMode, + REGISTER_MAP, TimestampSeconds, ) +from harp.device.client import Device from harp.protocol import HarpMessage, ParsedHarpMessage from harp.serial import open_serial_device diff --git a/src/packages/harp-data/README.md b/src/packages/harp-data/README.md index ddba84a..89d0677 100644 --- a/src/packages/harp-data/README.md +++ b/src/packages/harp-data/README.md @@ -24,7 +24,7 @@ per register, named `_
.bin`, alongside the device's ``` Reading is driven by a generated -[`harp.device.Device`](../harp-device) that describes how to decode each register. +[`harp.device.client.Device`](../harp-device) that describes how to decode each register. `create_dataset_reader` does that for you — it finds the `device.yml` in the folder, builds the device, and returns a ready-to-use reader: @@ -43,7 +43,7 @@ Already have a device module (e.g. a pre-generated package, or one built with ```python from pathlib import Path from harp.data import DatasetReader -from harp.device import create_device_module +from harp.device.schema import create_device_module behavior = create_device_module((Path("session.harp") / "device.yml").read_bytes()) reader = DatasetReader(behavior, "session.harp") diff --git a/src/packages/harp-data/src/harp/data/_dataset.py b/src/packages/harp-data/src/harp/data/_dataset.py index 6047769..26094f2 100644 --- a/src/packages/harp-data/src/harp/data/_dataset.py +++ b/src/packages/harp-data/src/harp/data/_dataset.py @@ -6,7 +6,7 @@ from typing import Any import pandas as pd -from harp.device import DeviceModuleLike, create_device_module +from harp.device.schema import DeviceModuleLike, create_device_module from harp.protocol import RegisterBase from harp.protocol._constants import _TIMESTAMP_FLAG @@ -43,7 +43,7 @@ class DatasetReader: everything = reader.read_all() # {register_name: DataFrame} ``device_module`` is a device module -- a generated device package, or one built from a - schema with :func:`~harp.device.create_device_module`. Its ``REGISTER_MAP`` and + schema with :func:`~harp.device.schema.create_device_module`. Its ``REGISTER_MAP`` and ``__name__`` are read on demand. ``name`` overrides the ```` file prefix, which defaults to the module name. @@ -197,14 +197,14 @@ def create_dataset_reader( """Build a :class:`DatasetReader` for a dataset folder, device and all. Convenience wrapper that finds the device schema inside ``root`` (``device.yml`` - by default), builds its module with :func:`~harp.device.create_device_module`, and + by default), builds its module with :func:`~harp.device.schema.create_device_module`, and returns a reader ready to :meth:`~DatasetReader.read`:: reader = create_dataset_reader("session.harp") df = reader.read(44) ``schema`` points at the schema file explicitly when it isn't ``root/device.yml``. - ``converters`` and ``strict`` are forwarded to :func:`~harp.device.create_device_module` + ``converters`` and ``strict`` are forwarded to :func:`~harp.device.schema.create_device_module` for custom ``interfaceType`` decoding; ``name`` and ``resolver`` are forwarded to :class:`DatasetReader`. Use ``DatasetReader(device_module, root)`` directly when you already have a (e.g. pre-generated) device module. diff --git a/src/packages/harp-device/README.md b/src/packages/harp-device/README.md index 0625631..b73ad68 100644 --- a/src/packages/harp-device/README.md +++ b/src/packages/harp-device/README.md @@ -10,7 +10,8 @@ dependencies. Pair it with a transport (e.g. [`harp-serial`](../harp-serial)). A `Device` is driven over a transport; `read`/`write` take a register class: ```python -from harp.device import Device, WhoAmI, OperationControl +from harp.device.core import OperationControl, WhoAmI +from harp.device.client import Device # `device` is a Device opened over some transport (see harp-serial) who = device.read(WhoAmI).parsed # -> np.uint16 @@ -24,7 +25,7 @@ device identity as `WHO_AM_I`, declare the register classes at module level, and the core `REGISTER_MAP` beside them: ```python -from harp.device import REGISTER_MAP as _CORE_REGISTER_MAP +from harp.device.core import REGISTER_MAP as _CORE_REGISTER_MAP WHO_AM_I: int = 1216 REGISTER_MAP = {**_CORE_REGISTER_MAP, 32: DigitalInputState, ...} @@ -72,7 +73,7 @@ names come from the yml verbatim, payload fields are `snake_case`, and enum memb ```python from pathlib import Path -from harp.device import create_device_module +from harp.device.schema import create_device_module behavior = create_device_module(Path("device.yml").read_bytes()) reg = behavior.AnalogData # by name diff --git a/src/packages/harp-device/src/harp/device/_schema/__init__.py b/src/packages/harp-device/src/harp/device/_schema/__init__.py deleted file mode 100644 index 75f066f..0000000 --- a/src/packages/harp-device/src/harp/device/_schema/__init__.py +++ /dev/null @@ -1,50 +0,0 @@ -from ._model import ( - Access, - BitMask, - Converter, - GroupMask, - InterfaceType, - MaskType, - MaskValue, - DeviceModel, - PayloadMember, - PayloadType, - Register, - Registers, - Visibility, -) -from ._emit import ( - ConverterContext, - ConverterFactory, - ConverterValue, - NameCollisionError, - UnknownConverterError, - create_registers, - parse_device_schema, -) -from ._naming import enum_member_name, field_name - -__all__ = [ - "parse_device_schema", - "create_registers", - "ConverterContext", - "ConverterFactory", - "ConverterValue", - "NameCollisionError", - "UnknownConverterError", - "enum_member_name", - "field_name", - "DeviceModel", - "Registers", - "Register", - "PayloadMember", - "PayloadType", - "Access", - "Visibility", - "Converter", - "BitMask", - "GroupMask", - "MaskType", - "MaskValue", - "InterfaceType", -] diff --git a/src/packages/harp-device/src/harp/device/client/__init__.py b/src/packages/harp-device/src/harp/device/client/__init__.py new file mode 100644 index 0000000..c2d142e --- /dev/null +++ b/src/packages/harp-device/src/harp/device/client/__init__.py @@ -0,0 +1,14 @@ +"""Talking to a Harp device: the device itself, its transport and the framer.""" + +from ._device import Device, EventHandler, Subscription +from ._framer import HarpFramer +from ._transport import ITransport, TransportError + +__all__ = [ + "Device", + "EventHandler", + "Subscription", + "HarpFramer", + "ITransport", + "TransportError", +] diff --git a/src/packages/harp-device/src/harp/device/_device.py b/src/packages/harp-device/src/harp/device/client/_device.py similarity index 98% rename from src/packages/harp-device/src/harp/device/_device.py rename to src/packages/harp-device/src/harp/device/client/_device.py index 71098e9..0d0e556 100644 --- a/src/packages/harp-device/src/harp/device/_device.py +++ b/src/packages/harp-device/src/harp/device/client/_device.py @@ -13,7 +13,7 @@ from ._framer import HarpFramer from ._transport import ITransport, TransportError -from ._registers import ( +from harp.device.core import ( WhoAmI, ) @@ -69,12 +69,12 @@ def __exit__(self, *args: object) -> None: class Device: """Harp device protocol logic (framing, request/reply, register access) - over an :class:`~harp.device.ITransport`. + over an :class:`~harp.device.client.ITransport`. Must be opened before use, via ``with`` or :meth:`open`. :meth:`read`, :meth:`write` and :meth:`subscribe` take a register class, so the device holds no register collection of its own: a device's registers live in its module, - beside a ``REGISTER_MAP`` (see :func:`~harp.device.create_device_module`, or the + beside a ``REGISTER_MAP`` (see :func:`~harp.device.schema.create_device_module`, or the ``harp-device`` README for the statically generated equivalent). A subclass sets :attr:`__whoami__` to validate device identity on open diff --git a/src/packages/harp-device/src/harp/device/_framer.py b/src/packages/harp-device/src/harp/device/client/_framer.py similarity index 100% rename from src/packages/harp-device/src/harp/device/_framer.py rename to src/packages/harp-device/src/harp/device/client/_framer.py diff --git a/src/packages/harp-device/src/harp/device/_transport.py b/src/packages/harp-device/src/harp/device/client/_transport.py similarity index 89% rename from src/packages/harp-device/src/harp/device/_transport.py rename to src/packages/harp-device/src/harp/device/client/_transport.py index efa4dfc..801ffd4 100644 --- a/src/packages/harp-device/src/harp/device/_transport.py +++ b/src/packages/harp-device/src/harp/device/client/_transport.py @@ -9,7 +9,7 @@ class TransportError(Exception): @runtime_checkable class ITransport(Protocol): - """Byte channel a :class:`~harp.device.Device` drives. + """Byte channel a :class:`~harp.device.client.Device` drives. Owns no protocol logic. Failures are reported as :class:`TransportError`. """ diff --git a/src/packages/harp-device/src/harp/device/__init__.py b/src/packages/harp-device/src/harp/device/core/__init__.py similarity index 69% rename from src/packages/harp-device/src/harp/device/__init__.py rename to src/packages/harp-device/src/harp/device/core/__init__.py index 3bed88a..7e3dee2 100644 --- a/src/packages/harp-device/src/harp/device/__init__.py +++ b/src/packages/harp-device/src/harp/device/core/__init__.py @@ -1,6 +1,6 @@ -from ._device import Device, EventHandler, Subscription -from ._emit_module import DeviceModule, DeviceModuleLike, create_device_module -from ._framer import HarpFramer +"""The core register set every Harp device carries, and its address space.""" + +from ._register_map import REGISTER_MAP from ._registers import ( AssemblyVersion, ClockConfiguration, @@ -26,22 +26,8 @@ TimestampSeconds, WhoAmI, ) -from ._register_map import REGISTER_MAP -from ._schema import ConverterContext, parse_device_schema -from ._transport import ITransport, TransportError __all__ = [ - "Device", - "EventHandler", - "Subscription", - "create_device_module", - "DeviceModule", - "DeviceModuleLike", - "parse_device_schema", - "ConverterContext", - "HarpFramer", - "ITransport", - "TransportError", "REGISTER_MAP", "WhoAmI", "HardwareVersionHigh", diff --git a/src/packages/harp-device/src/harp/device/_register_map.py b/src/packages/harp-device/src/harp/device/core/_register_map.py similarity index 100% rename from src/packages/harp-device/src/harp/device/_register_map.py rename to src/packages/harp-device/src/harp/device/core/_register_map.py diff --git a/src/packages/harp-device/src/harp/device/_registers.py b/src/packages/harp-device/src/harp/device/core/_registers.py similarity index 100% rename from src/packages/harp-device/src/harp/device/_registers.py rename to src/packages/harp-device/src/harp/device/core/_registers.py diff --git a/src/packages/harp-device/src/harp/device/schema/__init__.py b/src/packages/harp-device/src/harp/device/schema/__init__.py new file mode 100644 index 0000000..de66397 --- /dev/null +++ b/src/packages/harp-device/src/harp/device/schema/__init__.py @@ -0,0 +1,12 @@ +"""Building a device interface from a Harp ``device.yml`` at runtime.""" + +from ._emit import ConverterContext, parse_device_schema +from ._module import DeviceModule, DeviceModuleLike, create_device_module + +__all__ = [ + "create_device_module", + "DeviceModule", + "DeviceModuleLike", + "parse_device_schema", + "ConverterContext", +] diff --git a/src/packages/harp-device/src/harp/device/_schema/_emit.py b/src/packages/harp-device/src/harp/device/schema/_emit.py similarity index 100% rename from src/packages/harp-device/src/harp/device/_schema/_emit.py rename to src/packages/harp-device/src/harp/device/schema/_emit.py diff --git a/src/packages/harp-device/src/harp/device/_schema/_model.py b/src/packages/harp-device/src/harp/device/schema/_model.py similarity index 100% rename from src/packages/harp-device/src/harp/device/_schema/_model.py rename to src/packages/harp-device/src/harp/device/schema/_model.py diff --git a/src/packages/harp-device/src/harp/device/_emit_module.py b/src/packages/harp-device/src/harp/device/schema/_module.py similarity index 96% rename from src/packages/harp-device/src/harp/device/_emit_module.py rename to src/packages/harp-device/src/harp/device/schema/_module.py index d468373..e7c542e 100644 --- a/src/packages/harp-device/src/harp/device/_emit_module.py +++ b/src/packages/harp-device/src/harp/device/schema/_module.py @@ -12,9 +12,8 @@ from harp.protocol import RegisterBase -from ._register_map import REGISTER_MAP as CORE_REGISTER_MAP -from ._schema import create_registers, parse_device_schema -from ._schema._emit import ConverterValue +from harp.device.core import REGISTER_MAP as CORE_REGISTER_MAP +from ._emit import ConverterValue, create_registers, parse_device_schema #: Module name used when the schema carries no ``device`` header. _DEFAULT_NAME = "Device" diff --git a/src/packages/harp-device/src/harp/device/_schema/_naming.py b/src/packages/harp-device/src/harp/device/schema/_naming.py similarity index 100% rename from src/packages/harp-device/src/harp/device/_schema/_naming.py rename to src/packages/harp-device/src/harp/device/schema/_naming.py diff --git a/src/packages/harp-serial/README.md b/src/packages/harp-serial/README.md index 50e74d2..b98b2af 100644 --- a/src/packages/harp-serial/README.md +++ b/src/packages/harp-serial/README.md @@ -10,7 +10,8 @@ Like the builtin `open`, the returned device is connected and ready; use it in a `with` block for guaranteed cleanup: ```python -from harp.device import Device, WhoAmI +from harp.device.core import WhoAmI +from harp.device.client import Device from harp.serial import open_serial_device with open_serial_device(Device, port="COM3", baudrate=1_000_000) as dev: diff --git a/src/packages/harp-serial/src/harp/serial/_serial.py b/src/packages/harp-serial/src/harp/serial/_serial.py index 45d5b9a..f7d4e5b 100644 --- a/src/packages/harp-serial/src/harp/serial/_serial.py +++ b/src/packages/harp-serial/src/harp/serial/_serial.py @@ -4,7 +4,7 @@ import serial -from harp.device import Device, TransportError +from harp.device.client import Device, TransportError D = TypeVar("D", bound=Device) @@ -12,7 +12,7 @@ class SerialTransport: - """A serial-port :class:`~harp.device.ITransport` (structural conformance).""" + """A serial-port :class:`~harp.device.client.ITransport` (structural conformance).""" def __init__(self, port: str, baudrate: int = DEFAULT_BAUDRATE) -> None: self._port = port diff --git a/tests/conformance.py b/tests/conformance.py index 89316c7..0e11319 100644 --- a/tests/conformance.py +++ b/tests/conformance.py @@ -9,15 +9,9 @@ import numpy as np from harp.data import DatasetReader -from harp.device import ( - Device, - DeviceModule, - DeviceModuleLike, - OperationControl, - OperationControlPayload, - WhoAmI, - create_device_module, -) +from harp.device.core import OperationControl, OperationControlPayload, WhoAmI +from harp.device.client import Device +from harp.device.schema import DeviceModule, DeviceModuleLike, create_device_module from harp.protocol import ParsedHarpMessage, RegisterBase diff --git a/tests/data/test_dataset.py b/tests/data/test_dataset.py index 0aea937..fe1d733 100644 --- a/tests/data/test_dataset.py +++ b/tests/data/test_dataset.py @@ -9,7 +9,8 @@ create_dataset_reader, parse_to_dataframe, ) -from harp.device import TimestampSeconds, WhoAmI, create_device_module +from harp.device.core import TimestampSeconds, WhoAmI +from harp.device.schema import create_device_module def _records(cls, n, seed): diff --git a/tests/device/expected_device.py b/tests/device/expected_device.py index 304fc07..d32ad88 100644 --- a/tests/device/expected_device.py +++ b/tests/device/expected_device.py @@ -23,7 +23,7 @@ StringConverter, StructPayload, ) -from harp.device import REGISTER_MAP as _CORE_REGISTER_MAP +from harp.device.core import REGISTER_MAP as _CORE_REGISTER_MAP from .converters import ( DataConverter, diff --git a/tests/device/test_create_device_module.py b/tests/device/test_create_device_module.py index 2e2c9d2..1517dd9 100644 --- a/tests/device/test_create_device_module.py +++ b/tests/device/test_create_device_module.py @@ -1,10 +1,11 @@ import sys import types -import harp.device +import harp.device.core import pytest -from harp.device import REGISTER_MAP as CORE_REGISTER_MAP -from harp.device import DeviceModule, DeviceModuleLike, WhoAmI, create_device_module +from harp.device.core import REGISTER_MAP as CORE_REGISTER_MAP +from harp.device.core import WhoAmI +from harp.device.schema import DeviceModule, DeviceModuleLike, create_device_module from . import expected_device from .converters import DataConverter @@ -89,9 +90,9 @@ def test_generated_package_matches_device_protocol(): def test_common_registers_are_not_device_module(): # They carry REGISTER_MAP but describe no device, so they cannot be passed # where a device module is required, such as to a DatasetReader. - assert hasattr(harp.device, "REGISTER_MAP") - assert not hasattr(harp.device, "WHO_AM_I") - assert not isinstance(harp.device, DeviceModuleLike) + assert hasattr(harp.device.core, "REGISTER_MAP") + assert not hasattr(harp.device.core, "WHO_AM_I") + assert not isinstance(harp.device.core, DeviceModuleLike) def test_unknown_name_raises_attribute_error(test_module): diff --git a/tests/device/test_emit.py b/tests/device/test_emit.py index 597a0fc..73a89fc 100644 --- a/tests/device/test_emit.py +++ b/tests/device/test_emit.py @@ -5,7 +5,7 @@ from harp.data import parse_to_dataframe from harp.protocol import HarpMessage -from harp.device._schema import NameCollisionError, UnknownConverterError, create_registers +from harp.device.schema._emit import NameCollisionError, UnknownConverterError, create_registers from . import expected_core, expected_device from .converters import DataConverter diff --git a/tests/device/test_naming.py b/tests/device/test_naming.py index 2c09a7a..8795061 100644 --- a/tests/device/test_naming.py +++ b/tests/device/test_naming.py @@ -6,7 +6,7 @@ """ import pytest -from harp.device._schema import enum_member_name, field_name +from harp.device.schema._naming import enum_member_name, field_name # yml identifier -> generated enum member (SCREAMING_SNAKE_CASE) ENUM_MEMBERS = [ diff --git a/tests/device/test_schema.py b/tests/device/test_schema.py index 200e1e9..be39044 100644 --- a/tests/device/test_schema.py +++ b/tests/device/test_schema.py @@ -1,4 +1,5 @@ -from harp.device._schema import DeviceModel, PayloadType, parse_device_schema +from harp.device.schema import parse_device_schema +from harp.device.schema._model import DeviceModel, PayloadType def test_parse_full_device(device_yml): diff --git a/tests/protocol/test_framer.py b/tests/protocol/test_framer.py index 5b8a6fc..a90041a 100644 --- a/tests/protocol/test_framer.py +++ b/tests/protocol/test_framer.py @@ -1,6 +1,6 @@ import struct -from harp.device._framer import HarpFramer +from harp.device.client._framer import HarpFramer from harp.protocol._message_type import MessageType from tests.fixtures import TIMESTAMP_1S, make_frame_from_raw