Tasks
albert.collections.tasks.TaskCollection
Bases: BaseCollection
Manage Tasks in the Albert platform.
A Task is a unit of lab work. There are three kinds, and choosing the right one matters:
- PropertyTask: test and document the properties of products/formulas or raw materials. This is the task type that captures measured Property Data. A PropertyTask holds one or more Blocks, each pairing a Data Template (the results to capture) with a Workflow (the conditions to run under).
- BatchTask: manufacture a batch within Albert after creating a new formulation.
- GeneralTask: anything else happening in the lab that is not a batch or property task (e.g. equipment calibration). Has no blocks.
Typical PropertyTask flow: create the task, attach a Block with
add_block (a Data Template + a Workflow), then record results through
the Property Data collection
(PropertyDataCollection). Measured
results roll up to the associated inventory item's properties.
This collection is accessed as client.tasks.
Example
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
AlbertSession
|
The authenticated Albert session used for API calls. |
required |
Attributes:
| Name | Type | Description |
|---|---|---|
base_path |
str
|
The base API route for task requests. |
Methods:
| Name | Description |
|---|---|
create |
Create a PropertyTask, BatchTask, or GeneralTask. |
get_by_id |
Get a single fully populated task by its ID. |
search |
Fast, lightweight search returning partial tasks. |
get_all |
Same filters as search, but returns fully populated tasks. |
update |
Update an existing task. |
delete |
Delete a task by its ID. |
add_block |
Add a Block (Data Template + Workflow) to a Property or Batch task. |
remove_block |
Remove a Block from a Property or Batch task. |
update_block_workflow |
Swap the Workflow assigned to a Block. |
import_results |
Import measured results into a Property task from a file or attachment. |
get_history |
Get a task's audit history. |
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
AlbertSession
|
The authenticated Albert session used for API calls. |
required |
Source code in src/albert/collections/tasks.py
create
create(
*, task: PropertyTask | GeneralTask | BatchTask
) -> BaseTask
Create a new task.
Pass the concrete task type you want to create. Its category is set
automatically by the type, so the platform routes it correctly:
PropertyTask: test/document properties.BatchTask: manufacture a batch.GeneralTask: any other lab work.
For a PropertyTask, set parent_id to the parent Project ID. Blocks are
added separately with add_block after creation.
Example
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
task
|
PropertyTask or GeneralTask or BatchTask
|
The task to create. |
required |
Returns:
| Type | Description |
|---|---|
BaseTask
|
The created task (a |
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 or Batch task.
A Block pairs a Data Template (the results/data columns to capture) with a Workflow (the parameter conditions to run under). A task can hold multiple blocks, e.g. one per test. Once a block exists, results are written against it through the Property Data collection.
Example
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
task_id
|
TaskId
|
The task to add the block to (format |
required |
data_template_id
|
DataTemplateId
|
The Data Template supplying the block's results/data columns
(format |
required |
workflow_id
|
WorkflowId
|
The Workflow supplying the block's parameter conditions
(format |
required |
Returns:
| Type | Description |
|---|---|
None
|
|
See Also
remove_block : Remove a block from a task. update_block_workflow : Change the workflow on an existing block.
Source code in src/albert/collections/tasks.py
update_block_workflow
update_block_workflow(
*,
task_id: TaskId,
block_id: BlockId,
workflow_id: WorkflowId,
) -> None
Swap the Workflow assigned to a Block within a task.
Use this to change the conditions a block runs under without removing and re-adding the block. The task must be a Property or Batch task.
Example
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
task_id
|
TaskId
|
The task containing the block (format |
required |
block_id
|
BlockId
|
The block to update (format |
required |
workflow_id
|
WorkflowId
|
The new Workflow to assign to the block (format |
required |
Returns:
| Type | Description |
|---|---|
None
|
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If the task is not a PropertyTask or BatchTask. |
Notes
If the block already uses workflow_id, no change is made. A block's
default placeholder workflow ("No Parameter Group") is skipped when it is
not the block's only workflow.
Source code in src/albert/collections/tasks.py
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 | |
remove_block
Remove a Block from a Property or Batch task.
Removing a block also removes the results captured against it. To keep the
block but change its conditions, use update_block_workflow instead.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
task_id
|
TaskId
|
The task to remove the block from (e.g. |
required |
block_id
|
BlockId
|
The block to remove (e.g. |
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.
Example
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 write to, as an interval ID ( |
'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. |
Source code in src/albert/collections/tasks.py
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 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 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 604 605 606 607 | |
delete
delete(*, id: TaskId) -> None
Delete a task by its ID.
Deleting a task also removes any results recorded against its blocks.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
TaskId
|
The task to delete (format |
required |
Returns:
| Type | Description |
|---|---|
None
|
|
Source code in src/albert/collections/tasks.py
get_by_id
Get a single, fully populated task by its ID.
The returned object is the concrete type matching the task's category:
PropertyTask, BatchTask, or GeneralTask. For a PropertyTask
this includes its blocks.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
TaskId
|
The task to retrieve (format |
required |
Returns:
| Type | Description |
|---|---|
BaseTask
|
The fully populated task. |
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,
assigned_to_id: 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,
from_created_at: str | None = None,
to_created_at: str | None = None,
updated_by: str | list[str] | None = None,
from_updated_at: str | None = None,
to_updated_at: str | None = None,
additional_field: str | list[str] | None = None,
collaborator_pop_up: bool | None = None,
contains_field: list[str] | None = None,
contains_text: list[str] | None = None,
due_date_duration: str | None = None,
facet_field: str | None = None,
facet_text: str | None = None,
has_attachment: str | list[str] | None = None,
has_notes: str | list[str] | None = None,
linked_to: list[str] | None = None,
source_field: str | list[str] | None = None,
witness_status: list[str] | None = None,
metadata_filters: dict[str, Any] | None = None,
order_by: OrderBy = DESCENDING,
sort_by: str | None = None,
max_items: int | None = None,
offset: int = 0,
) -> Iterator[TaskSearchItem]
Search for tasks matching the given filters.
Returns lightweight, partially populated results and is the fastest way to
look tasks up. When you need complete tasks (e.g. a PropertyTask's blocks),
use get_all with the same filters, or pass the resulting IDs to
get_by_id. Results are returned as a lazily paginated iterator.
Example
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]
|
Filter by task IDs (e.g., |
None
|
linked_task
|
list[str]
|
Task IDs linked to the ones being searched. |
None
|
category
|
TaskCategory
|
Filter by task category: |
None
|
albert_id
|
list[str]
|
Filter by Albert IDs of entities linked to the tasks (e.g. inventory
IDs like |
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]
|
Filter by creator. Accepts user display name(s) or UserId(s) (e.g.
|
None
|
project_id
|
ProjectId
|
ID of the parent project for filtering tasks. |
None
|
from_created_at
|
str
|
Only include items created on or after this date (ISO 8601). |
None
|
to_created_at
|
str
|
Only include items created on or before this date (ISO 8601). |
None
|
updated_by
|
str or list[str]
|
Filter by user(s) who last updated the tasks. Accepts UserId(s) only
(e.g. |
None
|
from_updated_at
|
str
|
Only include items updated on or after this date (ISO 8601). |
None
|
to_updated_at
|
str
|
Only include items updated on or before this date (ISO 8601). |
None
|
assigned_to_id
|
list[str]
|
Filter by assigned user ID(s) (e.g. |
None
|
additional_field
|
str or list[str]
|
Request additional columns from the search index. |
None
|
collaborator_pop_up
|
bool
|
When True, restrict results for the collaborator pop-up UI. |
None
|
contains_field
|
list[str]
|
Fields to search inside. |
None
|
contains_text
|
list[str]
|
Values to search for within |
None
|
due_date_duration
|
str
|
Filter by due date duration bucket. |
None
|
facet_field
|
str
|
Facet field to filter on. |
None
|
facet_text
|
str
|
Facet text to search for. |
None
|
has_attachment
|
str or list[str]
|
Filter tasks by attachment presence. |
None
|
has_notes
|
str or list[str]
|
Filter tasks by note presence. |
None
|
linked_to
|
list[str]
|
Filter by linked entity ID(s). |
None
|
source_field
|
str or list[str]
|
Restrict which fields are returned in the response. |
None
|
witness_status
|
list[str]
|
Filter by witness status (e.g. |
None
|
metadata_filters
|
dict[str, Any]
|
Filter by custom field (metadata) values. |
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 tasks to return in total. If None, iterates over all matches. |
None
|
Returns:
| Type | Description |
|---|---|
Iterator[TaskSearchItem]
|
A lazily paginated iterator of partially populated search results. |
Source code in src/albert/collections/tasks.py
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 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 | |
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,
assigned_to_id: 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,
from_created_at: str | None = None,
to_created_at: str | None = None,
updated_by: str | list[str] | None = None,
from_updated_at: str | None = None,
to_updated_at: str | None = None,
additional_field: str | list[str] | None = None,
collaborator_pop_up: bool | None = None,
contains_field: list[str] | None = None,
contains_text: list[str] | None = None,
due_date_duration: str | None = None,
facet_field: str | None = None,
facet_text: str | None = None,
has_attachment: str | list[str] | None = None,
has_notes: str | list[str] | None = None,
linked_to: list[str] | None = None,
source_field: str | list[str] | None = None,
witness_status: list[str] | None = None,
metadata_filters: dict[str, Any] | None = None,
order_by: OrderBy = DESCENDING,
sort_by: str | None = None,
max_items: int | None = None,
offset: int = 0,
) -> Iterator[BaseTask]
Get fully populated tasks matching the given filters.
Accepts the same filters as search but returns complete task
entities (PropertyTask, BatchTask, or GeneralTask) rather than
lightweight search results. This is slower because it fetches full detail
for every match, so prefer search when you only need names, IDs, or
status. Results are returned as a lazily paginated iterator.
Example
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]
|
Filter by task IDs (e.g. |
None
|
linked_task
|
list[str]
|
Task IDs linked to the ones being searched. |
None
|
category
|
TaskCategory
|
Filter by task category: |
None
|
albert_id
|
list[str]
|
Filter by Albert IDs of entities linked to the tasks (e.g. inventory
IDs like |
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. |
None
|
parameter_group
|
list[str]
|
Parameter Group names associated with tasks. |
None
|
created_by
|
list[str]
|
Filter by creator. Accepts user display name(s) or UserId(s) (e.g.
|
None
|
project_id
|
ProjectId
|
ID of the parent project for filtering tasks. |
None
|
from_created_at
|
str
|
Only include items created on or after this date (ISO 8601). |
None
|
to_created_at
|
str
|
Only include items created on or before this date (ISO 8601). |
None
|
updated_by
|
str or list[str]
|
Filter by user(s) who last updated the tasks. Accepts UserId(s) only
(e.g. |
None
|
from_updated_at
|
str
|
Only include items updated on or after this date (ISO 8601). |
None
|
to_updated_at
|
str
|
Only include items updated on or before this date (ISO 8601). |
None
|
assigned_to_id
|
list[str]
|
Filter by assigned user ID(s) (e.g. |
None
|
additional_field
|
str or list[str]
|
Request additional columns from the search index. |
None
|
collaborator_pop_up
|
bool
|
When True, restrict results for the collaborator pop-up UI. |
None
|
contains_field
|
list[str]
|
Fields to search inside. |
None
|
contains_text
|
list[str]
|
Values to search for within |
None
|
due_date_duration
|
str
|
Filter by due date duration bucket. |
None
|
facet_field
|
str
|
Facet field to filter on. |
None
|
facet_text
|
str
|
Facet text to search for. |
None
|
has_attachment
|
str or list[str]
|
Filter tasks by attachment presence. |
None
|
has_notes
|
str or list[str]
|
Filter tasks by note presence. |
None
|
linked_to
|
list[str]
|
Filter by linked entity ID(s). |
None
|
source_field
|
str or list[str]
|
Restrict which fields are returned in the response. |
None
|
witness_status
|
list[str]
|
Filter by witness status (e.g. |
None
|
metadata_filters
|
dict[str, Any]
|
Filter by custom field (metadata) values. |
None
|
order_by
|
OrderBy
|
Sort direction. Default |
DESCENDING
|
sort_by
|
str
|
Attribute to sort tasks by (e.g. |
None
|
max_items
|
int
|
Maximum number of tasks to return in total. If None, iterates over all matches. |
None
|
Returns:
| Type | Description |
|---|---|
Iterator[BaseTask]
|
Fully populated tasks. Preserves |
Source code in src/albert/collections/tasks.py
878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 | |
update
Update an existing task.
Fetch the task (e.g. with get_by_id), modify the updatable fields,
then pass it here. Only the fields listed in Notes are applied. To change a
task's blocks, use add_block, remove_block, or
update_block_workflow instead.
Example
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
task
|
BaseTask
|
The task to update. Must have a valid |
required |
Returns:
| Type | Description |
|---|---|
BaseTask
|
The updated task. |
Notes
The following fields can be updated: due_date, metadata, name,
priority, project, state.
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
Get the audit history for a task.
Returns the chronological record of changes made to the task (and, optionally, a specific block).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
TaskId
|
The task to inspect (format |
required |
order
|
OrderBy
|
Sort direction for history entries. Default |
DESCENDING
|
limit
|
int
|
Maximum number of history entries to return. |
1000
|
entity
|
HistoryEntity
|
Restrict history to a specific entity scope (e.g. |
None
|
blockId
|
str
|
Restrict history to a specific block. |
None
|
startKey
|
str
|
Pagination key used to continue a previous history query. |
None
|
Returns:
| Type | Description |
|---|---|
TaskHistory
|
The task's history entries plus pagination metadata. |