Skip to content

pixano.app.models.datasets

DatasetBrowser(**data)

Bases: BaseModel

Data for Dataset Browser page.

Attributes:

Name Type Description
id str

dataset id

name str

dataset name

table_data TableData

table data

pagination PaginationInfo

pagination infos

semantic_search list[str]

list of semantic search available models

Source code in pydantic/main.py
def __init__(self, /, **data: Any) -> None:
    """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.
    """
    # `__tracebackhide__` tells pytest and some other tools to omit this function from tracebacks
    __tracebackhide__ = True
    validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self)
    if self is not validated_self:
        warnings.warn(
            'A custom validator is returning a value other than `self`.\n'
            "Returning anything other than `self` from a top level model validator isn't supported when validating via `__init__`.\n"
            'See the `model_validator` docs (https://docs.pydantic.dev/latest/concepts/validators/#model-validators) for more details.',
            stacklevel=2,
        )

DatasetModel(**data)

Bases: BaseModel

The model of a dataset.

Attributes:

Name Type Description
id str

Dataset ID.

path Path

Path to the dataset.

previews_path Path

Path to the previews.

media_dir Path

Path to the media directory.

thumbnail Path

Path to the thumbnail.

dataset_schema DatasetSchema

The dataset schema.

feature_values DatasetFeaturesValues

The feature values of the dataset.

info DatasetInfoModel

The dataset info.

Source code in pydantic/main.py
def __init__(self, /, **data: Any) -> None:
    """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.
    """
    # `__tracebackhide__` tells pytest and some other tools to omit this function from tracebacks
    __tracebackhide__ = True
    validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self)
    if self is not validated_self:
        warnings.warn(
            'A custom validator is returning a value other than `self`.\n'
            "Returning anything other than `self` from a top level model validator isn't supported when validating via `__init__`.\n"
            'See the `model_validator` docs (https://docs.pydantic.dev/latest/concepts/validators/#model-validators) for more details.',
            stacklevel=2,
        )

from_dataset(dataset) classmethod

Create a dataset model from a dataset.

Parameters:

Name Type Description Default
dataset Dataset

The dataset.

required

Returns:

Type Description
Self

The dataset model.

Source code in pixano/app/models/datasets.py
@classmethod
def from_dataset(cls, dataset: Dataset) -> Self:
    """Create a dataset model from a dataset.

    Args:
        dataset: The dataset.

    Returns:
        The dataset model.
    """
    info = DatasetInfoModel.from_dataset_info(dataset.info, dataset.path)
    return cls(
        id=dataset.info.id,
        path=dataset.path,
        previews_path=dataset.previews_path,
        media_dir=dataset.media_dir,
        thumbnail=dataset.thumbnail,
        dataset_schema=dataset.schema,
        feature_values=dataset.features_values,
        info=info,
    )

from_json(data) classmethod

Create a dataset model from a JSON object.

Parameters:

Name Type Description Default
data dict[str, Any]

JSON object.

required

Returns:

Type Description
Self

Dataset model.

Source code in pixano/app/models/datasets.py
@classmethod
def from_json(cls, data: dict[str, Any]) -> Self:
    """Create a dataset model from a JSON object.

    Args:
        data: JSON object.

    Returns:
        Dataset model.
    """
    return cls(
        id=data["id"],
        path=Path(data["path"]),
        previews_path=Path(data["previews_path"]),
        media_dir=Path(data["media_dir"]),
        thumbnail=Path(data["thumbnail"]),
        dataset_schema=DatasetSchema.deserialize(data["dataset_schema"]),
        feature_values=DatasetFeaturesValues(**data["feature_values"]),
        info=DatasetInfoModel.from_dataset_info(DatasetInfo(**data["info"]), Path(data["path"])),
    )

to_dataset()

Create a dataset from a dataset model.

Source code in pixano/app/models/datasets.py
def to_dataset(self) -> Dataset:
    """Create a dataset from a dataset model."""
    return Dataset(self.path, self.media_dir)

PaginationColumn(**data)

Bases: BaseModel

Column description.

Attributes:

Name Type Description
name str

column name.

type str

column type.

Source code in pydantic/main.py
def __init__(self, /, **data: Any) -> None:
    """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.
    """
    # `__tracebackhide__` tells pytest and some other tools to omit this function from tracebacks
    __tracebackhide__ = True
    validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self)
    if self is not validated_self:
        warnings.warn(
            'A custom validator is returning a value other than `self`.\n'
            "Returning anything other than `self` from a top level model validator isn't supported when validating via `__init__`.\n"
            'See the `model_validator` docs (https://docs.pydantic.dev/latest/concepts/validators/#model-validators) for more details.',
            stacklevel=2,
        )

PaginationInfo(**data)

Bases: BaseModel

Pagination info.

Attributes:

Name Type Description
current_page int

current page.

page_size int

number of items per page.

total_size int

total number of items.

Source code in pydantic/main.py
def __init__(self, /, **data: Any) -> None:
    """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.
    """
    # `__tracebackhide__` tells pytest and some other tools to omit this function from tracebacks
    __tracebackhide__ = True
    validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self)
    if self is not validated_self:
        warnings.warn(
            'A custom validator is returning a value other than `self`.\n'
            "Returning anything other than `self` from a top level model validator isn't supported when validating via `__init__`.\n"
            'See the `model_validator` docs (https://docs.pydantic.dev/latest/concepts/validators/#model-validators) for more details.',
            stacklevel=2,
        )

TableData(**data)

Bases: BaseModel

Table data.

Attributes:

Name Type Description
columns list[PaginationColumn]

column descriptions.

rows list[dict[str, Any]]

rows (actual data).

Source code in pydantic/main.py
def __init__(self, /, **data: Any) -> None:
    """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.
    """
    # `__tracebackhide__` tells pytest and some other tools to omit this function from tracebacks
    __tracebackhide__ = True
    validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self)
    if self is not validated_self:
        warnings.warn(
            'A custom validator is returning a value other than `self`.\n'
            "Returning anything other than `self` from a top level model validator isn't supported when validating via `__init__`.\n"
            'See the `model_validator` docs (https://docs.pydantic.dev/latest/concepts/validators/#model-validators) for more details.',
            stacklevel=2,
        )