ursa.store.factory

Config loading + get_store() factory.

Search order for the YAML config:

  1. Explicit path argument

  2. URSA_CONFIG env var

  3. ./ursa.yaml in the current working directory

  4. Packaged 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_config_source

Resolve the config source.

load_config

Load and validate the Ursa config from a YAML file.

get_store

Return the ObjectStore bound to role in the active config.

_build

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: FileNotFoundError

Raised when an explicit config path argument or URSA_CONFIG env 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. label is 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 ObjectStore bound to role in the active config.

Pass an already-loaded config to avoid re-reading the YAML, or config_path to 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) if role is 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]