Attributes (🧪 Beta)
albert.collections.attributes.AttributeCollection
Bases: BaseCollection
Manage inventory reference Attributes in the Albert platform (🧪 Beta).
An Attribute is a centralized, reusable inventory reference property
template (e.g. "Viscosity @ 25°C"): it names what to track, which
DataColumn it maps to, optional
parameter setpoints (e.g. Temperature = 25°C), an optional unit, and typed
validation. Reference values are the actual measured or assigned values for
that attribute on a specific inventory item or lot.
The API separates definition (create
Attribute definitions) from assignment
(store values on a parent with
add_values).
Inventory-level values are the source of truth for worksheet lookup columns;
worksheet cells may override locally for what-if analysis without writing back
to inventory.
This replaces the deprecated per-item Inventory Specs API
(get_specs,
add_specs).
Attributes are identified by Attribute ID (format ATR..., e.g.
"ATR469"). Reference values are keyed by parent_id: inventory items
(INV...), lots (LOT...), or other parent types as the platform expands.
This collection is accessed as client.attributes.
Beta Feature!
Please do not use in production or without explicit guidance from Albert. You might otherwise have a bad experience. This feature currently falls outside of the Albert support contract, but we'd love your feedback!
Example
from albert import Albert
from albert.resources.attributes import (
Attribute,
AttributeCategory,
AttributeValue,
ValidationItem,
)
from albert.resources.parameter_groups import DataType, Operator
client = Albert()
viscosity = client.attributes.create(
attribute=Attribute(
datacolumn_id="DAC123",
category=AttributeCategory.PROPERTY,
reference_name="Viscosity @ 25°C",
validation=[
ValidationItem(
datatype=DataType.NUMBER,
min=0.0,
max=500.0,
operator=Operator.BETWEEN,
)
],
)
)
client.attributes.add_values(
parent_id="INVA123",
values=[AttributeValue(attributeId=viscosity.id, referenceValue=45.2)],
)
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 attribute requests. |
Methods:
| Name | Description |
|---|---|
get_all |
Get all attributes, with optional filters. |
get_by_id |
Get a single attribute by its ID. |
get_by_ids |
Get multiple attributes by their IDs. |
create |
Create a new attribute. |
update |
Update an existing attribute. |
delete |
Delete an attribute by its ID. |
search |
Search for attributes matching the given filters. |
add_values |
Add or update reference values for a parent entity. |
get_values |
Get reference values for a parent entity. |
get_by_parent_ids |
Get reference values for multiple parent entities. |
delete_values |
Delete specific reference values from a parent entity. |
clear_values |
Remove all reference values from a parent entity. |
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
AlbertSession
|
The authenticated Albert session used for API calls. |
required |
Source code in src/albert/collections/attributes.py
get_all
get_all(
*,
category: AttributeCategory | None = None,
start_key: str | None = None,
max_items: int | None = None,
) -> Iterator[Attribute]
Get all attribute definitions, with optional filters.
Lists reusable inventory reference property templates (e.g. "Viscosity @
25°C") that can be assigned to inventory items and lots. Use
search for
full-text and field filters across the catalogue.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
category
|
AttributeCategory
|
Filter attributes by category (currently |
None
|
start_key
|
str
|
Pagination start key from a previous request. |
None
|
max_items
|
int
|
Maximum number of items to return. |
None
|
Returns:
| Type | Description |
|---|---|
Iterator[Attribute]
|
An iterator over Attribute entities. |
Source code in src/albert/collections/attributes.py
get_by_id
get_by_id(*, id: AttributeId) -> Attribute
Get a single attribute definition by its ID.
Returns the full template: linked data column, parameter setpoints, unit, and validation rules used when assigning reference values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
str
|
The attribute ID (format |
required |
Returns:
| Type | Description |
|---|---|
Attribute
|
The fully populated attribute. |
Source code in src/albert/collections/attributes.py
get_by_ids
get_by_ids(*, ids: list[AttributeId]) -> list[Attribute]
Get multiple attributes by their IDs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ids
|
list[str]
|
A list of attribute IDs. |
required |
Returns:
| Type | Description |
|---|---|
list[Attribute]
|
The fully populated attributes. |
Source code in src/albert/collections/attributes.py
create
Create a new inventory reference attribute definition.
Define the property template once in the attribute catalogue, then assign values to
inventory items or lots with add_values.
Uniqueness is enforced on name and on the data column, unit, and parameter
setpoint combination.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
attribute
|
Attribute
|
The attribute to create. |
required |
Returns:
| Type | Description |
|---|---|
Attribute
|
The fully populated attribute. |
Source code in src/albert/collections/attributes.py
update
Update an existing attribute definition.
Changes apply to the attribute definition. Inventory items that already store reference values keep their assignments; worksheet cells that previously imported a value are not updated automatically.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
attribute
|
Attribute
|
The updated Attribute object. Must have an ID set. |
required |
Returns:
| Type | Description |
|---|---|
Attribute
|
The fully populated attribute. |
Notes
The following fields can be updated: reference_name, parameters,
validation. reference_name must remain unique across definitions.
unit_id can only be set once (when no unit is currently assigned); it
cannot be changed afterwards.
Source code in src/albert/collections/attributes.py
delete
delete(*, id: AttributeId) -> None
Delete an attribute definition by its ID.
Removes the template from the attribute catalogue and its inventory-level reference values. Worksheet cells that already imported a value retain their local copy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
str
|
The attribute ID (format |
required |
Returns:
| Type | Description |
|---|---|
None
|
|
Source code in src/albert/collections/attributes.py
search
search(
*,
text: str | None = None,
order_by: OrderBy = DESCENDING,
sort_by: str | None = None,
datacolumn_id: list[DataColumnId] | None = None,
datacolumn_name: list[str] | None = None,
parameter: list[str] | None = None,
unit: list[str] | None = None,
data_type: list[DataType] | None = None,
facet_text: str | None = None,
facet_field: str | None = None,
contains_field: list[str] | None = None,
contains_text: list[str] | None = None,
max_items: int | None = None,
) -> Iterator[AttributeSearchItem]
Search the central attribute catalogue.
Full-text and field filters help locate reusable definitions when wiring worksheet lookup columns or assigning values on inventory details.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
Full-text search term. |
None
|
order_by
|
OrderBy
|
Sort order. Default is DESCENDING. |
DESCENDING
|
sort_by
|
str
|
Field to sort results by. |
None
|
datacolumn_id
|
list[str]
|
Filter by data column IDs. |
None
|
datacolumn_name
|
list[str]
|
Filter by data column names. |
None
|
parameter
|
list[str]
|
Filter by parameter name(s) (e.g., |
None
|
unit
|
list[str]
|
Filter by unit name(s) (e.g., |
None
|
data_type
|
list[DataType]
|
Filter by data type(s). |
None
|
facet_text
|
str
|
Facet text to search for. |
None
|
facet_field
|
str
|
Facet field to filter on. |
None
|
contains_field
|
list[str]
|
Fields to search inside. |
None
|
contains_text
|
list[str]
|
Values to search for within the |
None
|
max_items
|
int
|
Maximum number of items to return. |
None
|
Returns:
| Type | Description |
|---|---|
Iterator[AttributeSearchItem]
|
An iterator over search results. |
Source code in src/albert/collections/attributes.py
316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 | |
add_values
add_values(
*, parent_id: str, values: list[AttributeValue]
) -> AttributeValuesResponse
Add or update reference values on a parent entity.
Upserts values for the given attributes on parent_id (inventory item,
lot, etc.). Values must match each attribute's datatype. Inventory-level
values feed worksheet lookups; each inventory item holds its own values.
Attributes not listed in values are left unchanged.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parent_id
|
str
|
The ID of the parent entity (inventory item, lot, etc.). |
required |
values
|
list[AttributeValue]
|
The attribute values to add or update. |
required |
Returns:
| Type | Description |
|---|---|
AttributeValuesResponse
|
The saved attribute values with full attribute definitions. |
Source code in src/albert/collections/attributes.py
get_values
get_values(
*,
parent_id: str,
scope: AttributeScope | None = None,
start_key: str | None = None,
max_items: int | None = None,
) -> Iterator[AttributeValuesResponse]
Get reference values for a parent entity.
Returns one AttributeValuesResponse
per entity when scope includes child lots. Inventory item values are
the canonical source for worksheet reference columns.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parent_id
|
str
|
The ID of the parent entity. |
required |
scope
|
AttributeScope
|
Defines which entities to fetch values for.
|
None
|
start_key
|
str
|
Pagination start key from a previous request. |
None
|
max_items
|
int
|
Maximum number of items to return. |
None
|
Returns:
| Type | Description |
|---|---|
Iterator[AttributeValuesResponse]
|
An iterator over attribute value responses, one per entity. |
Source code in src/albert/collections/attributes.py
get_by_parent_ids
get_by_parent_ids(
*, parent_ids: list[str], max_items: int | None = None
) -> list[AttributeValuesResponse]
Get reference values for multiple parent entities.
Bulk read across inventory items (replaces deprecated
get_specs).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parent_ids
|
list[str]
|
The IDs of the parent entities to fetch values for. |
required |
max_items
|
int | None
|
Maximum total number of attribute value items to return across all parents. When None (default), all pages are fetched for every parent. |
None
|
Returns:
| Type | Description |
|---|---|
list[AttributeValuesResponse]
|
Attribute values for each parent entity that has values set. |
Source code in src/albert/collections/attributes.py
delete_values
delete_values(
*,
parent_id: str,
attribute_ids: list[AttributeId],
scope: AttributeScope | None = None,
) -> None
Delete specific reference values from a parent entity.
Removes assignments for the given attributes on parent_id without
deleting the attribute definitions themselves. Use scope to target lot-level
values under an inventory parent.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parent_id
|
str
|
The ID of the parent entity (inventory item |
required |
attribute_ids
|
list[str]
|
The attribute IDs whose values should be removed. |
required |
scope
|
AttributeScope
|
Scope of deletion. Defaults to |
None
|
Returns:
| Type | Description |
|---|---|
None
|
|
Source code in src/albert/collections/attributes.py
clear_values
clear_values(
*, parent_id: str, scope: AttributeScope | None = None
) -> None
Remove all reference values from a parent entity.
Clears every assignment on parent_id while leaving attribute
definitions in the attribute catalogue. Use scope to clear lot values
under an inventory item.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parent_id
|
str
|
The ID of the parent entity (inventory item |
required |
scope
|
AttributeScope
|
Scope of deletion. Defaults to |
None
|
Returns:
| Type | Description |
|---|---|
None
|
|