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
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[DatasetDescr_v0_2, DatasetDescr_v0_3], Discriminator("format_version")
21]
22"""Union of any released dataset desription"""
23# autogen: stop
class DatasetDescr(bioimageio.spec.generic.v0_3.GenericDescrBase):
 39class DatasetDescr(GenericDescrBase, title="bioimage.io dataset specification"):
 40    """A bioimage.io dataset resource description file (dataset RDF) describes a dataset relevant to bioimage
 41    processing.
 42    """
 43
 44    type: Literal["dataset"] = "dataset"
 45
 46    id: Optional[DatasetId] = None
 47    """bioimage.io-wide unique resource identifier
 48    assigned by bioimage.io; version **un**specific."""
 49
 50    parent: Optional[DatasetId] = None
 51    """The description from which this one is derived"""
 52
 53    source: Optional[HttpUrl] = None
 54    """"URL to the source of the dataset."""
 55
 56    @model_validator(mode="before")
 57    @classmethod
 58    def _convert(cls, data: Dict[str, Any], /) -> Dict[str, Any]:
 59        if (
 60            data.get("type") == "dataset"
 61            and isinstance(fv := data.get("format_version"), str)
 62            and fv.startswith("0.2.")
 63        ):
 64            old = DatasetDescr02.load(data)
 65            if isinstance(old, InvalidDescr):
 66                return data
 67
 68            return cast(
 69                Dict[str, Any],
 70                (cls if TYPE_CHECKING else dict)(
 71                    attachments=(
 72                        []
 73                        if old.attachments is None
 74                        else [FileDescr(source=f) for f in old.attachments.files]
 75                    ),
 76                    authors=[
 77                        _author_conv.convert_as_dict(a) for a in old.authors
 78                    ],  # pyright: ignore[reportArgumentType]
 79                    badges=old.badges,
 80                    cite=[
 81                        {"text": c.text, "doi": c.doi, "url": c.url} for c in old.cite
 82                    ],  # pyright: ignore[reportArgumentType]
 83                    config=old.config,
 84                    covers=old.covers,
 85                    description=old.description,
 86                    documentation=cast(DocumentationSource, old.documentation),
 87                    format_version="0.3.0",
 88                    git_repo=old.git_repo,  # pyright: ignore[reportArgumentType]
 89                    icon=old.icon,
 90                    id=None if old.id is None else DatasetId(old.id),
 91                    license=old.license,  # type: ignore
 92                    links=old.links,
 93                    maintainers=[
 94                        _maintainer_conv.convert_as_dict(m) for m in old.maintainers
 95                    ],  # pyright: ignore[reportArgumentType]
 96                    name=old.name,
 97                    source=old.source,
 98                    tags=old.tags,
 99                    type=old.type,
100                    uploader=old.uploader,
101                    version=old.version,
102                    **(old.model_extra or {}),
103                ),
104            )
105
106        return data

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

type: Literal['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: ClassVar[str] = '0.3.0'
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[bioimageio.spec.dataset.v0_2.DatasetDescr, DatasetDescr], Discriminator(discriminator='format_version', custom_error_type=None, custom_error_message=None, custom_error_context=None)]

Union of any released dataset desription