clabe.aind.smartsheet ¶
SmartsheetRow ¶
Bases: BaseModel
A parsed row of the scheduling smartsheet.
Fields are populated from the sheet's column names (or by field name). Blank or null
string values become None, and every column not modeled here is kept in model_extra.
SmartsheetScheduleClient ¶
SmartsheetScheduleClient(
base_url: str = DEFAULT_SMARTSHEET_ENDPOINT,
timeout: float | tuple[float, float] | None = (1, 4),
validator: Callable[
[str], str | None
] = validate_username,
)
Client for the AIND behavior scheduling smartsheet, looked up by animal.
Rows are parsed into rows and are cached per subject, so a session only costs one request. get_row degrades to a logged warning
and None when the service is unreachable, but add_scientific_contact and
get_project_name require their values and raise ValueError without them.
Example
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base_url
|
str
|
Root URL of the smartsheet service. |
DEFAULT_SMARTSHEET_ENDPOINT
|
timeout
|
float | tuple[float, float] | None
|
Timeout in seconds for each HTTP request, or a (connect, read) pair. |
(1, 4)
|
validator
|
Callable[[str], str | None]
|
Validates the scientific contact's username, returning the canonical name or None to reject it. Defaults to the Active Directory lookup. |
validate_username
|
Source code in src/clabe/aind/smartsheet.py
get_row ¶
get_row(subject: str) -> SmartsheetRow | None
Fetches the parsed sheet row for an animal.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
subject
|
str
|
The animal (mouse) id. |
required |
Returns:
| Type | Description |
|---|---|
SmartsheetRow | None
|
The row, or None if the animal is not found or the service is unreachable. |
SmartsheetRow | None
|
Only found rows and definitive not-found results are cached; failures are retried on the next call. |
Source code in src/clabe/aind/smartsheet.py
add_scientific_contact ¶
Returns a copy of the session with the animal's validated scientific contact added
to the end of experimenter, with duplicate names removed (first occurrence kept).
The given session is never modified.
The scientific contact is required: this raises instead of degrading.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
Session
|
The session to build on. |
required |
Returns:
| Type | Description |
|---|---|
Session
|
The updated copy of the session, so callers must use the return value. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the animal's row cannot be retrieved, the row has no scientific contact, or the username fails validation. |
Source code in src/clabe/aind/smartsheet.py
get_project_name ¶
get_project_name(session: Session) -> str
Returns the project name recorded for the session's animal.
The project name is required: this raises instead of degrading.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
Session
|
The session whose animal to look up. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The project name. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the animal's row cannot be retrieved or has no project name. |