Batch Data
albert.collections.batch_data.BatchDataCollection
Bases: BaseCollection
Manage Batch Data for Batch Tasks in the Albert platform.
Batch Data is the tabular record behind a Batch Task
(BatchTask): the grid that captures how a
physical batch of a formulation was actually made. It is organized as:
- Rows (
BatchDataRow): the formulation components (ingredients) that go into the batch, along with nested child rows for sub-formulas. - Product columns (
BatchDataColumn): the batch/product being manufactured, carrying batch totals, reference totals, and any lot breakdowns. - Values (
BatchDataValue): the amount recorded for a given row within a given column.
Batch Data is keyed by the Task ID of its Batch Task (format TAS...); it
is not a standalone catalog entity, so there is no free-text search. Retrieve
it with get_by_id using the owning Task ID, initialize it for a task
with create_batch_data, and record which lots were consumed with
update_used_batch_amounts.
This collection is accessed as client.batch_data.
Example
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 batch data requests. |
Methods:
| Name | Description |
|---|---|
create_batch_data |
Initialize the batch data entry for a batch task. |
get_by_id |
Get the batch data for a batch task by its ID. |
update_used_batch_amounts |
Record which lots were used for the batch's recorded amounts. |
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
AlbertSession
|
The authenticated Albert session used for API calls. |
required |
Source code in src/albert/collections/batch_data.py
create_batch_data
create_batch_data(*, task_id: TaskId)
Initialize the batch data entry for a batch task.
Sets up the empty batch data grid for the given Batch Task so that
amounts and lots can subsequently be recorded. Retrieve the populated
grid afterwards with get_by_id.
Example
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
task_id
|
TaskId
|
The Task ID of the batch task to create batch data for
(format |
required |
Returns:
| Type | Description |
|---|---|
BatchData
|
The created batch data entry. |
Source code in src/albert/collections/batch_data.py
get_by_id
get_by_id(
*,
id: TaskId,
type: BatchDataType = TASK_ID,
limit: int = 100,
start_key: str | None = None,
order_by: OrderBy = DESCENDING,
) -> BatchData
Get the batch data for a batch task by its ID.
Returns the batch data grid (rows, product columns, and recorded values)
for the owning Batch Task (BatchTask).
Example
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
TaskId
|
The identifier to look up, of the kind given by |
required |
type
|
BatchDataType
|
The kind of identifier passed as |
TASK_ID
|
limit
|
int
|
Maximum number of row entries to return per response. Defaults to 100. |
100
|
start_key
|
str
|
Pagination cursor identifying the first entry to evaluate; pass the
|
None
|
order_by
|
OrderBy
|
Direction in which results are sorted. Defaults to
|
DESCENDING
|
Returns:
| Type | Description |
|---|---|
BatchData
|
The fully populated batch data. |
Source code in src/albert/collections/batch_data.py
update_used_batch_amounts
update_used_batch_amounts(
*,
task_id: TaskId,
patches: list[BatchValuePatchPayload],
) -> None
Record which lots were used for a batch task's recorded amounts.
Applies patch entries that set the lot consumed for individual cells of
the batch data grid, identified by their row (and optional column). Each
patch targets a value via a
BatchValueId and describes the
change with one or more
BatchValuePatchDatum entries.
Example
from albert import Albert
from albert.resources.batch_data import (
BatchValueId,
BatchValuePatchDatum,
BatchValuePatchPayload,
)
client = Albert()
patch = BatchValuePatchPayload(
id=BatchValueId(row_id="ROW1", col_id="COL9999999"),
data=[
BatchValuePatchDatum(
operation="update",
new_value="LOT123",
old_value="LOT100",
)
],
)
client.batch_data.update_used_batch_amounts(task_id="TAS123", patches=[patch])
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
task_id
|
TaskId
|
The Task ID of the batch task to update (format |
required |
patches
|
list[BatchValuePatchPayload]
|
Patch entries describing which batch values to update and the lot to assign to each. |
required |
Returns:
| Type | Description |
|---|---|
None
|
|