Workflows
albert.collections.workflows
AlbertPaginator
AlbertPaginator(
*,
path: str,
mode: PaginationMode,
session: AlbertSession,
deserialize: Callable[
[Iterable[dict]], Iterable[ItemType]
],
params: dict[str, str] | None = None,
)
Bases: Iterator[ItemType]
Helper class for pagination through Albert endpoints.
Two pagination modes are possible:
- Offset-based via by the offset query parameter
- Key-based via by the startKey query parameter and 'lastKey' response field
A custom deserialize function is provided when additional logic is required to load
the raw items returned by the search listing, e.g., making additional Albert API calls.
Source code in src/albert/core/pagination.py
AlbertSession
AlbertSession(
*,
base_url: str,
token: str | None = None,
auth_manager: AlbertClientCredentials
| AlbertSSOClient
| None = None,
retries: int | None = None,
)
Bases: Session
A session that has a base URL, which is prefixed to all request URLs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base_url
|
str
|
The base URL to prefix to all relative request paths (e.g., "https://app.albertinvent.com"). |
required |
token
|
str | None
|
A static JWT token for authentication. Ignored if |
None
|
auth_manager
|
AlbertClientCredentials | AlbertSSOClient
|
An authentication manager used to dynamically fetch and refresh tokens.
If provided, it overrides |
None
|
retries
|
int
|
The number of automatic retries on failed requests (default is 3). |
None
|
Methods:
| Name | Description |
|---|---|
request |
|
Source code in src/albert/core/session.py
request
Source code in src/albert/core/session.py
BaseCollection
BaseCollection(*, session: AlbertSession)
BaseCollection is the base class for all collection classes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
AlbertSession
|
The Albert API Session instance. |
required |
Source code in src/albert/collections/base.py
PaginationMode
Workflow
Bases: BaseResource
A Pydantic Class representing a workflow in Albert.
Workflows are combinations of Data Templates and Parameter groups and their associated setpoints.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
The name of the workflow. |
parameter_group_setpoints |
list[ParameterGroupSetpoints]
|
The setpoints to apply to the parameter groups in the workflow. |
id |
str | None
|
The AlbertID of the workflow. This is set when a workflow is retrived from the platform. |
Methods:
| Name | Description |
|---|---|
get_interval_id |
Get the interval ID for a set of parameter values. |
model_post_init |
|
id
class-attribute
instance-attribute
id: str | None = Field(
alias="albertId",
default=None,
validation_alias=AliasChoices(
"albertId", "existingAlbertId"
),
exclude=True,
)
interval_combinations
class-attribute
instance-attribute
interval_combinations: list[IntervalCombination] | None = (
Field(default=None, alias="IntervalCombinations")
)
parameter_group_setpoints
class-attribute
instance-attribute
parameter_group_setpoints: list[ParameterGroupSetpoints] = (
Field(alias="ParameterGroups")
)
get_interval_id
Get the interval ID for a set of parameter values.
This method matches parameter values to intervals defined in the workflow and constructs a composite interval ID. For multiple parameters, the interval IDs are joined with 'X'.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parameter_values
|
dict[str, any]
|
Dictionary mapping parameter names to their values. Values can be numbers or strings that match the interval values defined in the workflow. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The composite interval ID string. For a single parameter this is just the interval ID. For multiple parameters, interval IDs are joined with 'X' (e.g. "ROW1XROW2"). |
Raises:
| Type | Description |
|---|---|
ValueError
|
If any parameter value does not match a defined interval in the workflow. |
Examples:
>>> workflow = Workflow(...)
>>> # Single parameter
>>> workflow.get_interval_id({"Temperature": 25})
'ROW1'
>>> # Multiple parameters
>>> workflow.get_interval_id({"Temperature": 25, "Time": 60})
'ROW1XROW2'
>>> # Non-matching value raises error
>>> workflow.get_interval_id({"Temperature": 999})
AlbertException: No matching interval found for parameter 'Temperature' with value '999'
Source code in src/albert/resources/workflows.py
WorkflowCollection
WorkflowCollection(*, session: AlbertSession)
Bases: BaseCollection
WorkflowCollection is a collection class for managing Workflow entities in the Albert platform.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
AlbertSession
|
The Albert session instance. |
required |
Methods:
| Name | Description |
|---|---|
create |
Create or return matching workflows for the provided list of workflows. |
get_all |
Get all workflows. Unlikely to be used in production. |
get_by_id |
Retrieve a Workflow by its ID. |
get_by_ids |
Returns a list of Workflow objects by their IDs. |
Source code in src/albert/collections/workflows.py
create
Create or return matching workflows for the provided list of workflows. This endpoint automatically tries to find an existing workflow with the same parameter setpoints, and will either return the existing workflow or create a new one.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
workflows
|
list[Workflow]
|
A list of Workflow objects to find or create. |
required |
Returns:
| Type | Description |
|---|---|
list[Workflow]
|
A list of created or found Workflow objects. |
Source code in src/albert/collections/workflows.py
get_all
Get all workflows. Unlikely to be used in production.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
limit
|
int
|
The number of workflows to return, by default 50. |
50
|
Yields:
| Type | Description |
|---|---|
Iterator[Workflow]
|
An iterator of Workflow objects. |
Source code in src/albert/collections/workflows.py
get_by_id
get_by_ids
Returns a list of Workflow objects by their IDs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ids
|
list[str]
|
The list of Workflow IDs to retrieve. |
required |
Returns:
| Type | Description |
|---|---|
list[Workflow]
|
The list of Workflow objects matching the provided IDs. |