bioimageio.spec.application.v0_3

 1from typing import TYPE_CHECKING, ClassVar, Literal, Optional
 2
 3from pydantic import Field
 4from typing_extensions import Annotated
 5
 6from .._internal.io import FileDescr as FileDescr
 7from .._internal.io_basics import Sha256 as Sha256
 8from .._internal.types import FileSource_
 9from .._internal.url import HttpUrl as HttpUrl
10from ..generic.v0_3 import VALID_COVER_IMAGE_EXTENSIONS as VALID_COVER_IMAGE_EXTENSIONS
11from ..generic.v0_3 import Author as Author
12from ..generic.v0_3 import BadgeDescr as BadgeDescr
13from ..generic.v0_3 import BioimageioConfig as BioimageioConfig
14from ..generic.v0_3 import CiteEntry as CiteEntry
15from ..generic.v0_3 import Config as Config
16from ..generic.v0_3 import DeprecatedLicenseId as DeprecatedLicenseId
17from ..generic.v0_3 import Doi as Doi
18from ..generic.v0_3 import GenericDescrBase, LinkedResourceBase, ResourceId
19from ..generic.v0_3 import LicenseId as LicenseId
20from ..generic.v0_3 import LinkedResource as LinkedResource
21from ..generic.v0_3 import Maintainer as Maintainer
22from ..generic.v0_3 import OrcidId as OrcidId
23from ..generic.v0_3 import RelativeFilePath as RelativeFilePath
24from ..generic.v0_3 import Uploader as Uploader
25from ..generic.v0_3 import Version as Version
26
27
28class ApplicationId(ResourceId):
29    pass
30
31
32class ApplicationDescr(GenericDescrBase):
33    """Bioimage.io description of an application."""
34
35    implemented_type: ClassVar[Literal["application"]] = "application"
36    if TYPE_CHECKING:
37        type: Literal["application"] = "application"
38    else:
39        type: Literal["application"]
40
41    id: Optional[ApplicationId] = None
42    """bioimage.io-wide unique resource identifier
43    assigned by bioimage.io; version **un**specific."""
44
45    parent: Optional[ApplicationId] = None
46    """The description from which this one is derived"""
47
48    source: Annotated[
49        Optional[FileSource_],
50        Field(description="URL or path to the source of the application"),
51    ] = None
52    """The primary source of the application"""
53
54
55class LinkedApplication(LinkedResourceBase):
56    """Reference to a bioimage.io application."""
57
58    id: ApplicationId
59    """A valid application `id` from the bioimage.io collection."""
class ApplicationId(bioimageio.spec.generic.v0_3.ResourceId):
29class ApplicationId(ResourceId):
30    pass

str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.

class ApplicationDescr(bioimageio.spec.generic.v0_3.GenericDescrBase):
33class ApplicationDescr(GenericDescrBase):
34    """Bioimage.io description of an application."""
35
36    implemented_type: ClassVar[Literal["application"]] = "application"
37    if TYPE_CHECKING:
38        type: Literal["application"] = "application"
39    else:
40        type: Literal["application"]
41
42    id: Optional[ApplicationId] = None
43    """bioimage.io-wide unique resource identifier
44    assigned by bioimage.io; version **un**specific."""
45
46    parent: Optional[ApplicationId] = None
47    """The description from which this one is derived"""
48
49    source: Annotated[
50        Optional[FileSource_],
51        Field(description="URL or path to the source of the application"),
52    ] = None
53    """The primary source of the application"""

Bioimage.io description of an application.

implemented_type: ClassVar[Literal['application']] = 'application'
id: Optional[ApplicationId]

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

parent: Optional[ApplicationId]

The description from which this one is derived

source: Annotated[Optional[Annotated[Union[bioimageio.spec._internal.url.HttpUrl, bioimageio.spec._internal.io.RelativeFilePath, Annotated[pathlib.Path, PathType(path_type='file'), FieldInfo(annotation=NoneType, required=True, title='FilePath')]], FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')]), AfterValidator(func=<function wo_special_file_name at 0x7f1ae293f880>), PlainSerializer(func=<function _package_serializer at 0x7f1ae263d800>, return_type=PydanticUndefined, when_used='unless-none')]], FieldInfo(annotation=NoneType, required=True, description='URL or path to the source of the application')]

The primary source of the application

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.
class LinkedApplication(bioimageio.spec.generic.v0_3.LinkedResourceBase):
56class LinkedApplication(LinkedResourceBase):
57    """Reference to a bioimage.io application."""
58
59    id: ApplicationId
60    """A valid application `id` from the bioimage.io collection."""

Reference to a bioimage.io application.

A valid application id from the bioimage.io collection.

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].