clabe.aind.modifiers ¶
ByAnimalModifier ¶
Injects per-animal state into a rig, and saves it back, through a Store.
The store decides where per-animal state lives, so the same modifier works against the config
library, Dataverse or an in-memory fake. The store is narrowed to subject on construction.
Example
class ManipulatorModifier(ByAnimalModifier[MyRig]):
def __init__(self, subject: str, store: Store):
super().__init__(subject, store, Kind(ManipulatorPosition), "manipulator.position")
def _process_before_update(self) -> ManipulatorPosition:
return read_position_from_hardware()
modifier = ManipulatorModifier(session.subject, store)
rig = modifier.inject(rig)
...
modifier.update()
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
subject
|
str
|
The animal this modifier reads and writes state for. |
required |
store
|
Store
|
The store holding this record. Narrowed to |
required |
kind
|
KindLike[Any]
|
The record kind to read and write. |
required |
model_path
|
str
|
Dot-separated path to the target attribute in the rig model. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in src/clabe/aind/modifiers.py
inject ¶
Returns a copy of the rig with the stored record injected; the given rig is never modified.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rig
|
TRig
|
The rig model. |
required |
Returns:
| Type | Description |
|---|---|
TRig
|
A copy of the rig, with the record injected (an unchanged copy if there is none). |
Source code in src/clabe/aind/modifiers.py
update ¶
Persists the record produced by _process_before_update.
Raises:
| Type | Description |
|---|---|
Exception
|
Whatever |
Source code in src/clabe/aind/modifiers.py
recursive_setattr ¶
Sets an attribute value using a dot-separated path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Any
|
The object to modify |
required |
attr
|
str
|
Dot-separated attribute path (e.g., "nested.field.value") |
required |
val
|
Any
|
The value to set |
required |
Example
Source code in src/clabe/aind/modifiers.py
rgetattr ¶
Gets an attribute value using a dot-separated path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Any
|
The object to query |
required |
attr
|
str
|
Dot-separated attribute path (e.g., "nested.field.value") |
required |
*args
|
Any
|
Optional default value if attribute doesn't exist |
()
|
Returns:
| Type | Description |
|---|---|
Any
|
The attribute value at the specified path |