stores.confierge¶
ConfiergeSettings ¶
Bases: ServiceSettings
Settings for :class: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/services.py
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 | |
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
:data: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 :class:~clabe.stores.CompositeStore.
Example
store = ConfiergeStore(ConfiergeSettings(namespace="aind-behavior-vr-foraging"))
rig = store.scoped(subject="789907").resolve(Kind.from_rig(MyRig))
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
:data: |
None
|
client
|
Confierge | None
|
A ready confierge client. Built from |
None
|
Source code in src/clabe/stores/confierge.py
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | |
write ¶
write(
kind: KindLike[T],
value: T,
*,
scope: Scope | None = None,
) -> None
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/stores/confierge.py
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | |
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
218 219 220 221 222 223 224 225 226 | |
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
240 241 242 243 | |
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 :class: |
None
|
Raises:
| Type | Description |
|---|---|
LookupError
|
If no record of this kind exists in scope, or the user declined to pick one. |
NoFrontendError
|
If a choice must be made and no frontend is registered. |
Source code in src/clabe/stores/_base.py
245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 | |