bayesline.api.AsyncSettingsResolver#

class bayesline.api.AsyncSettingsResolver#

Abstract base class for async settings resolvers.

__init__()#

Methods

__init__()

errors_against_settings_menu(settings[, ...])

Get errors that the given settings have against the settings menu.

has_all_references(raw_settings[, ...])

Check if the given settings have all their references.

is_corrupted(raw_setting)

Check if the given raw settings are corrupted.

is_valid(raw_setting[, settings_menus])

Check if the given raw settings are valid.

model_types()

Get model types mapping.

resolve_references(references)

Resolve the given settings references.

resolve_settings(settings)

Resolve the given references.

to_settings_model(raw_settings[, resolve, ...])

Convert the given raw settings to a settings model.

abstract classmethod model_types() dict[str, type[Settings]]#

Get model types mapping.

Returns#

dict[ModelType, type[Settings]]

A dictionary of the model types (str) to their type instance. Typically this is e.g. {UniverseSettings.__name__: UniverseSettings}.

abstract async resolve_settings(settings: list[Settings]) list[RawSettings]#

Resolve the given references.

Parameters#

settingslist[Settings]

The settings to resolve.

Returns#

list[RawSettings]

List of raw settings exactly in the same order as the input.

abstract async resolve_references(references: list[tuple[str, str | int]]) list[RawSettings]#

Resolve the given settings references.

Parameters#

referenceslist[tuple[ModelType, str | int]]

The settings references to resolve.

Returns#

list[RawSettings]

List of raw settings exactly in the same order as the input.

async to_settings_model(raw_settings: RawSettings, resolve: bool = False, settings_menus: dict[tuple[type[Settings], str | None], SettingsMenuType] | None = None) Settings#

Convert the given raw settings to a settings model.

Parameters#

raw_settingsRawSettings

The raw settings to convert.

resolvebool, default=False

If True, the references are resolved.

settings_menusSettingsMenusDict, default=None

A dictionary of (settings type, dataset) to the settings menu. If the key is not in the dictionary, the settings menu will be pulled from the registry and added to this dictionary. If None, the settings menu will be pulled from the registry and discarded after use.

Returns#

Settings

The settings model.

Raises#

InvalidSettingsError

If the raw settings are invalid.

NotImplementedError

If resolve=True is not implemented.

async is_valid(raw_setting: RawSettings, settings_menus: dict[tuple[type[Settings], str | None], SettingsMenuType] | None = None) bool#

Check if the given raw settings are valid.

Parameters#

raw_settingRawSettings

The raw settings to check.

settings_menusSettingsMenusDict, default=None

A dictionary of (settings type, dataset) to the settings menu. If the key is not in the dictionary, the settings menu will be pulled from the registry and added to this dictionary. If None, the settings menu will be pulled from the registry and discarded after use.

Returns#

bool

True if the raw setting is valid, False otherwise.

is_corrupted(raw_setting: RawSettings) bool#

Check if the given raw settings are corrupted.

Parameters#

raw_settingRawSettings

The raw settings to check.

Returns#

bool

True if the raw setting is corrupted, False otherwise.

async has_all_references(raw_settings: RawSettings, settings_menus: dict[tuple[type[Settings], str | None], SettingsMenuType] | None = None) bool#

Check if the given settings have all their references.

Parameters#

raw_settingsRawSettings

The raw settings to check.

settings_menusSettingsMenusDict, default=None

A dictionary of (settings type, dataset) to the settings menu. If the key is not in the dictionary, the settings menu will be pulled from the registry and added to this dictionary. If None, the settings menu will be pulled from the registry and discarded after use.

Returns#

bool

True if the settings have all their references, False otherwise.

abstract async errors_against_settings_menu(settings: Settings, settings_menus: dict[tuple[type[Settings], str | None], SettingsMenuType] | None = None) list[str]#

Get errors that the given settings have against the settings menu.

Parameters#

settingsSettings

The settings to validate.

settings_menusSettingsMenusDict, default=None

A dictionary of (settings type, dataset) to the settings menu. If the key is not in the dictionary, the settings menu will be pulled from the registry and added to this dictionary. If None, the settings menu will be pulled from the registry and discarded after use.

Returns#

list[str]

A list of error messages if the settings are invalid against the settings menu.