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. |
exists |
Check if an inventory item exists. |
get_match_or_none |
Get a matching inventory item by name and company, 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 a 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 |
Search for Inventory items matching the provided criteria. |
get_all |
Retrieve fully hydrated InventoryItem entities 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
exists
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 by name and company, or return None if not found.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
inventory_item
|
InventoryItem
|
The inventory item to match. |
required |
Returns:
Type | Description |
---|---|
InventoryItem or None
|
The matching inventory 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.
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 a 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 entities, 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 entities 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(
*,
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,
order: OrderBy = DESCENDING,
sort_by: str | None = None,
max_items: int | None = None,
offset: int | None = 0,
) -> Iterator[InventorySearchItem]
Search for Inventory items 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
|
Search text for full-text matching. |
None
|
cas
|
Cas or list[Cas]
|
Filter by CAS numbers. |
None
|
category
|
InventoryCategory or list[InventoryCategory]
|
Filter by item category. |
None
|
company
|
Company or list[Company]
|
Filter by associated company. |
None
|
location
|
Location or list[Location]
|
Filter by location. |
None
|
storage_location
|
StorageLocation or list[StorageLocation]
|
Filter by storage location. |
None
|
project_id
|
str
|
Filter by project ID (formulas). |
None
|
sheet_id
|
str
|
Filter by worksheet ID. |
None
|
created_by
|
User or list[User]
|
Filter by creator(s). |
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
|
Whether to match all filters (AND logic). Default is False. |
False
|
order
|
OrderBy
|
Sort order. Default is DESCENDING. |
DESCENDING
|
sort_by
|
str
|
Field to sort results by. Default is None. |
None
|
max_items
|
int
|
Maximum number of items to return in total. If None, fetches all available items. |
None
|
offset
|
int
|
Offset for pagination. Default is 0. |
0
|
Returns:
Type | Description |
---|---|
Iterator[InventorySearchItem]
|
An iterator over partial (unhydrated) InventorySearchItem results. |
Source code in src/albert/collections/inventory.py
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 |
|
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]
| 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,
order: OrderBy = DESCENDING,
sort_by: str | None = None,
max_items: int | None = None,
offset: int | None = 0,
) -> Iterator[InventoryItem]
Retrieve fully hydrated InventoryItem entities with optional filters.
This method returns complete entity data using get_by_ids
.
Use search()
for faster retrieval when you only need lightweight, partial (unhydrated) entities.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text
|
str
|
Search text for full-text matching. |
None
|
cas
|
Cas or list[Cas]
|
Filter by CAS numbers. |
None
|
category
|
InventoryCategory or list[InventoryCategory]
|
Filter by item category. |
None
|
company
|
Company or list[Company]
|
Filter by associated company. |
None
|
location
|
Location or list[Location]
|
Filter by location. |
None
|
storage_location
|
StorageLocation or list[StorageLocation]
|
Filter by storage location. |
None
|
project_id
|
str
|
Filter by project ID (formulas). |
None
|
sheet_id
|
str
|
Filter by worksheet ID. |
None
|
created_by
|
User or list[User]
|
Filter by creator(s). |
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
|
Whether to match all filters (AND logic). Default is False. |
False
|
order
|
OrderBy
|
Sort order. Default is DESCENDING. |
DESCENDING
|
sort_by
|
str
|
Field to sort results by. Default is None. |
None
|
max_items
|
int
|
Maximum number of items to return in total. If None, fetches all available items. |
None
|
offset
|
int
|
Offset for pagination. Default is 0. |
0
|
Returns:
Type | Description |
---|---|
Iterator[InventoryItem]
|
An iterator over fully hydrated InventoryItem entities. |
Source code in src/albert/collections/inventory.py
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 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 |
|
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. |