Skip to content

pixano.app.models.dataset_info

DatasetInfoModel(**data)

Bases: DatasetInfo

Dataset info model.

It contains all the information as a DatasetInfo and the number of items in the dataset.

Attributes:

Name Type Description
num_items int

Number of items in the dataset.

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_info(dataset_info, dataset_dir) staticmethod

Create a dataset info model from a dataset info.

Parameters:

Name Type Description Default
dataset_info DatasetInfo

Dataset info.

required
dataset_dir Path

Dataset directory.

required

Returns:

Type Description
DatasetInfoModel

Dataset info model.

Source code in pixano/app/models/dataset_info.py
@staticmethod
def from_dataset_info(dataset_info: DatasetInfo, dataset_dir: Path) -> "DatasetInfoModel":
    """Create a dataset info model from a dataset info.

    Args:
        dataset_info: Dataset info.
        dataset_dir: Dataset directory.

    Returns:
        Dataset info model.
    """
    db = lancedb.connect(dataset_dir / Dataset._DB_PATH)
    item_table = db.open_table(SchemaGroup.ITEM.value)
    num_items = item_table.count_rows()
    return DatasetInfoModel(
        num_items=num_items,
        **dataset_info.model_dump(),
    )