Tasks
albert.collections.tasks.TaskCollection
Bases: BaseCollection
TaskCollection is a collection class for managing Task entities in the Albert platform.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
session
|
AlbertSession
|
The Albert Session information |
required |
Methods:
Name | Description |
---|---|
create |
Create a new task. Tasks can be of different types, such as PropertyTask, and are created using the provided task object. |
add_block |
Add a block to a Property task. |
update_block_workflow |
Update the workflow of a specific block within a task. |
remove_block |
Remove a block from a Property task. |
delete |
Delete a task. |
get_by_id |
Retrieve a task by its ID. |
search |
Search for Task matching the provided criteria. |
get_all |
Retrieve fully hydrated Task entities with optional filters. |
update |
Update a task. |
get_history |
|
Attributes:
Name | Type | Description |
---|---|---|
base_path |
|
Source code in src/albert/collections/tasks.py
create
create(
*, task: PropertyTask | GeneralTask | BatchTask
) -> BaseTask
Create a new task. Tasks can be of different types, such as PropertyTask, and are created using the provided task object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
task
|
PropertyTask | GeneralTask | BatchTask
|
The task object to create. |
required |
Returns:
Type | Description |
---|---|
BaseTask
|
The registered task object. |
Source code in src/albert/collections/tasks.py
add_block
add_block(
*,
task_id: TaskId,
data_template_id: DataTemplateId,
workflow_id: WorkflowId,
) -> None
Add a block to a Property task.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
task_id
|
TaskId
|
The ID of the task to add the block to. |
required |
data_template_id
|
DataTemplateId
|
The ID of the data template to use for the block. |
required |
workflow_id
|
WorkflowId
|
The ID of the workflow to assign to the block. |
required |
Returns:
Type | Description |
---|---|
None
|
This method does not return any value. |
Source code in src/albert/collections/tasks.py
update_block_workflow
update_block_workflow(
*,
task_id: TaskId,
block_id: BlockId,
workflow_id: WorkflowId,
) -> None
Update the workflow of a specific block within a task.
This method updates the workflow of a specified block within a task.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
task_id
|
str
|
The ID of the task. |
required |
block_id
|
str
|
The ID of the block within the task. |
required |
workflow_id
|
str
|
The ID of the new workflow to be assigned to the block. |
required |
Returns:
Type | Description |
---|---|
None
|
This method does not return any value. |
Notes
- The method asserts that the retrieved task is an instance of
PropertyTask
. - If the block's current workflow matches the new workflow ID, no update is performed.
- The method handles the case where the block has a default workflow named "No Parameter Group".
Source code in src/albert/collections/tasks.py
remove_block
Remove a block from a Property task.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
task_id
|
str
|
ID of the Task to remove the block from (e.g., TASFOR1234) |
required |
block_id
|
str
|
ID of the Block to remove (e.g., BLK1) |
required |
Returns:
Type | Description |
---|---|
None
|
|
Source code in src/albert/collections/tasks.py
delete
delete(*, id: TaskId) -> None
Delete a task.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id
|
TaskId
|
The ID of the task to delete. |
required |
get_by_id
Retrieve a task by its ID.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id
|
TaskId
|
The ID of the task to retrieve. |
required |
Returns:
Type | Description |
---|---|
BaseTask
|
The task object with the provided ID. |
Source code in src/albert/collections/tasks.py
search
search(
*,
text: str | None = None,
tags: list[str] | None = None,
task_id: list[TaskId] | None = None,
linked_task: list[TaskId] | None = None,
category: TaskCategory | None = None,
albert_id: list[str] | None = None,
data_template: list[DataTemplateId] | None = None,
assigned_to: list[str] | None = None,
location: list[str] | None = None,
priority: list[str] | None = None,
status: list[str] | None = None,
parameter_group: list[ParameterGroupId] | None = None,
created_by: list[str] | None = None,
project_id: ProjectId | None = None,
order_by: OrderBy = DESCENDING,
sort_by: str | None = None,
max_items: int | None = None,
offset: int = 0,
) -> Iterator[TaskSearchItem]
Search for Task matching the provided criteria.
⚠️ This method returns partial (unhydrated) entities to optimize performance.
To retrieve fully detailed entities, use :meth:get_all
instead.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text
|
str
|
Text search across multiple task fields. |
None
|
tags
|
list[str]
|
Filter by tags associated with tasks. |
None
|
task_id
|
list[str]
|
Specific task IDs to search for. |
None
|
linked_task
|
list[str]
|
Task IDs linked to the ones being searched. |
None
|
category
|
TaskCategory
|
Task category filter (e.g., Experiment, Analysis). |
None
|
albert_id
|
list[str]
|
Albert-specific task identifiers. |
None
|
data_template
|
list[str]
|
Data template IDs associated with tasks. |
None
|
assigned_to
|
list[str]
|
User names assigned to the tasks. |
None
|
location
|
list[str]
|
Locations where tasks are carried out. |
None
|
priority
|
list[str]
|
Priority levels for filtering tasks. |
None
|
status
|
list[str]
|
Task status values (e.g., Open, Done). |
None
|
parameter_group
|
list[str]
|
Parameter Group IDs associated with tasks. |
None
|
created_by
|
list[str]
|
User names who created the tasks. |
None
|
project_id
|
str
|
ID of the parent project for filtering tasks. |
None
|
order_by
|
OrderBy
|
The order in which to return results (asc or desc), default DESCENDING. |
DESCENDING
|
sort_by
|
str
|
Attribute to sort tasks by (e.g., createdAt, name). |
None
|
max_items
|
int
|
Maximum number of items to return in total. If None, fetches all available items. |
None
|
offset
|
int
|
Number of results to skip for pagination, default 0. |
0
|
Returns:
Type | Description |
---|---|
Iterator[TaskSearchItem]
|
An iterator of matching, lightweight TaskSearchItem entities. |
Source code in src/albert/collections/tasks.py
239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 |
|
get_all
get_all(
*,
text: str | None = None,
tags: list[str] | None = None,
task_id: list[TaskId] | None = None,
linked_task: list[TaskId] | None = None,
category: TaskCategory | None = None,
albert_id: list[str] | None = None,
data_template: list[DataTemplateId] | None = None,
assigned_to: list[str] | None = None,
location: list[str] | None = None,
priority: list[str] | None = None,
status: list[str] | None = None,
parameter_group: list[ParameterGroupId] | None = None,
created_by: list[str] | None = None,
project_id: ProjectId | None = None,
order_by: OrderBy = DESCENDING,
sort_by: str | None = None,
max_items: int | None = None,
offset: int = 0,
) -> Iterator[BaseTask]
Retrieve fully hydrated Task entities with optional filters.
This method returns complete entity data using get_by_id
.
Use :meth:search
for faster retrieval when you only need lightweight, partial (unhydrated) entities.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text
|
str
|
Text search across multiple task fields. |
None
|
tags
|
list[str]
|
Filter by tags associated with tasks. |
None
|
task_id
|
list[str]
|
Specific task IDs to search for. |
None
|
linked_task
|
list[str]
|
Task IDs linked to the ones being searched. |
None
|
category
|
TaskCategory
|
Task category filter (e.g., Experiment, Analysis). |
None
|
albert_id
|
list[str]
|
Albert-specific task identifiers. |
None
|
data_template
|
list[str]
|
Data template IDs associated with tasks. |
None
|
assigned_to
|
list[str]
|
User names assigned to the tasks. |
None
|
location
|
list[str]
|
Locations where tasks are carried out. |
None
|
priority
|
list[str]
|
Priority levels for filtering tasks. |
None
|
status
|
list[str]
|
Task status values (e.g., Open, Done). |
None
|
parameter_group
|
list[str]
|
Parameter Group IDs associated with tasks. |
None
|
created_by
|
list[str]
|
User names who created the tasks. |
None
|
project_id
|
str
|
ID of the parent project for filtering tasks. |
None
|
order_by
|
OrderBy
|
The order in which to return results (asc or desc), default DESCENDING. |
DESCENDING
|
sort_by
|
str
|
Attribute to sort tasks by (e.g., createdAt, name). |
None
|
max_items
|
int
|
Maximum number of items to return in total. If None, fetches all available items. |
None
|
offset
|
int
|
Number of results to skip for pagination, default 0. |
0
|
Yields:
Type | Description |
---|---|
Iterator[BaseTask]
|
A stream of fully hydrated Task entities (PropertyTask, BatchTask, or GeneralTask). |
Source code in src/albert/collections/tasks.py
343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 |
|
update
Update a task.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
task
|
BaseTask
|
The updated Task object. |
required |
Returns:
Type | Description |
---|---|
BaseTask
|
The updated Task object as it exists in the Albert platform. |
Source code in src/albert/collections/tasks.py
get_history
get_history(
*,
id: TaskId,
order: OrderBy = DESCENDING,
limit: int = 1000,
entity: HistoryEntity | None = None,
blockId: str | None = None,
startKey: str | None = None,
) -> TaskHistory