bioimageio.spec.dataset

implementaions of all released minor versions are available in submodules:

 1# autogen: start
 2"""
 3implementaions of all released minor versions are available in submodules:
 4- dataset v0_2: `bioimageio.spec.dataset.v0_2.DatasetDescr`
 5- dataset v0_3: `bioimageio.spec.dataset.v0_3.DatasetDescr`
 6"""
 7
 8from typing import Union
 9
10from pydantic import Discriminator, Field
11from typing_extensions import Annotated
12
13from . import v0_2, v0_3
14
15DatasetDescr = v0_3.DatasetDescr
16DatasetDescr_v0_2 = v0_2.DatasetDescr
17DatasetDescr_v0_3 = v0_3.DatasetDescr
18
19AnyDatasetDescr = Annotated[
20    Union[
21        Annotated[DatasetDescr_v0_2, Field(title="dataset 0.2")],
22        Annotated[DatasetDescr_v0_3, Field(title="dataset 0.3")],
23    ],
24    Discriminator("format_version"),
25    Field(title="dataset"),
26]
27"""Union of any released dataset desription"""
28# autogen: stop
class DatasetDescr(bioimageio.spec.generic.v0_3.GenericDescrBase):
 39class DatasetDescr(GenericDescrBase):
 40    """A bioimage.io dataset resource description file (dataset RDF) describes a dataset relevant to bioimage
 41    processing.
 42    """
 43
 44    implemented_type: ClassVar[Literal["dataset"]] = "dataset"
 45    if TYPE_CHECKING:
 46        type: Literal["dataset"] = "dataset"
 47    else:
 48        type: Literal["dataset"]
 49
 50    id: Optional[DatasetId] = None
 51    """bioimage.io-wide unique resource identifier
 52    assigned by bioimage.io; version **un**specific."""
 53
 54    parent: Optional[DatasetId] = None
 55    """The description from which this one is derived"""
 56
 57    source: Optional[HttpUrl] = None
 58    """"URL to the source of the dataset."""
 59
 60    @model_validator(mode="before")
 61    @classmethod
 62    def _convert(cls, data: Dict[str, Any], /) -> Dict[str, Any]:
 63        if (
 64            data.get("type") == "dataset"
 65            and isinstance(fv := data.get("format_version"), str)
 66            and fv.startswith("0.2.")
 67        ):
 68            old = DatasetDescr02.load(data)
 69            if isinstance(old, InvalidDescr):
 70                return data
 71
 72            return cast(
 73                Dict[str, Any],
 74                (cls if TYPE_CHECKING else dict)(
 75                    attachments=(
 76                        []
 77                        if old.attachments is None
 78                        else [FileDescr(source=f) for f in old.attachments.files]
 79                    ),
 80                    authors=[
 81                        _author_conv.convert_as_dict(a) for a in old.authors
 82                    ],  # pyright: ignore[reportArgumentType]
 83                    badges=old.badges,
 84                    cite=[
 85                        {"text": c.text, "doi": c.doi, "url": c.url} for c in old.cite
 86                    ],  # pyright: ignore[reportArgumentType]
 87                    config=old.config,  # pyright: ignore[reportArgumentType]
 88                    covers=old.covers,
 89                    description=old.description,
 90                    documentation=old.documentation,
 91                    format_version="0.3.0",
 92                    git_repo=old.git_repo,  # pyright: ignore[reportArgumentType]
 93                    icon=old.icon,
 94                    id=None if old.id is None else DatasetId(old.id),
 95                    license=old.license,  # type: ignore
 96                    links=old.links,
 97                    maintainers=[
 98                        _maintainer_conv.convert_as_dict(m) for m in old.maintainers
 99                    ],  # pyright: ignore[reportArgumentType]
100                    name=old.name,
101                    source=old.source,
102                    tags=old.tags,
103                    type=old.type,
104                    uploader=old.uploader,
105                    version=old.version,
106                    **(old.model_extra or {}),
107                ),
108            )
109
110        return data

A bioimage.io dataset resource description file (dataset RDF) describes a dataset relevant to bioimage processing.

implemented_type: ClassVar[Literal['dataset']] = 'dataset'

bioimage.io-wide unique resource identifier assigned by bioimage.io; version unspecific.

The description from which this one is derived

source: Optional[bioimageio.spec._internal.url.HttpUrl]

"URL to the source of the dataset.

implemented_format_version_tuple: ClassVar[Tuple[int, int, int]] = (0, 3, 0)
model_config: ClassVar[pydantic.config.ConfigDict] = {'extra': 'forbid', 'frozen': False, 'populate_by_name': True, 'revalidate_instances': 'never', 'validate_assignment': True, 'validate_default': False, 'validate_return': True, 'use_attribute_docstrings': True, 'model_title_generator': <function _node_title_generator>, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

def model_post_init(self: pydantic.main.BaseModel, context: Any, /) -> None:
337def init_private_attributes(self: BaseModel, context: Any, /) -> None:
338    """This function is meant to behave like a BaseModel method to initialise private attributes.
339
340    It takes context as an argument since that's what pydantic-core passes when calling it.
341
342    Args:
343        self: The BaseModel instance.
344        context: The context.
345    """
346    if getattr(self, '__pydantic_private__', None) is None:
347        pydantic_private = {}
348        for name, private_attr in self.__private_attributes__.items():
349            default = private_attr.get_default()
350            if default is not PydanticUndefined:
351                pydantic_private[name] = default
352        object_setattr(self, '__pydantic_private__', pydantic_private)

This function is meant to behave like a BaseModel method to initialise private attributes.

It takes context as an argument since that's what pydantic-core passes when calling it.

Arguments:
  • self: The BaseModel instance.
  • context: The context.
DatasetDescr_v0_2 = <class 'bioimageio.spec.dataset.v0_2.DatasetDescr'>
DatasetDescr_v0_3 = <class 'DatasetDescr'>
AnyDatasetDescr = typing.Annotated[typing.Union[typing.Annotated[bioimageio.spec.dataset.v0_2.DatasetDescr, FieldInfo(annotation=NoneType, required=True, title='dataset 0.2')], typing.Annotated[DatasetDescr, FieldInfo(annotation=NoneType, required=True, title='dataset 0.3')]], Discriminator(discriminator='format_version', custom_error_type=None, custom_error_message=None, custom_error_context=None), FieldInfo(annotation=NoneType, required=True, title='dataset')]

Union of any released dataset desription