entoscope.dataset

The dataset extension point.

Its classes are importable from entoscope.dataset.

class entoscope.dataset.config.DatasetConfig(*, type: str, config_id: str | None = None)[source]

Bases: AbstractConfig, MethodConfig

The base of every dataset’s config, whose type names the registered dataset.

A dataset with settings of its own names a dataclass extending this one. A config file’s entry is read strictly into the class its type’s dataset names, as a method config is, so a key that class does not declare fails as the file is read.

classmethod factory() → type[DatasetFactory][source]

Name the factory datasets register with.

Returns:

DatasetFactory.

class entoscope.dataset.dataset.AbstractDataset(config: DatasetConfig)[source]

Bases: ABC, Generic[DatasetConfigT]

The base of every dataset: a collection of raw rows, loaded once.

A subclass implements load and registers with DatasetFactory. Its type argument names the dataclass of its config, extending DatasetConfig, which a config file’s entry is read into. A dataset naming none takes DatasetConfig itself, which no setting fits.

Parameters:

config – The dataset’s config.

abstractmethod load() → list[dict[str, Any]][source]

Read the rows from wherever the config says they are.

Returns:

Every row, as a mapping from column to value.

prepare() → AbstractDataset[source]

Load the rows, once.

Returns:

The dataset itself, loaded in place.

property rows: list[dict[str, Any]]

Every row, once the dataset is prepared.

class entoscope.dataset.factory.DatasetFactory[source]

Bases: RegistryFactory[AbstractDataset]

Resolves a config’s dataset type to a registered implementation. entoscope ships none.

classmethod create(config: DatasetConfig) → AbstractDataset[source]

Build the dataset a config names, unloaded.

Parameters:

config – The dataset’s config, whose type names the dataset.

Returns:

The dataset.

Raises:

ValueError – If no dataset is registered under the name.