Inventory
albert.collections.inventory.InventoryCollection
Bases: BaseCollection
Manage Inventory Items in the Albert platform.
An Inventory Item is a catalog entry for a physical or formulated material tracked in Albert. Every item belongs to one of five categories:
RawMaterials: purchased substances used as ingredients (e.g. a solvent or pigment), typically linked to a manufacturing Company and one or more CAS numbers.Consumables: supplies consumed during lab work (e.g. gloves, vials).Equipment: instruments and apparatus.Formulas: mixtures designed in Albert. A Formula item is created under its parent Project by passingproject_idtocreate.Reaction: products of chemical reactions recorded in Albert.
Inventory Items are referenced throughout the platform by their Inventory ID
(format INV..., e.g. "INVA9999999"). They are the building blocks that
Worksheets, Tasks, and Property Data all point back to.
This collection is accessed as client.inventory.
Example
from albert import Albert
from albert.resources.inventory import InventoryCategory
client = Albert()
# Find raw materials mentioning "titanium dioxide"
items = client.inventory.get_all(
text="titanium dioxide",
category=InventoryCategory.RAW_MATERIALS,
max_items=25,
)
for item in items:
print(item.id, item.name)
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 inventory requests. |
Methods:
| Name | Description |
|---|---|
create |
Create a new inventory item (raw material, consumable, equipment, or formula). |
create_many |
Create multiple raw material, consumable, or equipment items. |
get_by_id |
Get a single fully populated item by its ID. |
get_by_ids |
Get many items by their IDs in batches. |
search |
Fast, lightweight search returning partial items (best for lookups/counts). |
get_all |
Same filters as search, but returns fully populated items (slower). |
update |
Update an existing item. |
update_many |
Update multiple items, fetching current state in one batched call. |
delete |
Delete an item by its ID. |
reactivate |
Reactivate a deleted item by its ID. |
merge |
Merge duplicate item(s) into a single parent item. |
exists |
Check whether an item with the same name and company already exists. |
get_match_or_none |
Return the existing item matching name + company, or None. |
add_specs |
Attach inventory reference specs to an item (deprecated; prefer client.attributes). |
get_specs |
Get inventory reference specs for items (deprecated; prefer client.attributes). |
get_all_facets |
Get facet groups (aggregated filter counts) for a query. |
get_facet_by_name |
Get a single named facet group for a query. |
get_instructions |
Get a formula's batch instruction steps, filtered to one formula or one author. |
get_instruction_by_id |
Get a single instruction by its ID. |
get_instructions_by_parent_ids |
Get the instructions of several formulas in one call. |
create_instruction |
Add a batch instruction step to a formula. |
update_instruction |
Update an existing instruction's text. |
delete_instruction |
Delete an instruction from a formula. |
update_instruction_row_sequence |
Reorder the instructions within one row of a formula. |
copy_instructions |
Copy a formula's instructions and their order to other formulas. |
get_instruction_layout |
Get a formula's batch instruction procedure: ingredients, stages, and readings. |
get_instruction_sequence |
Get the row order of a formula's procedure. |
update_instruction_sequence |
Move a parameter group row to a new position in the row order. |
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
AlbertSession
|
The authenticated Albert session used for API calls. |
required |
Source code in src/albert/collections/inventory.py
merge
merge(
*,
parent_id: InventoryId,
child_id: InventoryId | list[InventoryId],
modules: list[InventoryMergeModule] | None = None,
) -> None
Merge one or more duplicate inventory items into a single parent item.
Use this to consolidate duplicates: the child item(s) are folded into the
parent, and their data (as selected by modules) is carried over. The
child items are removed as standalone entries.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parent_id
|
InventoryId
|
The item to keep. All merged data ends up here. |
required |
child_id
|
InventoryId or list[InventoryId]
|
The duplicate item(s) to merge into the parent. At least one is required. |
required |
modules
|
list[InventoryMergeModule]
|
Which categories of data to carry over from the children (e.g. pricing, notes). Defaults to all modules. |
None
|
Returns:
| Type | Description |
|---|---|
None
|
|
Source code in src/albert/collections/inventory.py
exists
exists(*, inventory_item: InventoryItem) -> bool
Check whether a matching inventory item already exists.
A match is determined by name and company, the same way create
detects duplicates. Useful before creating an item to avoid duplicates.
Example
from albert.resources.inventory import InventoryItem, InventoryCategory
from albert.resources.companies import Company
candidate = InventoryItem(
name="Acetone",
category=InventoryCategory.RAW_MATERIALS,
company=Company(name="Acme Chemicals"),
)
client.inventory.exists(inventory_item=candidate)
# True
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
inventory_item
|
InventoryItem
|
The item to look for. Its |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if a matching item exists, False otherwise. |
Source code in src/albert/collections/inventory.py
get_match_or_none
get_match_or_none(
*, inventory_item: InventoryItem
) -> InventoryItem | None
Return the existing item matching name and company, or None.
Like exists, but returns the matched item itself so you can reuse
its ID instead of creating a duplicate.
Example
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
inventory_item
|
InventoryItem
|
The item to match. Its |
required |
Returns:
| Type | Description |
|---|---|
InventoryItem or None
|
The matching item, or None if no match is found. |
Source code in src/albert/collections/inventory.py
create
create(
*,
inventory_item: InventoryItem,
avoid_duplicates: bool = True,
) -> InventoryItem
Create a new inventory item.
Use this to add a raw material, consumable, equipment, or formula item to
the catalog. A Formula item (category="Formulas") represents a mixture
designed in a Project and requires project_id set to that Project's ID.
Any tags or company on the item that do not yet exist in Albert are
created automatically before the item is registered (see
CompanyCollection and
TagCollection).
Example
from albert.resources.inventory import InventoryItem, InventoryCategory
from albert.resources.companies import Company
item = InventoryItem(
name="Titanium Dioxide",
category=InventoryCategory.RAW_MATERIALS,
company=Company(name="Acme Chemicals"),
)
created = client.inventory.create(inventory_item=item)
created.id
# 'INVA9999999'
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
inventory_item
|
InventoryItem
|
The item to create. |
required |
avoid_duplicates
|
bool
|
When True (default), if an item with the same name and company already exists, that existing item is returned instead of creating a duplicate. Set to False to force creation. Not applied to Formula items, which are always created as a new item under their Project. |
True
|
Returns:
| Type | Description |
|---|---|
InventoryItem
|
The newly created item, populated with its assigned Inventory ID. |
Source code in src/albert/collections/inventory.py
create_many
create_many(
*, inventory_items: list[InventoryItem]
) -> list[InventoryItem]
Create multiple inventory items.
Supports raw material, consumable, and equipment items. Formula and
Reaction items are not supported and fail per item; create them one at a
time with create.
Any tags or companies on the items that do not yet exist in Albert are
created automatically, matched once across the whole list rather than
once per item.
Example
from albert.resources.companies import Company
from albert.resources.inventory import InventoryCategory, InventoryItem
items = [
InventoryItem(
name="Titanium Dioxide",
category=InventoryCategory.RAW_MATERIALS,
company=Company(name="Acme Chemicals"),
),
InventoryItem(
name="Nitrile Gloves",
category=InventoryCategory.CONSUMABLES,
company=Company(name="Acme Chemicals"),
),
]
created = client.inventory.create_many(inventory_items=items)
[item.id for item in created]
# ['INVA9999999', 'INVC9999998']
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
inventory_items
|
list[InventoryItem]
|
The items to create. Volume items ( |
required |
Returns:
| Type | Description |
|---|---|
list[InventoryItem]
|
The created items, fully populated, in the order requested. |
Raises:
| Type | Description |
|---|---|
AlbertPartialError
|
If one or more items could not be created. The error carries the
succeeded ( |
Notes
Large input lists are supported. Already-created items are not rolled back when other items fail. A call that times out may still have created items, so do not blindly resend a timed-out load; reconcile which items exist first, then resend only the missing ones.
Source code in src/albert/collections/inventory.py
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 | |
get_by_id
get_by_id(*, id: InventoryId) -> InventoryItem
Get a single, fully populated inventory item by its ID.
A formula's batch instructions are not included; read them with
get_instruction_layout
(procedure table) and
get_instructions
(instruction steps).
For retrieving many items at once, use get_by_ids. To find items
without knowing their IDs, use search or get_all.
Only this method includes a formula's stored calculated property values
(calculated_properties).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
InventoryId
|
The Inventory ID (format |
required |
Returns:
| Type | Description |
|---|---|
InventoryItem
|
The fully populated item. |
Source code in src/albert/collections/inventory.py
get_by_ids
get_by_ids(
*, ids: list[InventoryId]
) -> list[InventoryItem]
Get multiple fully populated inventory items by their IDs.
Arbitrarily long ID lists are supported. Items not found are omitted from the result, and a warning lists the IDs that were skipped.
Example
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ids
|
list[InventoryId]
|
The Inventory IDs to retrieve (format |
required |
Returns:
| Type | Description |
|---|---|
list[InventoryItem]
|
The matching items. Order is not guaranteed to match the input. |
Source code in src/albert/collections/inventory.py
get_specs
get_specs(
*, ids: list[InventoryId]
) -> list[InventorySpecList]
Get the legacy inventory reference specs attached to inventory items.
Each InventorySpecList
holds that item's declared reference properties (definition and value
together). This is not Property Data: for measured task results or
custom property-data values, use
PropertyDataCollection.
Requests are automatically batched.
Deprecated
Prefer
get_by_parent_ids
(client.attributes). Specs are removed in SDK 2.0. See the Specs →
Attributes migration guide.
Example
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ids
|
list[InventoryId]
|
The Inventory IDs to fetch specs for (format |
required |
Returns:
| Type | Description |
|---|---|
list[InventorySpecList]
|
One entry per item, each holding that item's specs. |
Source code in src/albert/collections/inventory.py
add_specs
add_specs(
*,
inventory_id: InventoryId,
specs: InventorySpec | list[InventorySpec],
) -> InventorySpecList
Attach legacy inventory reference specs to an inventory item.
Each InventorySpec both
defines a property (name, data_column_id) and assigns its expected
InventorySpecValue on
this item. Use Specs for inventory reference properties (e.g. a
supplier-stated density that worksheets look up). For experimentally
measured results, use Tasks and
PropertyDataCollection
instead. A spec may optionally name conditions via a workflow.
Deprecated
Prefer
add_values
(client.attributes) after creating shared attribute definitions.
Specs are removed in SDK 2.0. See the Specs → Attributes migration guide.
Warning
This call replaces the item's complete spec set; it is not an
append. Always pass every spec the item should carry in one call: a
follow-up call with a subset can drop previously attached specs. A
500 Duplicate reference name error means spec rows with those
names already exist on the item (even when get_specs shows
none); do not blindly retry, call get_specs first and
reconcile. There is no Specs API to remove individual values.
Example
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
inventory_id
|
InventoryId
|
The item to attach the specs to (format |
required |
specs
|
InventorySpec or list[InventorySpec]
|
The full set of reference specs the item should carry. Each embeds the property definition and value (and optionally workflow conditions). |
required |
Returns:
| Type | Description |
|---|---|
InventorySpecList
|
The full set of specs now attached to the item. |
Source code in src/albert/collections/inventory.py
delete
delete(*, id: InventoryId) -> None
Delete an inventory item by its ID.
This permanently removes the item. To consolidate duplicates while
preserving data, use merge instead.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
InventoryId
|
The Inventory ID to delete (format |
required |
Returns:
| Type | Description |
|---|---|
None
|
|
Source code in src/albert/collections/inventory.py
reactivate
reactivate(*, id: InventoryId) -> InventoryItem
Reactivate a deleted inventory item by its ID.
Restores an item previously deleted with
delete, including
a duplicate removed by
merge. The item's
lots are restored with it. Data already carried over to the merge parent
stays on the parent.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
InventoryId
|
The Inventory ID to reactivate (format |
required |
Returns:
| Type | Description |
|---|---|
InventoryItem
|
The fully populated reactivated InventoryItem. |
Source code in src/albert/collections/inventory.py
get_all_facets
get_all_facets(
*,
text: str | None = None,
cas: list[Cas] | Cas | None = None,
category: list[InventoryCategory]
| InventoryCategory
| None = None,
company: list[Company] | Company | None = None,
location: list[Location] | Location | None = None,
storage_location: list[
StorageLocation | StorageLocationFilter
]
| StorageLocation
| StorageLocationFilter
| None = None,
project_id: ProjectId | None = None,
sheet_id: WorksheetId | None = None,
created_by: list[User]
| User
| str
| list[str]
| None = None,
lot_owner: list[User] | User | None = None,
tags: list[str] | None = None,
match_all_conditions: bool = False,
) -> list[FacetItem]
Get the facets available for an inventory search.
Facets are the grouped, counted filter options for a query, like the
refinement sidebar of a search UI (e.g. how many matching items fall under
each category, company, or tag). Use them to build progressive filtering
or to summarize a result set without fetching every item. To pull a single
named facet, use get_facet_by_name.
Example
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
Free-text query matched against item name and related fields. |
None
|
cas
|
Cas or list[Cas]
|
Filter by CAS number(s). |
None
|
category
|
InventoryCategory or list[InventoryCategory]
|
Filter by category: |
None
|
company
|
Company or list[Company]
|
Filter by manufacturing Company. |
None
|
location
|
Location or list[Location]
|
Filter by location. |
None
|
storage_location
|
StorageLocation or StorageLocationFilter or list[StorageLocation | StorageLocationFilter]
|
Filter by storage location. |
None
|
project_id
|
ProjectId
|
Filter by project. |
None
|
sheet_id
|
WorksheetId
|
Filter by worksheet. |
None
|
created_by
|
User, list[User], str, or list[str]
|
Filter by creator. Accepts user display name(s) or UserId(s) (e.g.
|
None
|
lot_owner
|
User or list[User]
|
Filter by lot owner. |
None
|
tags
|
list[str]
|
Filter by tag name(s). |
None
|
match_all_conditions
|
bool
|
If True, only count items that satisfy every applied filter (AND logic). Default False. |
False
|
Returns:
| Type | Description |
|---|---|
list[FacetItem]
|
The facet groups available for the query. |
Source code in src/albert/collections/inventory.py
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 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 | |
get_facet_by_name
get_facet_by_name(
name: str | list[str],
*,
text: str | None = None,
cas: list[Cas] | Cas | None = None,
category: list[InventoryCategory]
| InventoryCategory
| None = None,
company: list[Company] | Company | None = None,
location: list[Location] | Location | None = None,
storage_location: list[
StorageLocation | StorageLocationFilter
]
| StorageLocation
| StorageLocationFilter
| None = None,
project_id: ProjectId | None = None,
sheet_id: WorksheetId | None = None,
created_by: list[User]
| User
| str
| list[str]
| None = None,
lot_owner: list[User] | User | None = None,
tags: list[str] | None = None,
match_all_conditions: bool = False,
) -> list[FacetItem]
Return one or more named facets for an inventory search.
A convenience wrapper over get_all_facets that keeps only the
facet group(s) you name. Useful for iterative search refinement, e.g.
fetching the remaining Tags facet after other filters are applied.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str or list[str]
|
The facet group name(s) to return (e.g. |
required |
text
|
str
|
Search text for full-text matching. |
None
|
cas
|
list[Cas] | Cas | None
|
Filter by CAS values. |
None
|
category
|
list[InventoryCategory] | InventoryCategory | None
|
Filter by inventory category. |
None
|
company
|
list[Company] | Company | None
|
Filter by company. |
None
|
location
|
list[Location] | Location | None
|
Filter by location. |
None
|
storage_location
|
list[StorageLocation | StorageLocationFilter] | StorageLocation | StorageLocationFilter | None
|
Filter by storage location. |
None
|
project_id
|
ProjectId | None
|
Filter by project. |
None
|
sheet_id
|
WorksheetId | None
|
Filter by worksheet. |
None
|
created_by
|
User, list[User], str, or list[str]
|
Filter by creator. Accepts user display name(s) or UserId(s) (e.g.
|
None
|
lot_owner
|
list[User] | User | None
|
Filter by lot owner. |
None
|
tags
|
list[str] | None
|
Filter by tags. |
None
|
match_all_conditions
|
bool
|
If True, only count items that satisfy every applied filter (AND logic). Default False. |
False
|
Returns:
| Type | Description |
|---|---|
list[FacetItem]
|
The facet group(s) matching |
Source code in src/albert/collections/inventory.py
1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 | |
search
search(
*,
text: str | None = None,
cas: list[Cas] | Cas | None = None,
category: list[InventoryCategory]
| InventoryCategory
| None = None,
company: list[Company] | Company | None = None,
location: list[Location] | Location | None = None,
storage_location: list[
StorageLocation | StorageLocationFilter
]
| StorageLocation
| StorageLocationFilter
| None = None,
project_id: ProjectId | None = None,
sheet_id: WorksheetId | None = None,
created_by: list[User]
| User
| str
| list[str]
| None = None,
lot_owner: list[User] | User | None = None,
tags: list[str] | None = None,
match_all_conditions: bool = False,
order: OrderBy = DESCENDING,
sort_by: str | None = None,
max_items: int | None = None,
offset: int | None = 0,
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,
albert_id: str | list[str] | None = None,
attribute_id: str | list[str] | None = None,
cas_smile: str | list[str] | None = None,
collaborator_pop_up: bool | None = None,
contains_field: str | list[str] | None = None,
contains_text: str | list[str] | None = None,
created_by_id: str | list[str] | None = None,
details: bool | None = None,
drop_down_text: str | None = None,
drop_down_text_prop: str | None = None,
dup_detection: bool | None = None,
facet_field: str | None = None,
facet_text: str | None = None,
from_expiration_date: str | None = None,
from_lot_created_at: str | None = None,
from_on_hand: str | None = None,
gslo_group: str | list[str] | None = None,
idh: str | list[str] | None = None,
is_pop_up: bool | None = None,
lot_created_by: list[User]
| User
| str
| list[str]
| None = None,
material_category: str | list[str] | None = None,
pack_size: str | list[str] | None = None,
pictogram_name: str | list[str] | None = None,
result: str | list[str] | None = None,
rsn: str | list[str] | None = None,
source_field: str | list[str] | None = None,
status: str | list[str] | None = None,
sub_category: str | list[str] | None = None,
synthesis_product_created: str
| list[str]
| None = None,
to_expiration_date: str | None = None,
to_lot_created_at: str | None = None,
to_on_hand: str | None = None,
metadata_filters: dict[str, Any] | None = None,
custom_fields: dict[str, Any] | None = None,
additional_field: str | list[str] | None = None,
project_facets: dict[str, Any] | None = None,
composite_search: dict[str, Any] | None = None,
) -> Iterator[InventorySearchItem]
Search for inventory items matching the given filters.
Returns lightweight, partially populated results and is the fastest way to
look items up (best for name lookups, counts, or feeding IDs into another
call). Fields such as full CAS breakdowns and metadata are omitted; when
you need complete items, use get_all with the same filters, or pass
the resulting IDs to get_by_ids.
Filters are combined with OR logic by default (an item matches if it
satisfies any filter); set match_all_conditions=True to require every
filter to match. Results are returned as a lazily paginated iterator, so
iterating fetches additional pages on demand.
Example
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
Free-text query matched against item name, alias, and related fields. Only the first 50 characters are used. |
None
|
cas
|
Cas or list[Cas]
|
Filter by CAS number(s). |
None
|
category
|
InventoryCategory or list[InventoryCategory]
|
Filter by category: |
None
|
company
|
Company or list[Company]
|
Filter by manufacturing Company. |
None
|
location
|
Location or list[Location]
|
Filter by location. |
None
|
storage_location
|
StorageLocation or StorageLocationFilter or list[StorageLocation | StorageLocationFilter]
|
Filter by storage location. |
None
|
project_id
|
str
|
Filter by the project a formula belongs to (Formula items only). |
None
|
sheet_id
|
str
|
Filter by worksheet ID. |
None
|
created_by
|
User, list[User], str, or list[str]
|
Filter by creator. Accepts user display name(s) or UserId(s) (e.g.
|
None
|
lot_owner
|
User or list[User]
|
Filter by lot owner(s). |
None
|
tags
|
list[str]
|
Filter by tag name(s). |
None
|
match_all_conditions
|
bool
|
Require every filter to match (AND logic). Default False (OR logic). |
False
|
order
|
OrderBy
|
Sort direction. Default |
DESCENDING
|
sort_by
|
str
|
Field to sort by. Default None (server default order). |
None
|
max_items
|
int
|
Maximum number of items to return in total. If None, iterates over all matches. |
None
|
from_created_at
|
str
|
Only include items created on or after this date, formatted as
|
None
|
to_created_at
|
str
|
Only include items created on or before this date, formatted as
|
None
|
updated_by
|
str or list[str]
|
Filter by user(s) who last updated the item. 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
|
metadata_filters
|
dict[str, Any]
|
Filter by custom field (metadata) values. Keys are custom field names.
For string-type custom fields, map the name to a list of values, e.g.
|
None
|
albert_id
|
str or list[str]
|
Filter by Albert ID(s). |
None
|
attribute_id
|
str or list[str]
|
Filter by attribute ID(s). Cannot be combined with |
None
|
cas_smile
|
str or list[str]
|
Filter by CAS SMILES string(s). |
None
|
collaborator_pop_up
|
bool
|
Apply collaborator popup search behavior. |
None
|
contains_field
|
str or list[str]
|
Field(s) for contains-style filtering. |
None
|
contains_text
|
str or list[str]
|
Text value(s) paired with |
None
|
created_by_id
|
str or list[str]
|
Filter by creator UserId(s). |
None
|
details
|
bool
|
Invoke custom logic for the worksheet details view. |
None
|
drop_down_text
|
str
|
Dropdown search text. |
None
|
drop_down_text_prop
|
str
|
Dropdown search property name. |
None
|
dup_detection
|
bool
|
Enable duplicate-detection text sanitization. |
None
|
facet_field
|
str
|
Facet field to filter on. |
None
|
facet_text
|
str
|
Facet text to match. |
None
|
from_expiration_date
|
str
|
Only include lots expiring on or after this date ( |
None
|
from_lot_created_at
|
str
|
Only include lots created on or after this date ( |
None
|
from_on_hand
|
str
|
Minimum on-hand quantity filter. |
None
|
gslo_group
|
str or list[str]
|
Filter by GSLO group(s). |
None
|
idh
|
str or list[str]
|
Filter by IDH value(s). |
None
|
is_pop_up
|
bool
|
Apply popup search behavior. |
None
|
lot_created_by
|
User, list[User], str, or list[str]
|
Filter by lot creator. Accepts display name(s), UserId(s), or
|
None
|
material_category
|
str or list[str]
|
Filter by material category. |
None
|
pack_size
|
str or list[str]
|
Filter by pack size. |
None
|
pictogram_name
|
str or list[str]
|
Filter by pictogram name(s). |
None
|
result
|
str or list[str]
|
Filter by result value(s). |
None
|
rsn
|
str or list[str]
|
Filter by RSN value(s). |
None
|
source_field
|
str or list[str]
|
Restrict which fields are returned in search results. |
None
|
status
|
str or list[str]
|
Filter by status value(s). |
None
|
sub_category
|
str or list[str]
|
Filter by sub-category. |
None
|
synthesis_product_created
|
str or list[str]
|
Filter by synthesis product creation value(s). |
None
|
to_expiration_date
|
str
|
Only include lots expiring on or before this date ( |
None
|
to_lot_created_at
|
str
|
Only include lots created on or before this date ( |
None
|
to_on_hand
|
str
|
Maximum on-hand quantity filter. |
None
|
custom_fields
|
dict[str, Any]
|
Filter by custom field values. |
None
|
additional_field
|
str or list[str]
|
Request additional columns from the search index. |
None
|
project_facets
|
dict[str, Any]
|
Project facet filters. |
None
|
composite_search
|
dict[str, Any]
|
Composite search specification. |
None
|
Returns:
| Type | Description |
|---|---|
Iterator[InventorySearchItem]
|
A lazily paginated iterator of partially populated search results. |
Source code in src/albert/collections/inventory.py
1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 | |
get_all
get_all(
*,
text: str | None = None,
cas: list[Cas] | Cas | None = None,
category: list[InventoryCategory]
| InventoryCategory
| None = None,
company: list[Company] | Company | None = None,
location: list[Location] | Location | None = None,
storage_location: list[
StorageLocation | StorageLocationFilter
]
| StorageLocation
| StorageLocationFilter
| None = None,
project_id: ProjectId | None = None,
sheet_id: WorksheetId | None = None,
created_by: list[User]
| User
| str
| list[str]
| None = None,
lot_owner: list[User] | User | None = None,
tags: list[str] | None = None,
match_all_conditions: bool = False,
order: OrderBy = DESCENDING,
sort_by: str | None = None,
max_items: int | None = None,
offset: int | None = 0,
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,
albert_id: str | list[str] | None = None,
attribute_id: str | list[str] | None = None,
cas_smile: str | list[str] | None = None,
collaborator_pop_up: bool | None = None,
contains_field: str | list[str] | None = None,
contains_text: str | list[str] | None = None,
created_by_id: str | list[str] | None = None,
details: bool | None = None,
drop_down_text: str | None = None,
drop_down_text_prop: str | None = None,
dup_detection: bool | None = None,
facet_field: str | None = None,
facet_text: str | None = None,
from_expiration_date: str | None = None,
from_lot_created_at: str | None = None,
from_on_hand: str | None = None,
gslo_group: str | list[str] | None = None,
idh: str | list[str] | None = None,
is_pop_up: bool | None = None,
lot_created_by: list[User]
| User
| str
| list[str]
| None = None,
material_category: str | list[str] | None = None,
pack_size: str | list[str] | None = None,
pictogram_name: str | list[str] | None = None,
result: str | list[str] | None = None,
rsn: str | list[str] | None = None,
source_field: str | list[str] | None = None,
status: str | list[str] | None = None,
sub_category: str | list[str] | None = None,
synthesis_product_created: str
| list[str]
| None = None,
to_expiration_date: str | None = None,
to_lot_created_at: str | None = None,
to_on_hand: str | None = None,
metadata_filters: dict[str, Any] | None = None,
custom_fields: dict[str, Any] | None = None,
additional_field: str | list[str] | None = None,
project_facets: dict[str, Any] | None = None,
composite_search: dict[str, Any] | None = None,
) -> Iterator[InventoryItem]
Get fully populated inventory items matching the given filters.
Accepts the same filters as search but returns complete
InventoryItem entities 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 counts.
Filters are combined with OR logic by default; set
match_all_conditions=True to require every filter to match. Results are
returned as a lazily paginated iterator.
Example
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
Free-text query matched against item name, alias, and related fields. Only the first 50 characters are used. |
None
|
cas
|
Cas or list[Cas]
|
Filter by CAS number(s). |
None
|
category
|
InventoryCategory or list[InventoryCategory]
|
Filter by category: |
None
|
company
|
Company or list[Company]
|
Filter by manufacturing Company. |
None
|
location
|
Location or list[Location]
|
Filter by location. |
None
|
storage_location
|
StorageLocation or StorageLocationFilter or list[StorageLocation | StorageLocationFilter]
|
Filter by storage location. |
None
|
project_id
|
str
|
Filter by the project a formula belongs to (Formula items only). |
None
|
sheet_id
|
str
|
Filter by worksheet ID. |
None
|
created_by
|
User, list[User], str, or list[str]
|
Filter by creator. Accepts user display name(s) or UserId(s) (e.g.
|
None
|
lot_owner
|
User or list[User]
|
Filter by lot owner(s). |
None
|
tags
|
list[str]
|
Filter by tag name(s). |
None
|
match_all_conditions
|
bool
|
Require every filter to match (AND logic). Default False (OR logic). |
False
|
order
|
OrderBy
|
Sort direction. Default |
DESCENDING
|
sort_by
|
str
|
Field to sort by. Default None (server default order). |
None
|
max_items
|
int
|
Maximum number of items to return in total. If None, iterates over all matches. |
None
|
from_created_at
|
str
|
Only include items created on or after this date, formatted as
|
None
|
to_created_at
|
str
|
Only include items created on or before this date, formatted as
|
None
|
updated_by
|
str or list[str]
|
Filter by user(s) who last updated the item. 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
|
metadata_filters
|
dict[str, Any]
|
Filter by custom field (metadata) values. Keys are custom field names.
For string-type custom fields, map the name to a list of values, e.g.
|
None
|
albert_id
|
str or list[str]
|
Filter by Albert ID(s). |
None
|
attribute_id
|
str or list[str]
|
Filter by attribute ID(s). Cannot be combined with |
None
|
cas_smile
|
str or list[str]
|
Filter by CAS SMILES string(s). |
None
|
collaborator_pop_up
|
bool
|
Apply collaborator popup search behavior. |
None
|
contains_field
|
str or list[str]
|
Field(s) for contains-style filtering. |
None
|
contains_text
|
str or list[str]
|
Text value(s) paired with |
None
|
created_by_id
|
str or list[str]
|
Filter by creator UserId(s). |
None
|
details
|
bool
|
Invoke custom logic for the worksheet details view. |
None
|
drop_down_text
|
str
|
Dropdown search text. |
None
|
drop_down_text_prop
|
str
|
Dropdown search property name. |
None
|
dup_detection
|
bool
|
Enable duplicate-detection text sanitization. |
None
|
facet_field
|
str
|
Facet field to filter on. |
None
|
facet_text
|
str
|
Facet text to match. |
None
|
from_expiration_date
|
str
|
Only include lots expiring on or after this date ( |
None
|
from_lot_created_at
|
str
|
Only include lots created on or after this date ( |
None
|
from_on_hand
|
str
|
Minimum on-hand quantity filter. |
None
|
gslo_group
|
str or list[str]
|
Filter by GSLO group(s). |
None
|
idh
|
str or list[str]
|
Filter by IDH value(s). |
None
|
is_pop_up
|
bool
|
Apply popup search behavior. |
None
|
lot_created_by
|
User, list[User], str, or list[str]
|
Filter by lot creator. Accepts display name(s), UserId(s), or
|
None
|
material_category
|
str or list[str]
|
Filter by material category. |
None
|
pack_size
|
str or list[str]
|
Filter by pack size. |
None
|
pictogram_name
|
str or list[str]
|
Filter by pictogram name(s). |
None
|
result
|
str or list[str]
|
Filter by result value(s). |
None
|
rsn
|
str or list[str]
|
Filter by RSN value(s). |
None
|
source_field
|
str or list[str]
|
Restrict which fields are returned in search results. |
None
|
status
|
str or list[str]
|
Filter by status value(s). |
None
|
sub_category
|
str or list[str]
|
Filter by sub-category. |
None
|
synthesis_product_created
|
str or list[str]
|
Filter by synthesis product creation value(s). |
None
|
to_expiration_date
|
str
|
Only include lots expiring on or before this date ( |
None
|
to_lot_created_at
|
str
|
Only include lots created on or before this date ( |
None
|
to_on_hand
|
str
|
Maximum on-hand quantity filter. |
None
|
custom_fields
|
dict[str, Any]
|
Filter by custom field values. |
None
|
additional_field
|
str or list[str]
|
Request additional columns from the search index. |
None
|
project_facets
|
dict[str, Any]
|
Project facet filters. |
None
|
composite_search
|
dict[str, Any]
|
Composite search specification. |
None
|
Returns:
| Type | Description |
|---|---|
Iterator[InventoryItem]
|
A lazily paginated iterator of fully populated items. |
Source code in src/albert/collections/inventory.py
1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 | |
update
update(*, inventory_item: InventoryItem) -> InventoryItem
Update an existing inventory item.
Fetch the item (e.g. with get_by_id), modify the updatable fields
on the returned object, then pass it here. Only the fields listed in Notes
are applied; changes to other fields are ignored, and a change to
symbols also emits a warning.
Example
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
inventory_item
|
InventoryItem
|
The item to update. Must have a valid |
required |
Returns:
| Type | Description |
|---|---|
InventoryItem
|
The updated item. |
Raises:
| Type | Description |
|---|---|
AlbertPartialError
|
If a tag or company change only partially succeeds. The error carries
the succeeded ( |
Warns:
| Type | Description |
|---|---|
UserWarning
|
If |
Notes
The following fields can be updated: acls, alias, company,
description, is_formula_override, metadata, name,
security_class, tags, unit_category.
Note that unit_category cannot be changed to or from volume,
and density is fixed at creation.
On individual CAS entries (via cas): min, max, target,
cas_category, inventory_function.
substance_id can be set when adding a new CAS entry; it is not
patchable on existing entries.
Any tags that do not yet exist in Albert are created automatically.
Source code in src/albert/collections/inventory.py
1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 | |
update_many
update_many(
*, inventory_items: list[InventoryItem]
) -> list[InventoryItem]
Update multiple inventory items.
Same per-item semantics as update,
but the current state of all items is fetched up front in batched calls
and the updated items are re-fetched the same way, so updating N items
avoids N individual read round-trips.
Example
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
inventory_items
|
list[InventoryItem]
|
The items to update. Each must have a valid |
required |
Returns:
| Type | Description |
|---|---|
list[InventoryItem]
|
The updated items. Order is not guaranteed to match the input list. |
Raises:
| Type | Description |
|---|---|
AlbertPartialError
|
If a batched tag or company change only partially succeeds. The error
carries the succeeded ( |
Warns:
| Type | Description |
|---|---|
UserWarning
|
If |
Notes
The same fields can be updated as with
update.
Tag and company changes are applied together in batches of up to 300
items; all other changes are applied per item. If an error occurs
mid-batch, earlier updates are not rolled back.
Source code in src/albert/collections/inventory.py
2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 | |
get_instructions
get_instructions(
*,
parent_id: InventoryId | None = None,
created_by: str | None = None,
updated_by: str | None = None,
max_items: int | None = None,
) -> Iterator[Instruction]
Get a formula's batch instruction steps, filtered to one formula or one author.
Exactly one filter must be provided: a formula (parent_id), a creator
(created_by), or a last editor (updated_by). Results are returned
as a lazily paginated iterator; when filtering by formula, instructions
come back in display order (formula-level instructions first, then each
ingredient row's).
Example
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parent_id
|
InventoryId
|
Only instructions belonging to this formula (format |
None
|
created_by
|
str
|
Only instructions created by this user ID. |
None
|
updated_by
|
str
|
Only instructions last edited by this user ID. |
None
|
max_items
|
int
|
Maximum number of items to return in total. If None, iterates over all matches. |
None
|
Returns:
| Type | Description |
|---|---|
Iterator[Instruction]
|
A lazily paginated iterator of matching instructions. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If zero or more than one of the filters is provided. |
Source code in src/albert/collections/inventory.py
get_instruction_by_id
get_instruction_by_id(
*, parent_id: InventoryId, id: str
) -> Instruction
Get a single instruction by its ID.
Example
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parent_id
|
InventoryId
|
The ID of the formula the instruction belongs to (format |
required |
id
|
str
|
The ID of the instruction to retrieve (format |
required |
Returns:
| Type | Description |
|---|---|
Instruction
|
The fully populated instruction. |
Source code in src/albert/collections/inventory.py
get_instructions_by_parent_ids
get_instructions_by_parent_ids(
*, parent_ids: list[InventoryId]
) -> list[InstructionSet]
Get the instructions of several formulas in one call.
Each formula comes back with its instructions in display order and the per-row ordering of those instructions. Formulas without instructions yet are returned empty. At most 15 formulas can be fetched per call.
Example
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parent_ids
|
list[InventoryId]
|
The IDs of the formulas to fetch instructions for (format |
required |
Returns:
| Type | Description |
|---|---|
list[InstructionSet]
|
One entry per requested formula, with its instructions and ordering. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If more than 15 formula IDs are provided. |
Source code in src/albert/collections/inventory.py
create_instruction
create_instruction(
*, instruction: Instruction
) -> Instruction
Add a batch instruction step (e.g. "Take the pH of the batch") to a formula.
The instruction's parent_id selects the formula and is required.
A new instruction is appended at the end of its order by default (its
row's, or the formula-level one); reorder with
update_instruction_row_sequence.
Example
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
instruction
|
Instruction
|
The instruction to create. Requires |
required |
Returns:
| Type | Description |
|---|---|
Instruction
|
The created instruction, populated with its assigned ID. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the instruction has no |
Source code in src/albert/collections/inventory.py
update_instruction
update_instruction(
*, instruction: Instruction
) -> Instruction
Update an instruction's text.
Fetch an instruction (e.g. via get_instruction_by_id),
modify its name, then pass it here. The instruction is matched by its
id and parent_id. If nothing changed, the existing instruction is
returned unmodified.
Example
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
instruction
|
Instruction
|
The instruction with updated fields. Must include |
required |
Returns:
| Type | Description |
|---|---|
Instruction
|
The updated instruction. |
Notes
The following fields can be updated: name. Renames that change only
letter casing are rejected. An unset name (never assigned on the
model) is left unchanged rather than cleared.
Source code in src/albert/collections/inventory.py
delete_instruction
delete_instruction(
*, parent_id: InventoryId, id: str
) -> None
Delete an instruction from a formula.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parent_id
|
InventoryId
|
The ID of the formula the instruction belongs to (format |
required |
id
|
str
|
The ID of the instruction to delete (format |
required |
Returns:
| Type | Description |
|---|---|
None
|
|
Source code in src/albert/collections/inventory.py
update_instruction_row_sequence
update_instruction_row_sequence(
*,
parent_id: InventoryId,
instruction_ids: list[str],
design_row_id: str | None = None,
) -> InstructionSet
Reorder the instructions within one row of a formula.
Instructions are ordered independently inside each row they are pinned
to, with one extra order for the formula-level (unpinned) instructions.
Pass the row's full set of instruction IDs in the desired order; omit
design_row_id to reorder the formula-level instructions. This does
not change the order of the rows themselves (see
update_instruction_sequence).
Example
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parent_id
|
InventoryId
|
The ID of the formula whose instructions are reordered (format
|
required |
instruction_ids
|
list[str]
|
The IDs of the row's instructions in the desired order (format
|
required |
design_row_id
|
str
|
The unique ID of the ingredient row whose instructions are reordered
(format |
None
|
Returns:
| Type | Description |
|---|---|
InstructionSet
|
The formula's instructions with their updated ordering. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in src/albert/collections/inventory.py
2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 | |
copy_instructions
copy_instructions(
*, source_id: InventoryId, target_ids: list[InventoryId]
) -> InstructionCopyResult
Copy a formula's instructions and their order to other formulas.
Every instruction of the source formula is recreated on each target formula with a fresh ID, keeping the same row pins and order. Formulas that already have instructions are skipped, not overwritten.
Example
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source_id
|
InventoryId
|
The ID of the formula to copy instructions from (format |
required |
target_ids
|
list[InventoryId]
|
The IDs of the formulas to copy instructions to (format |
required |
Returns:
| Type | Description |
|---|---|
InstructionCopyResult
|
How many target formulas received the instructions and how many were skipped. |
Source code in src/albert/collections/inventory.py
get_instruction_layout
get_instruction_layout(
*, inventory_id: InventoryId
) -> InstructionLayout
Get a formula's batch instruction procedure: ingredients, stages, and readings.
Returns every row of the formula's procedure in display order:
ingredient rows, parameter groups (procedure stages), and parameter
rows, each with its values for the relevant Worksheet columns. To get
only the row order without the values, use
get_instruction_sequence.
See the albert.resources.instructions
models for how the overall order is determined.
Example
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
inventory_id
|
InventoryId
|
The ID of the formula inventory item (format |
required |
Returns:
| Type | Description |
|---|---|
InstructionLayout
|
The formula's procedure table, including the version of the row order. |
Source code in src/albert/collections/inventory.py
get_instruction_sequence
get_instruction_sequence(
*,
inventory_id: InventoryId,
exclude_hidden: bool = False,
) -> InstructionSequence
Get the row order of a formula's procedure.
Lists every row of the formula's procedure in display order, including
rows that have no values for the formula yet. If the order has never
been customized, it matches the Sheet the formula lives on; see the
albert.resources.instructions models
for how the order is determined. The returned version is required
when reordering rows with
update_instruction_sequence.
Example
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
inventory_id
|
InventoryId
|
The ID of the formula inventory item (format |
required |
exclude_hidden
|
bool
|
When True, omit rows that are currently hidden on the Worksheet. Default is False. |
False
|
Returns:
| Type | Description |
|---|---|
InstructionSequence
|
The formula's row order, including its |
Source code in src/albert/collections/inventory.py
update_instruction_sequence
update_instruction_sequence(
*,
inventory_id: InventoryId,
source_id: str,
reference_id: str,
position: SequencePosition,
version: int,
) -> InstructionSequence
Move a parameter group row to a new position in the row order.
Only parameter group rows (the stages of the procedure) can be
reordered; ingredient rows always follow the Sheet's Product Design. The
row identified by source_id is placed directly above or below the row
identified by reference_id, which can be an ingredient row or another
parameter group row.
Both IDs use the unique row format DES...#ROW..., which users rarely
know directly. Find them by matching display names in the formula's
procedure table, as in the example below; each row's row_unique_id
is the value to pass here.
The version guards against conflicting edits: it must match the row
order's current version, or the move is rejected and the row order
should be re-fetched before retrying. The updated row order (with its
new version) is returned, so consecutive moves can chain off each
result.
Example
from albert import Albert
from albert.resources.instructions import SequencePosition
client = Albert()
layout = client.inventory.get_instruction_layout(inventory_id="INV123")
ids_by_name = {row.name: row.row_unique_id for row in layout.rows}
sequence = client.inventory.get_instruction_sequence(inventory_id="INV123")
updated = client.inventory.update_instruction_sequence(
inventory_id="INV123",
source_id=ids_by_name["Heating"],
reference_id=ids_by_name["Premix"],
position=SequencePosition.BELOW,
version=sequence.version,
)
print(updated.version)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
inventory_id
|
InventoryId
|
The ID of the formula inventory item (format |
required |
source_id
|
str
|
The unique ID of the parameter group row to move (format |
required |
reference_id
|
str
|
The unique ID of the row to place the moved row next to (format
|
required |
position
|
SequencePosition
|
Whether to place the moved row |
required |
version
|
int
|
The row order's current version, as returned by
|
required |
Returns:
| Type | Description |
|---|---|
InstructionSequence
|
The updated row order, including its new |
Notes
Reordering is available only when it is enabled for the tenant; otherwise the call is rejected as not applicable.
Source code in src/albert/collections/inventory.py
2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 | |