clabe.aind.dataverse ¶
DataverseSuggestion ¶
Bases: BaseModel
Internal representation of a suggestion entry in Dataverse.
validate_trainer_state
classmethod
¶
Validate and convert the trainer_state field from a JSON string to a TrainerState object.
Source code in src/clabe/aind/dataverse.py
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/aind/dataverse.py
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/aind/dataverse.py
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
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/aind/dataverse.py
write ¶
Appends a new suggestion for the subject in scope.
Source code in src/clabe/aind/dataverse.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. |