bioimageio.spec.application.v0_2

 1from typing import TYPE_CHECKING, ClassVar, Literal, Optional
 2
 3from pydantic import Field
 4from typing_extensions import Annotated
 5
 6from .._internal.common_nodes import Node
 7from .._internal.types import FileSource_ as FileSource_
 8from .._internal.url import HttpUrl as HttpUrl
 9from ..generic.v0_2 import VALID_COVER_IMAGE_EXTENSIONS as VALID_COVER_IMAGE_EXTENSIONS
10from ..generic.v0_2 import AttachmentsDescr as AttachmentsDescr
11from ..generic.v0_2 import Author as Author
12from ..generic.v0_2 import BadgeDescr as BadgeDescr
13from ..generic.v0_2 import CiteEntry as CiteEntry
14from ..generic.v0_2 import Doi as Doi
15from ..generic.v0_2 import GenericDescrBase
16from ..generic.v0_2 import LinkedResource as LinkedResource
17from ..generic.v0_2 import Maintainer as Maintainer
18from ..generic.v0_2 import OrcidId as OrcidId
19from ..generic.v0_2 import RelativeFilePath as RelativeFilePath
20from ..generic.v0_2 import ResourceId as ResourceId
21from ..generic.v0_2 import Uploader as Uploader
22from ..generic.v0_2 import Version as Version
23
24
25class ApplicationId(ResourceId):
26    pass
27
28
29class ApplicationDescr(GenericDescrBase):
30    """Bioimage.io description of an application."""
31
32    implemented_type: ClassVar[Literal["application"]] = "application"
33    if TYPE_CHECKING:
34        type: Literal["application"] = "application"
35    else:
36        type: Literal["application"]
37
38    id: Optional[ApplicationId] = None
39    """bioimage.io-wide unique resource identifier
40    assigned by bioimage.io; version **un**specific."""
41
42    source: Annotated[
43        Optional[FileSource_],
44        Field(description="URL or path to the source of the application"),
45    ] = None
46    """The primary source of the application"""
47
48
49class LinkedApplication(Node):
50    """Reference to a bioimage.io application."""
51
52    id: ApplicationId
53    """A valid application `id` from the bioimage.io collection."""
54
55    version_number: Optional[int] = None
56    """version number (n-th published version, not the semantic version) of linked application"""
class ApplicationId(bioimageio.spec.generic.v0_2.ResourceId):
26class ApplicationId(ResourceId):
27    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_2.GenericDescrBase):
30class ApplicationDescr(GenericDescrBase):
31    """Bioimage.io description of an application."""
32
33    implemented_type: ClassVar[Literal["application"]] = "application"
34    if TYPE_CHECKING:
35        type: Literal["application"] = "application"
36    else:
37        type: Literal["application"]
38
39    id: Optional[ApplicationId] = None
40    """bioimage.io-wide unique resource identifier
41    assigned by bioimage.io; version **un**specific."""
42
43    source: Annotated[
44        Optional[FileSource_],
45        Field(description="URL or path to the source of the application"),
46    ] = None
47    """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.

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 0x7febd4d13c40>), PlainSerializer(func=<function _package_serializer at 0x7febd4daec00>, 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, 2, 4)
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._internal.node.Node):
50class LinkedApplication(Node):
51    """Reference to a bioimage.io application."""
52
53    id: ApplicationId
54    """A valid application `id` from the bioimage.io collection."""
55
56    version_number: Optional[int] = None
57    """version number (n-th published version, not the semantic version) of linked application"""

Reference to a bioimage.io application.

A valid application id from the bioimage.io collection.

version_number: Optional[int]

version number (n-th published version, not the semantic version) of linked application

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