analysis_request
Pydantic models for the analysis requests from the user --> API server.
AnalysisRequest
pydantic-model
¶
Bases: BaseModel
Analysis request information.
Fields:
-
analysis_config_id(AnalysisConfigIdStr) -
channels(list[ChannelName] | None) -
parameters(list[tuple[str, str | int | float | bool]]) -
dependencies(list[tuple[str, list[EventType]]])
Validators:
analysis_config_id
pydantic-field
¶
The unique analysis config type identifier (e.g., 'u-sleep-research-v1')
channels = None
pydantic-field
¶
Optional list of specific channels (by name) to use in the analysisIf not specified, all channels of types and/or exact match to the analysis' requirements available on the study will be used.
dependencies
pydantic-field
¶
A list of 2-tuples of format (parameter_hash, list of typed events) where parameter_hash identifies a dependency analysis by its parameter hash (SHA-1 hex string), and typed events specify which events are required as input from that dependency. The present analysis will only be run if all dependencies have status COMPLETED. This hash-based approach enables order-independent submission: you can submit an analysis before its dependencies exist, and it will wait in DEPENDENCY status until they complete. If any dependency fails/cancels, this analysis will also fail.
parameters
pydantic-field
¶
Parameters to use in the analysis as per the analysis config. Each parameter is a tuple of [name, value] where name is the api_name from the analysis config.
get_analysis_request_hash(include=('analysis_config_id', 'parameters', 'dependencies', 'channels'))
¶
Return a sha1 hash of the JSON str serialized analysis request.
This can be used to compare the analysis submission against other analysis submissions. Note that only the fields specified in the include set are considered when creating the hash. Per default, all fields are included. This flag is useful to ensure consistent outputs of this function if the class is used as a base class for other classes, which may define other fields in the model.
Boolean parameters are stored as Python bool and serialize consistently to JSON as true/false (lowercase), ensuring consistent hashing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
include
|
Sequence[str]
|
The fields to include in the hash. |
('analysis_config_id', 'parameters', 'dependencies', 'channels')
|
Returns:
| Type | Description |
|---|---|
str
|
The sha1 hash of the analysis and its parameters. |
validate_channels(value)
pydantic-validator
¶
Validate that all channels are unique.