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. |
import_results |
Import results from an attachment into property data. Reuse an existing attachment or upload a |
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 |
Fetch the audit history for the specified task. |
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
import_results
import_results(
*,
task_id: TaskId,
inventory_id: InventoryId,
data_template_id: DataTemplateId,
block_id: BlockId | None = None,
attachment_id: AttachmentId | None = None,
file_path: str | Path | None = None,
note_text: str | None = None,
lot_id: LotId | None = None,
interval: str = "default",
field_mapping: dict[str, str] | None = None,
mode: ImportMode = CSV,
) -> BaseTask
Import results from an attachment into property data. Reuse an existing attachment or upload a new one, optionally provide header-to-column mappings, and target the desired block, lot, and interval. Returns the task after the import.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
task_id
|
TaskId
|
The property task receiving the results. |
required |
block_id
|
BlockId | None
|
Target block on the task where the data will be written. Optional, when a single block present on the task. If multiple blocks exist, this parameter must be provided. |
None
|
inventory_id
|
InventoryId
|
Inventory item id. |
required |
data_template_id
|
DataTemplateId
|
Data template Id. |
required |
attachment_id
|
AttachmentId | None
|
Existing attachment to use. Exactly one of |
None
|
file_path
|
str | Path | None
|
Local file to upload and attach to a new note on the task. Exactly one of
|
None
|
note_text
|
str | None
|
Optional text for the note created when uploading a new file. |
None
|
lot_id
|
LotId | None
|
Lot context when deleting/writing property data. |
None
|
interval
|
str
|
Interval combination to target. Defaults to "default". |
'default'
|
field_mapping
|
dict[str, str] | None
|
Optional mapping from CSV header labels to data column names. Keys should match the
header text from the CSV (case-insensitive comparison is applied), and values should
match the corresponding data template column names. For example,
|
None
|
mode
|
ImportMode
|
Import mode to use, by default ImportMode.CSV. Use ImportMode.SCRIPT to run a custom script to process the CSV before import. This requires a script attachment on the data template. |
CSV
|
Returns:
| Type | Description |
|---|---|
BaseTask
|
The task with the newly imported results. |
Examples:
Import results from a CSV file
Source code in src/albert/collections/tasks.py
229 230 231 232 233 234 235 236 237 238 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 342 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 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 | |
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 | str | list[str] | None = None,
albert_id: list[str] | None = None,
data_template: list[str] | 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[str] | 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 names 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 names associated with tasks. |
None
|
created_by
|
list[str]
|
User names who created the tasks. |
None
|
project_id
|
ProjectId
|
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
496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 | |
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 | str | list[str] | None = None,
albert_id: list[str] | None = None,
data_template: list[str] | 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[str] | 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 names 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 names associated with tasks. |
None
|
created_by
|
list[str]
|
User names who created the tasks. |
None
|
project_id
|
ProjectId
|
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
605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 | |
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
Fetch the audit history for the specified task.