Skip to content

pixano.features.schemas.entities.named_entity

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

Bases: Entity

A named entity.

A NamedEntity represents an entity with a simple name attribute.

Attributes:

Name Type Description
name str

The name of the entity.

Source code in pixano/features/schemas/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)

create_named_entity(name, id='', item_ref=ItemRef.none(), view_ref=ViewRef.none(), parent_ref=EntityRef.none())

Create a NamedEntity instance.

Parameters:

Name Type Description Default
name str

The name of the entity.

required
id str

NamedEntity ID.

''
item_ref ItemRef

Item reference.

none()
view_ref ViewRef

View reference.

none()
parent_ref EntityRef

Entity reference.

none()

Returns:

Type Description
NamedEntity

The created NamedEntity instance.

Source code in pixano/features/schemas/entities/named_entity.py
def create_named_entity(
    name: str,
    id: str = "",
    item_ref: ItemRef = ItemRef.none(),
    view_ref: ViewRef = ViewRef.none(),
    parent_ref: EntityRef = EntityRef.none(),
) -> NamedEntity:
    """Create a `NamedEntity` instance.

    Args:
        name: The name of the entity.
        id: NamedEntity ID.
        item_ref: Item reference.
        view_ref: View reference.
        parent_ref: Entity reference.

    Returns:
        The created `NamedEntity` instance.
    """
    return NamedEntity(
        id=id,
        item_ref=item_ref,
        view_ref=view_ref,
        parent_ref=parent_ref,
        name=name,
    )

is_named_entity(cls, strict=False)

Check if the given class is a NamedEntity or a subclass of NamedEntity.

Source code in pixano/features/schemas/entities/named_entity.py
def is_named_entity(cls: type, strict: bool = False) -> bool:
    """Check if the given class is a `NamedEntity` or a subclass of `NamedEntity`."""
    return issubclass_strict(cls, NamedEntity, strict)