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

1from __future__ import annotations 

2 

3from typing import TYPE_CHECKING, ClassVar, Literal, Union 

4 

5from typing_extensions import Annotated 

6 

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 

25 

26 

27class NotebookId(ResourceId): 

28 pass 

29 

30 

31_WithNotebookSuffix = WithSuffix(".ipynb", case_sensitive=True) 

32NotebookSource = Union[ 

33 Annotated[HttpUrl, _WithNotebookSuffix], 

34 Annotated[FilePath, _WithNotebookSuffix], 

35 Annotated[RelativeFilePath, _WithNotebookSuffix], 

36] 

37 

38 

39class NotebookDescr(GenericDescrBase): 

40 """Bioimage.io description of a Jupyter Notebook.""" 

41 

42 implemented_type: ClassVar[Literal["notebook"]] = "notebook" 

43 if TYPE_CHECKING: 

44 type: Literal["notebook"] = "notebook" 

45 else: 

46 type: Literal["notebook"] 

47 

48 id: NotebookId | None = None 

49 """bioimage.io-wide unique resource identifier 

50 assigned by bioimage.io; version **un**specific.""" 

51 

52 source: NotebookSource 

53 """The Jupyter notebook""" 

54 

55 

56class LinkedNotebook(Node): 

57 """Reference to a bioimage.io notebook.""" 

58 

59 id: NotebookId 

60 """A valid notebook `id` from the bioimage.io collection.""" 

61 

62 version_number: int | None = None 

63 """version number (n-th published version, not the semantic version) of linked notebook"""