clabe.aind.confierge ¶
DEFAULT_SCOPE_MAPPING
module-attribute
¶
DEFAULT_SCOPE_MAPPING: ScopeMapping = MappingProxyType(
{"computer_name": "hostname", "subject": "subject_id"}
)
The scopes ficus is keyed on today. Extend it by passing {**DEFAULT_SCOPE_MAPPING, "rig": "rig_id"} to
ConfiergeStore.
ConfiergeSettings ¶
Bases: ServiceSettings
Settings for ConfiergeStore, read from the confierge section of clabe.yml.
settings_customise_sources
classmethod
¶
settings_customise_sources(
settings_cls: type[BaseSettings],
init_settings: PydanticBaseSettingsSource,
env_settings: PydanticBaseSettingsSource,
dotenv_settings: PydanticBaseSettingsSource,
file_secret_settings: PydanticBaseSettingsSource,
) -> tuple[PydanticBaseSettingsSource, ...]
Customizes the settings sources to include the safe YAML settings source.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
settings_cls
|
type[BaseSettings]
|
The settings class |
required |
init_settings
|
PydanticBaseSettingsSource
|
The initial settings source |
required |
env_settings
|
PydanticBaseSettingsSource
|
The environment settings source |
required |
dotenv_settings
|
PydanticBaseSettingsSource
|
The dotenv settings source |
required |
file_secret_settings
|
PydanticBaseSettingsSource
|
The file secret settings source |
required |
Returns:
| Type | Description |
|---|---|
tuple[PydanticBaseSettingsSource, ...]
|
Tuple[PydanticBaseSettingsSource, ...]: A tuple of settings sources |
Source code in src/clabe/settings.py
ConfiergeStore ¶
ConfiergeStore(
settings: ConfiergeSettings,
*,
scope: Scope | None = None,
scope_mapping: ScopeMapping | None = None,
client: Confierge | None = None,
)
Bases: StoreBase
A store over ficus, through the confierge client.
This is a thin adapter: it translates the store API's scope into ficus' scopes (see
DEFAULT_SCOPE_MAPPING) and leaves merging, validation of scope names and the offline
cache to ficus and confierge. Ficus owns the layering, so a read yields exactly one document and
never prompts.
A store addresses one ficus namespace, whatever the kind. To serve several kinds, give each its
own store and route them with CompositeStore.
Example
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
settings
|
ConfiergeSettings
|
Which namespace and server to use, and how writes behave. |
required |
scope
|
Scope | None
|
Initial scope. |
None
|
scope_mapping
|
ScopeMapping | None
|
Translates scope keys into ficus scope names. Defaults to
|
None
|
client
|
Confierge | None
|
A ready confierge client. Built from |
None
|
Source code in src/clabe/aind/confierge.py
write ¶
Posts a record to ficus, which decides which layer receives it from the scope.
Raises:
| Type | Description |
|---|---|
TypeError
|
If the record does not serialize to a JSON object. |
Source code in src/clabe/aind/confierge.py
scoped ¶
Returns a view sharing this store's data, narrowed by the given scope.
The view is the same concrete store type, so narrowing never loses backend-specific typing.
Source code in src/clabe/stores/_base.py
list ¶
list(
kind: KindLike[T], *, scope: Scope | None = None
) -> Sequence[T]
Returns every record of this kind in scope, validated but unprompted.
Source code in src/clabe/stores/_base.py
resolve ¶
resolve(
kind: KindLike[T],
*,
scope: Scope | None = None,
pick_kwargs: PickRequestKwargs | None = None,
) -> T
Selects a single record: raises on none, auto-selects a lone candidate, prompts otherwise.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
kind
|
KindLike[T]
|
The kind of record to resolve. |
required |
scope
|
Scope | None
|
Narrows which records are considered. Layered over the store's own scope. |
None
|
pick_kwargs
|
PickRequestKwargs | None
|
Optional overrides for the |
None
|
Raises:
| Type | Description |
|---|---|
LookupError
|
If no record of this kind exists in scope, or the user declined to pick one. |
NoSessionError
|
If a choice must be made and nothing can ask the user. |