Source code for ursa.register._writer
"""Module-private write boundary between :mod:`ursa.register` and the catalog backend.
The four ``register.*`` functions only ever need to insert a row, never
read or query. This Protocol captures exactly that surface so test code
can swap in an in-memory writer with no Lance dependency.
Method names mirror :class:`ursa.catalog.Catalog`'s typed wrappers
(``add_participant`` / ``add_recording`` / ``add_modality`` /
``add_event``), so the real :class:`Catalog` structurally satisfies this
Protocol without an adapter layer.
Implementations MUST raise :class:`ursa.catalog.CatalogRowExists` (or any
subclass — :class:`~ursa.catalog.CatalogPKConflict` qualifies) when the
row's ``__primary_key__`` is already present in the target table. Phase
1a is intentionally non-idempotent — see ENG-1074.
"""
from __future__ import annotations
from typing import Protocol
from ursa.catalog import EventRow, ModalityRow, ParticipantRow, RecordingRow
[docs]
class CatalogWriter(Protocol):
"""Insert-only contract that :class:`ursa.catalog.Catalog` satisfies."""
[docs]
def add_participant(self, row: ParticipantRow) -> None: ...
[docs]
def add_recording(self, row: RecordingRow) -> None: ...
[docs]
def add_modality(self, row: ModalityRow) -> None: ...
[docs]
def add_event(self, row: EventRow) -> None: ...