ursa.store.factory¶
Config loading + get_store() factory.
Search order for the YAML config:
Explicit
pathargumentURSA_CONFIGenv var./ursa.yamlin the current working directoryPackaged
ursa.default.yaml
The packaged config is profile-agnostic; bucket and credential routing
based on CONSTELLATION_PROFILE happens inside constellation-utils.
Module Contents¶
Functions¶
Resolve the config source. |
|
Load and validate the Ursa config from a YAML file. |
|
Return the |
|
Data¶
API¶
- ursa.store.factory.__all__¶
[‘load_config’, ‘get_store’, ‘ConfigNotFoundError’]
- ursa.store.factory._DEFAULT_ROLE¶
‘default’
- ursa.store.factory._CONFIG_ENV_VAR¶
‘URSA_CONFIG’
- ursa.store.factory._CWD_FILENAME¶
‘ursa.yaml’
- ursa.store.factory._PACKAGED_CONFIG¶
‘ursa.default.yaml’
- exception ursa.store.factory.ConfigNotFoundError[source]¶
Bases:
FileNotFoundErrorRaised when an explicit config path argument or
URSA_CONFIGenv points at a file that doesn’t exist. (The packaged-default fallback is always available, so this only fires when the caller explicitly asked for a path that wasn’t found.)Initialization
Initialize self. See help(type(self)) for accurate signature.
- ursa.store.factory._resolve_config_source(path: pathlib.Path | None) tuple[str, Any][source]¶
Resolve the config source.
Returns
(label, file_obj_or_path)where the file contents will be parsed as YAML.labelis used in error messages.
- ursa.store.factory.load_config(path: pathlib.Path | None = None) ursa.store.config.UrsaConfig[source]¶
Load and validate the Ursa config from a YAML file.
- ursa.store.factory.get_store(role: str = _DEFAULT_ROLE, *, config: ursa.store.config.UrsaConfig | None = None, config_path: pathlib.Path | None = None) ursa.store.base.ObjectStore[source]¶
Return the
ObjectStorebound torolein the active config.Pass an already-loaded
configto avoid re-reading the YAML, orconfig_pathto override the search order. Without either, the YAML is resolved through the search-order described in the module docstring.Raises
KeyError(with the available role list) ifroleis not defined in the active config.
- ursa.store.factory._build(cfg: ursa.store.config.R2StoreConfig | ursa.store.config.LocalStoreConfig, *, role: str) ursa.store.base.ObjectStore[source]¶