Sheets
albert.resources.sheets
CellColor
CellType
DesignType
Cell
Bases: BaseResource
A Cell in a Sheet
Attributes:
Name | Type | Description |
---|---|---|
column_id |
str
|
The column ID of the cell. |
row_id |
str
|
The row ID of the cell. |
value |
str | dict
|
The value of the cell. If the cell is an inventory item, this will be a dict. |
min_value |
str | None
|
The minimum allowed value for inventory cells. Optional. |
max_value |
str | None
|
The maximum allowed value for inventory cells. Optional. |
row_label_name |
(str, optional)
|
The display name of the row. |
type |
CellType
|
The type of the cell. Allowed values are |
row_type |
(CellType, optional)
|
The type of the row containing this cell. Usually one of INV (inventory row), TOT (total row), TAS (task row), TAG, PRC, PDC, BAT or BLK. |
name |
str | None
|
The name of the cell. Optional. Default is None. |
calculation |
str
|
The calculation of the cell. Optional. Default is "". |
design_id |
str
|
The design ID of the design this cell is in. |
format |
dict
|
The format of the cell. Optional. Default is {}. The format is a dict with the keys |
raw_value |
str
|
The raw value of the cell. If the cell is an inventory item, this will be the value of the inventory item. Read-only. |
color |
str | None
|
The color of the cell. Read only. |
Component
Bases: BaseResource
Represents an amount of an inventory item in a formulation
Attributes:
Name | Type | Description |
---|---|---|
inventory_item |
InventoryItem
|
The inventory item in the component |
amount |
float
|
The amount of the inventory item in the component |
cell |
Cell
|
The cell that the component is in. Read-only. |
DesignState
Design
Bases: BaseSessionResource
A Design in a Sheet. Designs are sheet subsections that are largly abstracted away from the user.
Attributes:
Name | Type | Description |
---|---|---|
id |
str
|
The Albert ID of the design. |
design_type |
DesignType
|
The type of the design. Allowed values are |
state |
DesignState | None
|
The state of the design. Optional. Default is None. |
grid |
DataFrame | None
|
The grid of the design. Optional. Default is None. Read-only. |
rows |
list[Row] | None
|
The rows of the design. Optional. Default is None. Read-only. |
columns |
list[Column] | None
|
The columns of the design. Optional. Default is None. Read-only. |
SheetFormulationRef
Bases: BaseAlbertModel
A reference to a formulation in a sheet
Show JSON schema:
{
"description": "A reference to a formulation in a sheet",
"properties": {
"id": {
"description": "The Albert ID of the inventory item that is the formulation",
"title": "Id",
"type": "string"
},
"name": {
"description": "The name of the formulation",
"title": "Name",
"type": "string"
},
"hidden": {
"description": "Whether the formulation is hidden",
"title": "Hidden",
"type": "boolean"
}
},
"required": [
"id",
"name",
"hidden"
],
"title": "SheetFormulationRef",
"type": "object"
}
Fields:
Sheet
Bases: BaseSessionResource
A Sheet in Albert
Attributes:
Name | Type | Description |
---|---|---|
id |
str
|
The Albert ID of the sheet. |
name |
str
|
The name of the sheet. |
hidden |
bool
|
Whether the sheet is hidden. |
designs |
list[Design]
|
The designs of the sheet. |
project_id |
str
|
The Albert ID of the project the sheet is in. |
grid |
DataFrame | None
|
The grid of the sheet. Optional. Default is None. Read-only. |
columns |
list[Column]
|
The columns of the sheet. Read-only. |
rows |
list[Row]
|
The rows of the sheet. Read-only. |
Methods:
Name | Description |
---|---|
set_session |
|
set_sheet_fields |
|
rename |
|
add_formulation |
|
add_formulation_columns |
|
add_blank_row |
|
add_inventory_row |
|
update_cells |
|
add_blank_column |
|
delete_column |
|
delete_row |
|
get_column |
Retrieve a Column by its colId, underlying inventory ID, or display header name. |
lock_column |
Lock or unlock a column in the sheet. |
formulations
formulations: list[SheetFormulationRef] = Field(
default_factory=list, alias="Formulas"
)
set_session
set_sheet_fields
set_sheet_fields() -> Sheet
Source code in src/albert/resources/sheets.py
add_formulation
add_formulation(
*,
formulation_name: str,
components: list[Component],
inventory_id: InventoryId | None = None,
enforce_order: bool = False,
clear: bool = True,
) -> Column
Source code in src/albert/resources/sheets.py
add_formulation_columns
add_formulation_columns(
*,
formulation_names: list[str],
starting_position: dict | None = None,
) -> list[Column]
Source code in src/albert/resources/sheets.py
add_blank_row
add_blank_row(
*,
row_name: str,
design: DesignType | str | None = PRODUCTS,
position: dict | None = None,
)
Source code in src/albert/resources/sheets.py
add_inventory_row
Source code in src/albert/resources/sheets.py
update_cells
Source code in src/albert/resources/sheets.py
add_blank_column
Source code in src/albert/resources/sheets.py
delete_column
delete_column(*, column_id: str) -> None
Source code in src/albert/resources/sheets.py
delete_row
Source code in src/albert/resources/sheets.py
get_column
get_column(
*,
column_id: str | None = None,
inventory_id: InventoryId | None = None,
column_name: str | None = None,
) -> Column
Retrieve a Column by its colId, underlying inventory ID, or display header name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
column_id
|
str | None
|
The sheet column ID to match (e.g. "COL5"). |
None
|
inventory_id
|
str | None
|
The internal inventory identifier to match (e.g. "INVP015-001"). |
None
|
column_name
|
str | None
|
The human-readable header name of the column (e.g. "p1"). |
None
|
Returns:
Type | Description |
---|---|
Column
|
The matching Column object. |
Raises:
Type | Description |
---|---|
AlbertException
|
If no matching column is found or if multiple matches exist. |
Source code in src/albert/resources/sheets.py
lock_column
lock_column(
*,
column_id: str | None = None,
inventory_id: InventoryId | None = None,
column_name: str | None = None,
locked: bool = True,
) -> Column
Lock or unlock a column in the sheet.
The column can be specified by its sheet column ID (e.g. "COL5"
),
by the underlying inventory identifier of a formulation/product, or by
the displayed header name. By default the column will be locked; pass
locked=False
to unlock it.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
column_id
|
str | None
|
The sheet column ID to match. |
None
|
inventory_id
|
str | None
|
The inventory identifier of the formulation or product to match. |
None
|
column_name
|
str | None
|
The displayed header name of the column. |
None
|
locked
|
bool
|
Whether to lock ( |
True
|
Returns:
Type | Description |
---|---|
Column
|
The column that was updated. |
Source code in src/albert/resources/sheets.py
Column
Bases: BaseSessionResource
A column in a Sheet
Attributes:
Name | Type | Description |
---|---|---|
column_id |
str
|
The column ID of the column. |
name |
str | None
|
The name of the column. Optional. Default is None. |
type |
CellType
|
The type of the column. Allowed values are |
sheet |
Sheet
|
The sheet the column is in. |
cells |
list[Cell]
|
The cells in the column. Read-only. |
df_name |
str
|
The name of the column in the DataFrame. Read-only |
Methods:
Name | Description |
---|---|
rename |
|
recolor_cells |
|
rename
Source code in src/albert/resources/sheets.py
recolor_cells
recolor_cells(color: CellColor)
Row
Bases: BaseSessionResource
A row in a Sheet
Attributes:
Name | Type | Description |
---|---|---|
row_id |
str
|
The row ID of the row. |
type |
CellType
|
The type of the row. Allowed values are |
design |
Design
|
The design the row is in. |
sheet |
Sheet
|
The sheet the row is in. |
name |
str | None
|
The name of the row. Optional. Default is None. |
inventory_id |
str | None
|
The inventory ID of the row. Optional. Default is None. |
manufacturer |
str | None
|
The manufacturer of the row. Optional. Default is None. |
row_unique_id |
str
|
The unique ID of the row. Read-only. |
cells |
list[Cell]
|
The cells in the row. Read-only. |
Methods:
Name | Description |
---|---|
recolor_cells |
|