pixano.app.models.base_schema
BaseSchemaModel(created_at=None, updated_at=None, **data)
Base schema model.
This class is a base class for all schema models. It provides methods to convert a row to a model and vice versa.
Attributes:
Name | Type | Description |
---|---|---|
id |
str
|
Unique identifier of the row. |
created_at |
datetime
|
The creation date of the row. |
updated_at |
datetime
|
The last modification date of the row. |
table_info |
TableInfo
|
Information about the table to which the row belongs. |
data |
dict[str, Any]
|
Dumped data from the Pixano backend row except the id. |
Raises ValidationError
if the input data cannot be
validated to form a valid model.
self
is explicitly positional-only to allow self
as a field name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
created_at
|
datetime | None
|
The creation date of the object. |
None
|
updated_at
|
datetime | None
|
The last modification date of the object. |
None
|
data
|
Any
|
The data of the object validated by Pydantic. |
{}
|
Source code in pixano/app/models/base_schema.py
from_row(row, table_info)
classmethod
Create a model from a row.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
row
|
T
|
The row to create the model from. |
required |
table_info
|
TableInfo
|
The table info of the row. |
required |
Returns:
Type | Description |
---|---|
Self
|
The created model. |
Source code in pixano/app/models/base_schema.py
from_rows(rows, table_info)
classmethod
Create a list of models from a list of schemas.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
rows
|
list[T]
|
The rows to create the models from. |
required |
table_info
|
TableInfo
|
The table info of the rows. |
required |
Returns:
Type | Description |
---|---|
list[Self]
|
The list of created models. |
Source code in pixano/app/models/base_schema.py
model_dump(exclude_timestamps=False, **kwargs)
Dump the model to a dictionary.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
exclude_timestamps
|
bool
|
Exclude timestamps "created_at" and "updated_at" from the model dump. Useful for comparing models without timestamps. |
False
|
kwargs
|
Any
|
Arguments for pydantic |
{}
|
Returns:
Type | Description |
---|---|
dict[str, Any]
|
The model dump. |
Source code in pixano/app/models/base_schema.py
to_row(dataset)
Create a row from the model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataset
|
Dataset
|
The dataset of the row. |
required |
Returns:
Type | Description |
---|---|
T
|
The created row. |
Source code in pixano/app/models/base_schema.py
to_rows(models, dataset)
staticmethod
Create a list of rows from a list of models.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
models
|
list[BaseSchemaModel]
|
The models to create the rows from. |
required |
dataset
|
Dataset
|
The dataset of the row. |
required |
Returns:
Type | Description |
---|---|
list[T]
|
The list of created rows. |