Skip to content

pixano.features.schemas.source

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

Bases: BaseSchema

Source of the annotation.

Attributes:

Name Type Description
name str

Name of the source.

kind str

Kind of source.

metadata str

Metadata of the source. dict[str, Any] encoded in a string.

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_ground_truth(metadata={}) classmethod

Create a ground truth source.

Source code in pixano/features/schemas/source.py
@classmethod
def create_ground_truth(cls, metadata: str | dict[str, Any] = {}) -> "Source":
    """Create a ground truth source."""
    return cls(
        id=SourceKind.GROUND_TRUTH.value,
        name="Ground Truth",
        kind=SourceKind.GROUND_TRUTH.value,
        metadata=metadata,
    )

SourceKind

Bases: Enum

Kind of source that produced the annotation.

Attributes:

Name Type Description
MODEL

Source produced by a model.

HUMAN

Source produced by a human.

GROUND_TRUTH

The source is a ground truth.

OTHER

Source produced by other means.

create_source(id, name, kind, metadata)

Create a Source instance.

Parameters:

Name Type Description Default
id str

Identifier of the source.

required
name str

Name of the source.

required
kind Literal['model', 'human', 'ground_truth', 'other'] | SourceKind

Kind of source.

required
metadata str | dict[str, Any]

Metadata of the source.

required

Returns:

Type Description
Source

The created Source instance.

Source code in pixano/features/schemas/source.py
def create_source(
    id: str,
    name: str,
    kind: Literal["model", "human", "ground_truth", "other"] | SourceKind,
    metadata: str | dict[str, Any],
) -> Source:
    """Create a `Source` instance.

    Args:
        id: Identifier of the source.
        name: Name of the source.
        kind: Kind of source.
        metadata: Metadata of the source.

    Returns:
        The created `Source` instance.
    """
    return Source(id=id, name=name, kind=kind, metadata=metadata)

is_source(cls, strict=False)

Check if a class is a Source or subclass of Source.

Source code in pixano/features/schemas/source.py
def is_source(cls: type, strict: bool = False) -> bool:
    """Check if a class is a Source or subclass of Source."""
    return issubclass_strict(cls, Source, strict)