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):
 41class DatasetDescr(GenericDescrBase):
 42    """A bioimage.io dataset resource description file (dataset RDF) describes a dataset relevant to bioimage
 43    processing.
 44    """
 45
 46    implemented_type: ClassVar[Literal["dataset"]] = "dataset"
 47    if TYPE_CHECKING:
 48        type: Literal["dataset"] = "dataset"
 49    else:
 50        type: Literal["dataset"]
 51
 52    id: Optional[DatasetId] = None
 53    """bioimage.io-wide unique resource identifier
 54    assigned by bioimage.io; version **un**specific."""
 55
 56    parent: Optional[DatasetId] = None
 57    """The description from which this one is derived"""
 58
 59    source: Optional[HttpUrl] = None
 60    """"URL to the source of the dataset."""
 61
 62    @model_validator(mode="before")
 63    @classmethod
 64    def _convert(cls, data: Dict[str, Any], /) -> Dict[str, Any]:
 65        if (
 66            data.get("type") == "dataset"
 67            and isinstance(fv := data.get("format_version"), str)
 68            and fv.startswith("0.2.")
 69        ):
 70            old = DatasetDescr02.load(data)
 71            if isinstance(old, InvalidDescr):
 72                return data
 73
 74            return cast(
 75                Dict[str, Any],
 76                (cls if TYPE_CHECKING else dict)(
 77                    attachments=(
 78                        []
 79                        if old.attachments is None
 80                        else [FileDescr(source=f) for f in old.attachments.files]
 81                    ),
 82                    authors=[
 83                        _author_conv.convert_as_dict(a) for a in old.authors
 84                    ],  # pyright: ignore[reportArgumentType]
 85                    badges=old.badges,
 86                    cite=[
 87                        {"text": c.text, "doi": c.doi, "url": c.url} for c in old.cite
 88                    ],  # pyright: ignore[reportArgumentType]
 89                    config=old.config,  # pyright: ignore[reportArgumentType]
 90                    covers=old.covers,
 91                    description=old.description,
 92                    documentation=cast(DocumentationSource, old.documentation),
 93                    format_version="0.3.0",
 94                    git_repo=old.git_repo,  # pyright: ignore[reportArgumentType]
 95                    icon=old.icon,
 96                    id=None if old.id is None else DatasetId(old.id),
 97                    license=old.license,  # type: ignore
 98                    links=old.links,
 99                    maintainers=[
100                        _maintainer_conv.convert_as_dict(m) for m in old.maintainers
101                    ],  # pyright: ignore[reportArgumentType]
102                    name=old.name,
103                    source=old.source,
104                    tags=old.tags,
105                    type=old.type,
106                    uploader=old.uploader,
107                    version=old.version,
108                    **(old.model_extra or {}),
109                ),
110            )
111
112        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)
def model_post_init(self: pydantic.main.BaseModel, context: Any, /) -> None:
124                    def wrapped_model_post_init(self: BaseModel, context: Any, /) -> None:
125                        """We need to both initialize private attributes and call the user-defined model_post_init
126                        method.
127                        """
128                        init_private_attributes(self, context)
129                        original_model_post_init(self, context)

We need to both initialize private attributes and call the user-defined model_post_init method.

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