stores.dataverse¶
DataverseSuggestion ¶
Bases: BaseModel
Internal representation of a suggestion entry in Dataverse.
validate_trainer_state
classmethod
¶
validate_trainer_state(value)
Validate and convert the trainer_state field from a JSON string to a TrainerState object.
Source code in src/clabe/stores/dataverse.py
411 412 413 414 415 416 417 418 419 420 421 | |
from_request_output
classmethod
¶
from_request_output(
subject: str, request_output: dict
) -> DataverseSuggestion
Create a _Suggestion instance from a dictionary of data.
Source code in src/clabe/stores/dataverse.py
423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 | |
from_trainer_state
classmethod
¶
from_trainer_state(
subject: str, trainer_state: TrainerState
) -> DataverseSuggestion
Create a _Suggestion instance from a TrainerState object.
Source code in src/clabe/stores/dataverse.py
450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 | |
DataverseStore ¶
DataverseStore(
*,
client: _DataverseRestClient | None = None,
history: int = _DEFAULT_HISTORY,
scope: Scope | None = None,
)
Bases: StoreBase
A store over the Dataverse suggestion tables, serving trainer state only.
Reads and appends to aibs_fact_mouse_proposed_behavior_sessionses, keyed
through aibs_dim_mices. Requires subject and task_name in scope.
Example
store = CompositeStore(
default=LocalFileStore(root=VR_LIB),
routes={"trainer_state": DataverseStore()},
)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
client
|
_DataverseRestClient | None
|
The REST client. Defaults to one built from KeePass credentials. |
None
|
history
|
int
|
How many recent suggestions to offer. At the default of 1 the latest suggestion is used without prompting. |
_DEFAULT_HISTORY
|
scope
|
Scope | None
|
Initial scope. |
None
|
Source code in src/clabe/stores/dataverse.py
507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 | |
write ¶
write(
kind: KindLike[T],
value: T,
*,
scope: Scope | None = None,
) -> None
Appends a new suggestion for the subject in scope.
Source code in src/clabe/stores/dataverse.py
539 540 541 542 543 544 545 546 | |
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 | |