Data Columns
albert.collections.data_columns.DataColumnCollection
Bases: BaseCollection
Manage Data Columns in the Albert platform.
A Data Column (DAC, IDs DAC...) is the definition of a single measured
result variable, such as Viscosity or APHA Color. Data columns are the
reusable building blocks of a Data Template's results: a
DataTemplate references them through
its data_column_values, and the values recorded against a data column
during experiments are stored as Property Data.
This collection is accessed as client.data_columns.
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 data column requests. |
Methods:
| Name | Description |
|---|---|
search |
Search data columns with free text and filters, returning partial items. |
get_all |
Get data columns matching optional filters. |
get_by_id |
Get a single data column by its ID. |
get_by_name |
Get a single data column by its exact name. |
create |
Create a new data column. |
get_or_create |
Return the existing data column matching by name, or create it. |
update |
Update an existing data column. |
delete |
Delete a data column by its ID. |
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
AlbertSession
|
The authenticated Albert session used for API calls. |
required |
Source code in src/albert/collections/data_columns.py
get_by_name
get_by_name(*, name: str) -> DataColumn | None
Get a single data column by its exact name.
Matching is case-insensitive. To retrieve multiple columns or use partial
matching, use get_all; for
free-text search, use search.
Example
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The name of the data column to retrieve (e.g. |
required |
Returns:
| Type | Description |
|---|---|
DataColumn or None
|
The matching data column, or None if no exact match is found. |
Source code in src/albert/collections/data_columns.py
get_by_id
get_by_id(*, id: DataColumnId) -> DataColumn
Get a single data column by its ID.
To find a column without knowing its ID, use get_by_name or
get_all.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
DataColumnId
|
The Data Column ID (format |
required |
Returns:
| Type | Description |
|---|---|
DataColumn
|
The fully populated data column. |
Source code in src/albert/collections/data_columns.py
search
search(
*,
text: str | None = None,
created_by: str | list[str] | None = None,
data_template: str | list[str] | None = None,
albert_id: str | list[str] | None = None,
facet_text: str | None = None,
facet_field: str | None = None,
contains_field: str | list[str] | None = None,
contains_text: str | list[str] | None = None,
source_field: str | list[str] | None = None,
additional_field: str | list[str] | None = None,
translation: str | list[str] | None = None,
sort_by: str | None = None,
order: OrderBy | None = None,
metadata_filters: dict[str, Any] | None = None,
custom_fields: dict[str, Any] | None = None,
max_items: int | None = None,
) -> Iterator[DataColumnSearchItem]
Search for data columns matching the given filters.
Returns partial (unhydrated)
DataColumnSearchItem entities, best for
free-text lookups, counts, and pulling IDs. Results are returned lazily as an
iterator that pages through matches on demand. Call hydrate() on an item
to fetch its full DataColumn.
Example
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
Free-text query matched against data column fields. |
None
|
created_by
|
str or list[str]
|
Filter by creator user ID(s). |
None
|
data_template
|
str or list[str]
|
Filter by data template name(s) the columns belong to. |
None
|
albert_id
|
str or list[str]
|
Filter by Data Column ID(s) (format |
None
|
facet_text
|
str
|
Text to match within a facet search. |
None
|
facet_field
|
str
|
Field to search within for facet filtering. |
None
|
contains_field
|
str or list[str]
|
Field(s) to apply a "contains" search to. |
None
|
contains_text
|
str or list[str]
|
Text value(s) for the "contains" search. |
None
|
source_field
|
str or list[str]
|
Restrict which fields are returned on each search hit. |
None
|
additional_field
|
str or list[str]
|
Additional fields to include on each search hit. |
None
|
translation
|
str or list[str]
|
Filter by translation(s). |
None
|
sort_by
|
str
|
Attribute to sort results by. |
None
|
order
|
OrderBy
|
The order in which to sort results ( |
None
|
metadata_filters
|
dict[str, Any]
|
Filter by metadata field values. |
None
|
custom_fields
|
dict[str, Any]
|
Filter by custom field values. |
None
|
max_items
|
int
|
Maximum number of items to return in total. If None, iterates over all matching items. |
None
|
Returns:
| Type | Description |
|---|---|
Iterator[DataColumnSearchItem]
|
A lazy iterator of matching partial data columns. Call |
Source code in src/albert/collections/data_columns.py
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 | |
get_all
get_all(
*,
order_by: OrderBy = DESCENDING,
ids: DataColumnId | list[DataColumnId] | None = None,
name: str | list[str] | None = None,
exact_match: bool | None = None,
default: bool | None = None,
start_key: str | None = None,
max_items: int | None = None,
) -> Iterator[DataColumn]
Get data columns matching the given filters.
Results are returned as a lazily paginated iterator, so iterating fetches
additional pages on demand. To retrieve a single column by its exact name,
use get_by_name; by its ID, use get_by_id. For
free-text search, use search.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
order_by
|
OrderBy
|
Sort direction. Default |
DESCENDING
|
ids
|
DataColumnId or list[DataColumnId]
|
Filter by one or more Data Column IDs (format |
None
|
name
|
str or list[str]
|
Filter by name(s). |
None
|
exact_match
|
bool
|
When True, the |
None
|
default
|
bool
|
When True, return only default data columns. |
None
|
start_key
|
str
|
Pagination key to resume from. Usually left unset. |
None
|
max_items
|
int
|
Maximum number of items to return in total. If None, iterates over all matches. |
None
|
Returns:
| Type | Description |
|---|---|
Iterator[DataColumn]
|
A lazily paginated iterator of matching data columns. |
Source code in src/albert/collections/data_columns.py
create
create(*, data_column: DataColumn) -> DataColumn
Create a new data column.
To avoid creating a duplicate when a column with the same name may already
exist, use get_or_create instead.
Example
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data_column
|
DataColumn
|
The data column to create. |
required |
Returns:
| Type | Description |
|---|---|
DataColumn
|
The newly created data column, populated with its assigned Data Column ID. |
Source code in src/albert/collections/data_columns.py
get_or_create
get_or_create(*, data_column: DataColumn) -> DataColumn
Return the existing data column matching by name, or create it.
If a data column with the same name already exists, that existing column is
returned instead of creating a duplicate; otherwise a new column is created
via create.
Example
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data_column
|
DataColumn
|
The data column to get or create. Its |
required |
Returns:
| Type | Description |
|---|---|
DataColumn
|
The existing or newly created data column. |
Source code in src/albert/collections/data_columns.py
delete
delete(*, id: DataColumnId) -> None
Delete a data column by its ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
DataColumnId
|
The Data Column ID to delete (format |
required |
Returns:
| Type | Description |
|---|---|
None
|
|
Source code in src/albert/collections/data_columns.py
update
update(*, data_column: DataColumn) -> DataColumn
Update an existing data column.
Fetch the column (e.g. with get_by_id), modify the updatable fields
on the returned object, then pass it here. Only the fields listed in Notes
are applied; changes to other fields are ignored.
Example
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data_column
|
DataColumn
|
The data column to update. Must have a valid |
required |
Returns:
| Type | Description |
|---|---|
DataColumn
|
The updated data column as registered in Albert. |
Notes
The following fields can be updated: metadata, name.