Skip to content

pixano.app.models.entities

EntityModel(created_at=None, updated_at=None, **data)

Bases: BaseSchemaModel[Entity]

Model for the Entity schema.

Source code in pixano/app/models/base_schema.py
def __init__(self, /, created_at: datetime | None = None, updated_at: datetime | None = None, **data: Any):
    """Create a new model by parsing and validating input data from keyword arguments.

    Raises [`ValidationError`][pydantic_core.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.

    Args:
        created_at: The creation date of the object.
        updated_at: The last modification date of the object.
        data: The data of the object validated by Pydantic.
    """
    created_at, updated_at = validate_and_init_create_at_and_update_at(created_at, updated_at)
    data.update({"created_at": created_at, "updated_at": updated_at})
    super().__init__(**data)

to_row(schema_type)

Create an Entity from the model.

Source code in pixano/app/models/entities.py
def to_row(self, schema_type: type[T]) -> T:
    """Create an [Entity][pixano.features.Entity] from the model."""
    if not issubclass(schema_type, Entity):
        raise ValueError(f"Schema type must be a subclass of {Entity.__name__}.")
    return super().to_row(schema_type)