Coverage for src/bioimageio/spec/notebook/v0_2.py: 100%
37 statements
« prev ^ index » next coverage.py v7.15.4, created at 2026-08-18 09:17 +0000
« prev ^ index » next coverage.py v7.15.4, created at 2026-08-18 09:17 +0000
1from __future__ import annotations
3from typing import TYPE_CHECKING, ClassVar, Literal, Union
5from typing_extensions import Annotated
7from .._internal.common_nodes import Node
8from .._internal.io import WithSuffix
9from .._internal.types import FilePath
10from .._internal.url import HttpUrl
11from ..generic.v0_2 import VALID_COVER_IMAGE_EXTENSIONS as VALID_COVER_IMAGE_EXTENSIONS
12from ..generic.v0_2 import AttachmentsDescr as AttachmentsDescr
13from ..generic.v0_2 import Author as Author
14from ..generic.v0_2 import BadgeDescr as BadgeDescr
15from ..generic.v0_2 import CiteEntry as CiteEntry
16from ..generic.v0_2 import Doi as Doi
17from ..generic.v0_2 import GenericDescrBase
18from ..generic.v0_2 import LinkedResource as LinkedResource
19from ..generic.v0_2 import Maintainer as Maintainer
20from ..generic.v0_2 import OrcidId as OrcidId
21from ..generic.v0_2 import RelativeFilePath as RelativeFilePath
22from ..generic.v0_2 import ResourceId as ResourceId
23from ..generic.v0_2 import Uploader as Uploader
24from ..generic.v0_2 import Version as Version
27class NotebookId(ResourceId):
28 pass
31_WithNotebookSuffix = WithSuffix(".ipynb", case_sensitive=True)
32NotebookSource = Union[
33 Annotated[HttpUrl, _WithNotebookSuffix],
34 Annotated[FilePath, _WithNotebookSuffix],
35 Annotated[RelativeFilePath, _WithNotebookSuffix],
36]
39class NotebookDescr(GenericDescrBase):
40 """Bioimage.io description of a Jupyter Notebook."""
42 implemented_type: ClassVar[Literal["notebook"]] = "notebook"
43 if TYPE_CHECKING:
44 type: Literal["notebook"] = "notebook"
45 else:
46 type: Literal["notebook"]
48 id: NotebookId | None = None
49 """bioimage.io-wide unique resource identifier
50 assigned by bioimage.io; version **un**specific."""
52 source: NotebookSource
53 """The Jupyter notebook"""
56class LinkedNotebook(Node):
57 """Reference to a bioimage.io notebook."""
59 id: NotebookId
60 """A valid notebook `id` from the bioimage.io collection."""
62 version_number: int | None = None
63 """version number (n-th published version, not the semantic version) of linked notebook"""