Skip to content

DatasetStore

The port that keeps the installation's datasets: reviewed documents with a purpose, training or evaluation.

Port: DatasetStore, declared in indx_interfaces.protocols over the models in indx_interfaces.datasets (ADR-0077).

A Dataset is a key (invoices_eval), a name, a DatasetPurpose (training or evaluation), optionally the type its documents are, and its documents: each a digest with the document’s name copied. Its examples are the labels kept on those digests, read from the LabelStore when asked.

class DatasetStore(Protocol):
def put(self, owner: OwnerId, dataset: Dataset) -> None: ...
def get(self, owner: OwnerId, dataset_id: DatasetId) -> Dataset | None: ...
def list(self, owner: OwnerId) -> tuple[Dataset, ...]: ...
def delete(self, owner: OwnerId, dataset_id: DatasetId) -> bool: ...

A fifth store port rather than more methods on LabelStore, because a dataset changes when a person curates it and a label when a person reviews: the ports split by aggregate. A dataset never expires, so there is no purge. Three backends ship: memory, sqlite and postgres, named by INDX_DATASET_STORE.

  • Owner. Every method takes an OwnerId first, and nothing crosses owners.
  • Identity. Within an owner, a dataset is its key; put replaces the one with the same key.
  • Idempotence. delete of a key that is not there is False.
  • Order. list returns the owner’s datasets by key.
  • Validation. The model refuses a digest listed twice. The server, not the store, checks that the type exists and that no digest is in an evaluation and a training dataset of the same type.

tests/unit/test_store_conformance.py holds every installed backend to these rules.