Inventory
albert.collections.inventory.InventoryCollection
Bases: BaseCollection
InventoryCollection is a collection class for managing Inventory Item entities in the Albert platform.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
session
|
Albert
|
The Albert session instance. |
required |
Methods:
Name | Description |
---|---|
merge |
Merge one or multiple child inventory into a parent inventory item. |
inventory_exists |
Check if an inventory item exists. |
get_match_or_none |
Get a matching inventory item or return None if not found. |
create |
Create a new inventory item. |
get_by_id |
Retrieve an inventory item by its ID. |
get_by_ids |
Retrieve an set of inventory items by their IDs. |
get_specs |
Get the specs for a list of inventory items. |
add_specs |
Add inventory specs to the inventory item. |
delete |
Delete an inventory item by its ID. |
get_all_facets |
Get available facets for inventory items based on the provided filters. |
get_facet_by_name |
Returns a specific facet by its name with all the filters applied to the search. |
search |
Get a list of inventory items that match the search criteria and |
list |
List inventory items with optional filters. |
update |
Update an inventory item. |
Attributes:
Name | Type | Description |
---|---|---|
base_path |
|
Source code in src/albert/collections/inventory.py
merge
merge(
*,
parent_id: InventoryId,
child_id: InventoryId | list[InventoryId],
modules: list[str] | None = None,
) -> None
Merge one or multiple child inventory into a parent inventory item.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
parent_id
|
InventoryId
|
The ID of the parent inventory item. |
required |
child_id
|
InventoryId | list[InventoryId]
|
The ID(s) of the child inventory item(s). |
required |
modules
|
list[str]
|
The merge modules to use (default is all). |
None
|
Returns:
Type | Description |
---|---|
None
|
|
Source code in src/albert/collections/inventory.py
inventory_exists
inventory_exists(*, inventory_item: InventoryItem) -> bool
Check if an inventory item exists.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
inventory_item
|
InventoryItem
|
The inventory item to check. |
required |
Returns:
Type | Description |
---|---|
bool
|
True if the inventory 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
Get a matching inventory item or return None if not found.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
inventory_item
|
InventoryItem
|
The inventory item to match. |
required |
Returns:
Type | Description |
---|---|
Union[InventoryItem, None]
|
The matching inventory item or None if not found. |
Source code in src/albert/collections/inventory.py
create
create(
*,
inventory_item: InventoryItem,
avoid_duplicates: bool = True,
) -> InventoryItem
Create a new inventory item.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
inventory_item
|
InventoryItem
|
The inventory item to create. |
required |
avoid_duplicates
|
bool
|
Whether to avoid creating duplicate items (default is True). |
True
|
Returns:
Type | Description |
---|---|
InventoryItem
|
The created inventory item. |
Source code in src/albert/collections/inventory.py
get_by_id
get_by_id(*, id: InventoryId) -> InventoryItem
Retrieve an inventory item by its ID.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id
|
InventoryId
|
The ID of the inventory item. |
required |
Returns:
Type | Description |
---|---|
InventoryItem
|
The retrieved inventory item. |
Source code in src/albert/collections/inventory.py
get_by_ids
get_by_ids(
*, ids: list[InventoryId]
) -> list[InventoryItem]
Retrieve an set of inventory items by their IDs.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ids
|
list[InventoryId]
|
The list of IDs of the inventory items. |
required |
Returns:
Type | Description |
---|---|
list[InventoryItem]
|
The retrieved inventory items. |
Source code in src/albert/collections/inventory.py
get_specs
get_specs(
*, ids: list[InventoryId]
) -> list[InventorySpecList]
Get the specs for a list of inventory items.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ids
|
list[InventoryId]
|
List of Inventory IDs to get the specs for. |
required |
Returns:
Type | Description |
---|---|
list[InventorySpecList]
|
A list of InventorySpecList objects, each containing the specs for an inventory item. |
Source code in src/albert/collections/inventory.py
add_specs
add_specs(
*,
inventory_id: InventoryId,
specs: InventorySpec | list[InventorySpec],
) -> InventorySpecList
Add inventory specs to the inventory item.
An InventorySpec
is a property that was not directly measured via a task,
but is a generic property of that inentory item.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
inventory_id
|
InventoryId
|
The Albert ID of the inventory item to add the specs to |
required |
specs
|
list[InventorySpec]
|
List of InventorySpec objects to add to the inventory item, which described the value and, optionally, the conditions associated with the value (via workflow). |
required |
Returns:
Type | Description |
---|---|
InventorySpecList
|
The list of InventorySpecs attached to the InventoryItem. |
Source code in src/albert/collections/inventory.py
delete
delete(*, id: InventoryId) -> None
Delete an inventory item by its ID.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id
|
InventoryId
|
The ID of the inventory item. |
required |
Returns:
Type | Description |
---|---|
None
|
|
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]
| StorageLocation
| None = None,
project_id: ProjectId | None = None,
sheet_id: WorksheetId | None = None,
created_by: list[User] | User | None = None,
lot_owner: list[User] | User | None = None,
tags: list[str] | None = None,
match_all_conditions: bool = False,
) -> list[FacetItem]
Get available facets for inventory items based on the provided filters.
Source code in src/albert/collections/inventory.py
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]
| StorageLocation
| None = None,
project_id: ProjectId | None = None,
sheet_id: WorksheetId | None = None,
created_by: list[User] | User | None = None,
lot_owner: list[User] | User | None = None,
tags: list[str] | None = None,
match_all_conditions: bool = False,
) -> list[FacetItem]
Returns a specific facet by its name with all the filters applied to the search. This can be used for example to fetch all remaining tags as part of an iterative refinement of a search.
Source code in src/albert/collections/inventory.py
search
search(
*,
limit: int = 100,
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]
| StorageLocation
| None = None,
project_id: ProjectId | None = None,
sheet_id: WorksheetId | None = None,
created_by: list[User] | User | None = None,
lot_owner: list[User] | User | None = None,
tags: list[str] | None = None,
match_all_conditions: bool = False,
) -> Iterator[InventorySearchItem]
Get a list of inventory items that match the search criteria and return the raw search records. These are not full inventory item objects, but are special short documents intended for fast summary results
Source code in src/albert/collections/inventory.py
list
list(
*,
limit: int = 100,
text: str | None = None,
cas: list[Cas] | Cas | None = None,
category: list[InventoryCategory]
| InventoryCategory
| None = None,
company: list[Company] | Company | None = None,
order: OrderBy = DESCENDING,
sort_by: str | None = "createdAt",
location: list[Location] | Location | None = None,
storage_location: list[StorageLocation]
| StorageLocation
| None = None,
project_id: ProjectId | None = None,
sheet_id: WorksheetId | None = None,
created_by: list[User] | User | None = None,
lot_owner: list[User] | User | None = None,
tags: list[str] | None = None,
match_all_conditions: bool = False,
) -> Iterator[InventoryItem]
List inventory items with optional filters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
limit
|
int
|
Maximum number of items to return (default is 100) |
100
|
text
|
str
|
Text to search for in inventory names and descriptions |
None
|
cas
|
list[Cas] | Cas | None
|
Filter by CAS number(s) |
None
|
category
|
list[InventoryCategory] | InventoryCategory | None
|
Filter by inventory category/categories |
None
|
company
|
list[Company] | Company | None
|
Filter by manufacturing company/companies |
None
|
order
|
OrderBy
|
Sort order, either ASCENDING or DESCENDING (default is DESCENDING) |
DESCENDING
|
sort_by
|
str
|
Field to sort by (default is "createdAt") |
'createdAt'
|
location
|
list[Location] | None
|
Filter by location(s) |
None
|
storage_location
|
list[StorageLocation] | None
|
Filter by storage location(s) |
None
|
project_id
|
str
|
Filter by project ID |
None
|
sheet_id
|
str
|
Filter by sheet ID |
None
|
created_by
|
list[User]
|
Filter by creator(s) |
None
|
lot_owner
|
list[User]
|
Filter by lot owner(s) |
None
|
tags
|
list[str]
|
Filter by tag(s) |
None
|
match_all_conditions
|
bool
|
Whether to match all conditions (default is False -- e.g. OR between conditions) |
False
|
Returns:
Type | Description |
---|---|
Iterator[InventoryItem]
|
An iterator over the matching inventory items |
Source code in src/albert/collections/inventory.py
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 |
|
update
update(*, inventory_item: InventoryItem) -> InventoryItem
Update an inventory item.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
inventory_item
|
InventoryItem
|
The updated inventory item object. |
required |
Returns:
Type | Description |
---|---|
InventoryItem
|
The updated inventory item retrieved from the server. |