bayesline.api.RegistryBasedApiBase#

class bayesline.api.RegistryBasedApiBase#

Concrete base for RegistryBasedApi implementations.

Implements the standard load flow once so loaders only have to write the construction step:

  1. If ref_or_settings is a str/int, resolve it through self.settings.read(...) and unwrap to a DatasetAwareSettings[T].

  2. Call self.validate(settings) which fetches the dataset status via the _get_dataset_status hook (raising DatasetError if missing or corrupt), then fetches the menu and runs settings.setting.validate_settings(menu).

  3. Delegate to self._load(settings, *, name, id_) for the actual construction. name / id_ carry the original reference if one was passed (None otherwise).

Subclasses override _load, _get_dataset_status, and the settings property.

__init__()#

Methods

__init__()

load(ref_or_settings, *args, **kwargs)

Load an API instance from settings or reference.

validate(settings)

Validate settings against the menu for its dataset.

Attributes

settings

Get the settings registry.

validate(settings: DatasetAwareSettings[T]) None#

Validate settings against the menu for its dataset.

Fetches the menu from settings.dataset and runs the bound Settings.validate_settings against it. Raises pydantic.ValidationError (or subclasses) on failure.

Parameters#

settingsDatasetAwareSettings[T]

The dataset-bound settings to validate.

load(ref_or_settings: str | int | DatasetAwareSettings[T], *args: Any, **kwargs: Any) ApiType#

Load an API instance from settings or reference.

The standard flow is: resolve a str/int reference to a DatasetAwareSettings via the registry, validate it, then construct the concrete API. Implementations typically inherit RegistryBasedApiBase to get this flow for free and only override _load.

Parameters#

ref_or_settingsstr | int | DatasetAwareSettings[T]

Reference identifier, numeric ID, or dataset-bound settings.

*argsAny

Additional positional arguments passed to the loader.

**kwargsAny

Additional keyword arguments passed to the loader.

Returns#

ApiType

The loaded API instance.