bayesline.api.RegistryBasedApiBase#
- class bayesline.api.RegistryBasedApiBase#
Concrete base for
RegistryBasedApiimplementations.Implements the standard
loadflow once so loaders only have to write the construction step:If
ref_or_settingsis astr/int, resolve it throughself.settings.read(...)and unwrap to aDatasetAwareSettings[T].Call
self.validate(settings)which fetches the dataset status via the_get_dataset_statushook (raisingDatasetErrorif missing or corrupt), then fetches the menu and runssettings.setting.validate_settings(menu).Delegate to
self._load(settings, *, name, id_)for the actual construction.name/id_carry the original reference if one was passed (Noneotherwise).
Subclasses override
_load,_get_dataset_status, and thesettingsproperty.- __init__()#
Methods
__init__()load(ref_or_settings, *args, **kwargs)Load an API instance from settings or reference.
validate(settings)Validate
settingsagainst the menu for its dataset.Attributes
settingsGet the settings registry.
- validate(settings: DatasetAwareSettings[T]) None#
Validate
settingsagainst the menu for its dataset.Fetches the menu from
settings.datasetand runs the boundSettings.validate_settingsagainst it. Raisespydantic.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/intreference to aDatasetAwareSettingsvia the registry, validate it, then construct the concrete API. Implementations typically inheritRegistryBasedApiBaseto get this flow for free and only override_load.Parameters#
Returns#
- ApiType
The loaded API instance.