common
¤
Common nodes and field types of bioimage.io specifications.
Classes:
| Name | Description |
|---|---|
BytesReader |
|
FileDescr |
A file description |
HttpUrl |
A URL with the HTTP or HTTPS scheme. |
InvalidDescr |
A representation of an invalid resource description |
RelativeFilePath |
A path relative to the |
RootHttpUrl |
An untested HTTP URL, possibly a 'URL folder' or an invalid HTTP URL |
Sha256 |
A SHA-256 hash value |
Attributes:
| Name | Type | Description |
|---|---|---|
AbsoluteDirectory |
|
|
AbsoluteFilePath |
|
|
BioimageioYamlContent |
|
|
BioimageioYamlSource |
|
|
FileName |
|
|
FilePath |
|
|
FileSource |
|
|
PermissiveFileSource |
|
|
YamlValue |
|
|
ZipPath |
|
AbsoluteDirectory
module-attribute
¤
AbsoluteDirectory = Annotated[
pydantic.DirectoryPath,
Predicate(Path.is_absolute),
pydantic.Field(title="AbsoluteDirectory"),
]
-
API Reference
commonBytesReader
AbsoluteFilePath
module-attribute
¤
AbsoluteFilePath = Annotated[
pydantic.FilePath,
Predicate(Path.is_absolute),
pydantic.Field(title="AbsoluteFilePath"),
]
-
API Reference
specget_resource_package_content
BioimageioYamlContent
module-attribute
¤
BioimageioYamlContent = Dict[str, YamlValue]
-
API Reference
spec
BioimageioYamlSource
module-attribute
¤
BioimageioYamlSource = Union[
PermissiveFileSource,
ZipFile,
BioimageioYamlContent,
BioimageioYamlContentView,
]
FilePath
module-attribute
¤
-
v0_2NotebookSource -
v0_3NotebookSource -
API Reference
commonFileSource
FileSource
module-attribute
¤
FileSource = Annotated[
Union[HttpUrl, RelativeFilePath, FilePath],
Field(union_mode="left_to_right"),
]
-
API Reference
utilsinterprete_file_source
-
v0_2FileSource_ - API Reference
PermissiveFileSource
module-attribute
¤
PermissiveFileSource = Union[
FileSource, str, pydantic.HttpUrl
]
YamlValue
module-attribute
¤
YamlValue = Union[
YamlLeafValue,
List["YamlValue"],
Dict[YamlKey, "YamlValue"],
]
-
v0_5BioimageioYamlContent - API Reference
ZipPath
module-attribute
¤
ZipPath = zipp.Path
-
API Reference
specget_resource_package_content
BytesReader
¤
BytesReader(
reader: Union[BytesReaderP, BytesReaderIntoP],
*,
sha256: Optional[Sha256],
suffix: Suffix,
original_file_name: FileName,
original_root: Union[
RootHttpUrl, AbsoluteDirectory, ZipFile
],
is_zipfile: Optional[bool],
)
Bases: BytesReaderP
flowchart TD
bioimageio.spec.common.BytesReader[BytesReader]
bioimageio.spec._internal.io_basics.BytesReaderP[BytesReaderP]
bioimageio.spec._internal.io_basics.BytesReaderP --> bioimageio.spec.common.BytesReader
click bioimageio.spec.common.BytesReader href "" "bioimageio.spec.common.BytesReader"
click bioimageio.spec._internal.io_basics.BytesReaderP href "" "bioimageio.spec._internal.io_basics.BytesReaderP"
-
API Reference
utilsget_reader
Methods:
| Name | Description |
|---|---|
read |
|
read_text |
|
readable |
|
seek |
|
seekable |
|
tell |
|
Attributes:
| Name | Type | Description |
|---|---|---|
closed |
bool
|
|
is_zipfile |
bool
|
|
original_file_name |
FileName
|
|
original_root |
Union[RootHttpUrl, AbsoluteDirectory, ZipFile]
|
|
sha256 |
Sha256
|
|
suffix |
Suffix
|
|
Source code in src/bioimageio/spec/_internal/io_basics.py
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | |
read
¤
read(size: int = -1) -> bytes
Source code in src/bioimageio/spec/_internal/io_basics.py
126 127 | |
read_text
¤
read_text(encoding: str = 'utf-8') -> str
Source code in src/bioimageio/spec/_internal/io_basics.py
129 130 | |
readable
¤
readable() -> bool
Source code in src/bioimageio/spec/_internal/io_basics.py
132 133 | |
seek
¤
seek(offset: int, whence: int = os.SEEK_SET) -> int
Source code in src/bioimageio/spec/_internal/io_basics.py
135 136 | |
seekable
¤
seekable() -> bool
Source code in src/bioimageio/spec/_internal/io_basics.py
138 139 | |
tell
¤
tell() -> int
Source code in src/bioimageio/spec/_internal/io_basics.py
141 142 | |
FileDescr
pydantic-model
¤
Bases: Node
A file description
Show JSON schema:
{
"$defs": {
"RelativeFilePath": {
"description": "A path relative to the `rdf.yaml` file (also if the RDF source is a URL).",
"format": "path",
"title": "RelativeFilePath",
"type": "string"
}
},
"additionalProperties": false,
"description": "A file description",
"properties": {
"source": {
"anyOf": [
{
"description": "A URL with the HTTP or HTTPS scheme.",
"format": "uri",
"maxLength": 2083,
"minLength": 1,
"title": "HttpUrl",
"type": "string"
},
{
"$ref": "#/$defs/RelativeFilePath"
},
{
"format": "file-path",
"title": "FilePath",
"type": "string"
}
],
"description": "File source",
"title": "Source"
},
"sha256": {
"anyOf": [
{
"description": "A SHA-256 hash value",
"maxLength": 64,
"minLength": 64,
"title": "Sha256",
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "SHA256 hash value of the **source** file.",
"title": "Sha256"
}
},
"required": [
"source"
],
"title": "_internal.io.FileDescr",
"type": "object"
}
Fields:
-
source(FileSource) -
sha256(Optional[Sha256])
dict_from_kwargs
classmethod
¤
dict_from_kwargs(
*args: P.args, **kwargs: P.kwargs
) -> Dict[str, Any]
Source code in src/bioimageio/spec/_internal/node.py
95 96 97 98 99 100 | |
download
¤
download(
*,
progressbar: Union[
Progressbar, Callable[[], Progressbar], bool, None
] = None,
)
alias for .get_reader
Source code in src/bioimageio/spec/_internal/io.py
316 317 318 319 320 321 322 | |
get_reader
¤
get_reader(
*,
progressbar: Union[
Progressbar, Callable[[], Progressbar], bool, None
] = None,
)
open the file source (download if needed)
Source code in src/bioimageio/spec/_internal/io.py
308 309 310 311 312 313 314 | |
model_validate
classmethod
¤
model_validate(
obj: Union[Any, Mapping[str, Any]],
*,
strict: Optional[bool] = None,
extra: Optional[
Literal["allow", "ignore", "forbid"]
] = None,
from_attributes: Optional[bool] = None,
context: Union[
ValidationContext, Mapping[str, Any], None
] = None,
by_alias: Optional[bool] = None,
by_name: Optional[bool] = None,
) -> Self
Validate a pydantic model instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Union[Any, Mapping[str, Any]]
|
The object to validate. |
required |
|
Optional[bool]
|
Whether to raise an exception on invalid fields. |
None
|
|
Optional[bool]
|
Whether to extract data from object attributes. |
None
|
|
Union[ValidationContext, Mapping[str, Any], None]
|
Additional context to pass to the validator. |
None
|
Raises:
| Type | Description |
|---|---|
ValidationError
|
If the object failed validation. |
Returns:
| Type | Description |
|---|---|
Self
|
The validated description instance. |
Source code in src/bioimageio/spec/_internal/node.py
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | |
validate_sha256
¤
validate_sha256(force_recompute: bool = False) -> None
validate the sha256 hash value of the source file
Source code in src/bioimageio/spec/_internal/io.py
274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 | |
HttpUrl
¤
Bases: RootHttpUrl
flowchart TD
bioimageio.spec.common.HttpUrl[HttpUrl]
bioimageio.spec._internal.root_url.RootHttpUrl[RootHttpUrl]
bioimageio.spec._internal.validated_string.ValidatedString[ValidatedString]
bioimageio.spec._internal.root_url.RootHttpUrl --> bioimageio.spec.common.HttpUrl
bioimageio.spec._internal.validated_string.ValidatedString --> bioimageio.spec._internal.root_url.RootHttpUrl
click bioimageio.spec.common.HttpUrl href "" "bioimageio.spec.common.HttpUrl"
click bioimageio.spec._internal.root_url.RootHttpUrl href "" "bioimageio.spec._internal.root_url.RootHttpUrl"
click bioimageio.spec._internal.validated_string.ValidatedString href "" "bioimageio.spec._internal.validated_string.ValidatedString"
A URL with the HTTP or HTTPS scheme.
-
API Reference
spec
-
v0_2RelativeFilePath -
v0_2RelativeFilePath -
v0_2RelativeFilePath -
v0_2RelativeFilePath -
v0_3RelativeFilePath -
v0_3RelativeFilePath -
v0_3RelativeFilePath -
v0_3RelativeFilePath -
v0_4RelativeFilePath -
v0_5RelativeFilePath -
API Reference
commonRelativeFilePath
-
v0_2NotebookSource -
v0_3NotebookSource -
API Reference
commonFileSource
Methods:
| Name | Description |
|---|---|
__get_pydantic_core_schema__ |
|
__get_pydantic_json_schema__ |
|
__new__ |
|
absolute |
analog to |
exists |
True if URL is available |
Attributes:
| Name | Type | Description |
|---|---|---|
host |
Optional[str]
|
|
parent |
RootHttpUrl
|
|
parents |
Iterable[RootHttpUrl]
|
iterate over all URL parents (max 100) |
path |
Optional[str]
|
|
root_model |
Type[RootModel[Any]]
|
the pydantic root model to validate the string |
scheme |
str
|
|
suffix |
str
|
|
root_model
class-attribute
¤
the pydantic root model to validate the string
__get_pydantic_core_schema__
classmethod
¤
__get_pydantic_core_schema__(
source_type: Any, handler: GetCoreSchemaHandler
) -> CoreSchema
Source code in src/bioimageio/spec/_internal/validated_string.py
29 30 31 32 33 | |
__get_pydantic_json_schema__
classmethod
¤
__get_pydantic_json_schema__(
core_schema: CoreSchema, handler: GetJsonSchemaHandler
) -> JsonSchemaValue
Source code in src/bioimageio/spec/_internal/validated_string.py
35 36 37 38 39 40 41 42 43 44 | |
__new__
¤
__new__(object: object)
Source code in src/bioimageio/spec/_internal/validated_string.py
19 20 21 22 23 | |
absolute
¤
absolute()
analog to absolute method of pathlib.
Source code in src/bioimageio/spec/_internal/root_url.py
18 19 20 | |
exists
¤
exists()
True if URL is available
Source code in src/bioimageio/spec/_internal/url.py
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 | |
InvalidDescr
pydantic-model
¤
Bases: ResourceDescrBase
A representation of an invalid resource description
Show JSON schema:
{
"additionalProperties": true,
"description": "A representation of an invalid resource description",
"properties": {
"type": {
"title": "Type"
},
"format_version": {
"title": "Format Version"
}
},
"required": [
"type",
"format_version"
],
"title": "An invalid resource description",
"type": "object"
}
Fields:
-
_validation_summary(Optional[ValidationSummary]) -
type(Any) -
format_version(Any)
file_name
property
¤
file_name: Optional[FileName]
File name of the bioimageio.yaml file the description was loaded from.
implemented_format_version
class-attribute
¤
implemented_format_version: Literal['unknown'] = 'unknown'
implemented_format_version_tuple
class-attribute
¤
implemented_format_version_tuple: Tuple[int, int, int]
root
property
¤
root: Union[RootHttpUrl, DirectoryPath, ZipFile]
The URL/Path prefix to resolve any relative paths with.
__pydantic_init_subclass__
classmethod
¤
__pydantic_init_subclass__(**kwargs: Any)
Source code in src/bioimageio/spec/_internal/common_nodes.py
207 208 209 210 211 212 213 214 215 216 217 218 219 | |
dict_from_kwargs
classmethod
¤
dict_from_kwargs(
*args: P.args, **kwargs: P.kwargs
) -> Dict[str, Any]
Source code in src/bioimageio/spec/_internal/node.py
95 96 97 98 99 100 | |
get_package_content
¤
get_package_content() -> Dict[
FileName, Union[FileDescr, BioimageioYamlContent]
]
Returns package content without creating the package.
Source code in src/bioimageio/spec/_internal/common_nodes.py
397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 | |
get_reason
¤
get_reason() -> Optional[str]
Get the reason why the description is invalid, if available.
Source code in src/bioimageio/spec/_internal/common_nodes.py
434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 | |
load
classmethod
¤
load(
data: IncompleteDescrView,
context: Optional[ValidationContext] = None,
) -> Union[Self, InvalidDescr]
factory method to create a resource description object
Source code in src/bioimageio/spec/_internal/common_nodes.py
232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 | |
load_from_kwargs
classmethod
¤
load_from_kwargs(
context: Optional[ValidationContext] = None,
*args: P.args,
**kwargs: P.kwargs,
) -> Union[T, InvalidDescr]
Source code in src/bioimageio/spec/_internal/common_nodes.py
221 222 223 224 225 226 227 228 229 230 | |
model_validate
classmethod
¤
model_validate(
obj: Union[Any, Mapping[str, Any]],
*,
strict: Optional[bool] = None,
extra: Optional[
Literal["allow", "ignore", "forbid"]
] = None,
from_attributes: Optional[bool] = None,
context: Union[
ValidationContext, Mapping[str, Any], None
] = None,
by_alias: Optional[bool] = None,
by_name: Optional[bool] = None,
) -> Self
Validate a pydantic model instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Union[Any, Mapping[str, Any]]
|
The object to validate. |
required |
|
Optional[bool]
|
Whether to raise an exception on invalid fields. |
None
|
|
Optional[bool]
|
Whether to extract data from object attributes. |
None
|
|
Union[ValidationContext, Mapping[str, Any], None]
|
Additional context to pass to the validator. |
None
|
Raises:
| Type | Description |
|---|---|
ValidationError
|
If the object failed validation. |
Returns:
| Type | Description |
|---|---|
Self
|
The validated description instance. |
Source code in src/bioimageio/spec/_internal/node.py
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | |
package
¤
package(
dest: Optional[
Union[ZipFile, IO[bytes], Path, str]
] = None,
) -> ZipFile
package the described resource as a zip archive
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Optional[Union[ZipFile, IO[bytes], Path, str]]
|
(path/bytes stream of) destination zipfile |
None
|
Source code in src/bioimageio/spec/_internal/common_nodes.py
367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 | |
RelativeFilePath
¤
Bases: RelativePathBase[Union[AbsoluteFilePath, HttpUrl, ZipPath]]
flowchart TD
bioimageio.spec.common.RelativeFilePath[RelativeFilePath]
bioimageio.spec._internal.io.RelativePathBase[RelativePathBase]
bioimageio.spec._internal.io.RelativePathBase --> bioimageio.spec.common.RelativeFilePath
click bioimageio.spec.common.RelativeFilePath href "" "bioimageio.spec.common.RelativeFilePath"
click bioimageio.spec._internal.io.RelativePathBase href "" "bioimageio.spec._internal.io.RelativePathBase"
A path relative to the rdf.yaml file (also if the RDF source is a URL).
-
v0_2NotebookSource -
v0_3NotebookSource - API Reference
Methods:
| Name | Description |
|---|---|
__repr__ |
|
__str__ |
|
absolute |
get the absolute path/url |
format |
|
get_absolute |
|
model_post_init |
add validation @private |
Attributes:
| Name | Type | Description |
|---|---|---|
path |
PurePath
|
|
suffix |
|
__repr__
¤
__repr__() -> str
Source code in src/bioimageio/spec/_internal/io.py
150 151 | |
__str__
¤
__str__() -> str
Source code in src/bioimageio/spec/_internal/io.py
147 148 | |
absolute
¤
absolute() -> AbsolutePathT
get the absolute path/url
(resolved at time of initialization with the root of the ValidationContext)
Source code in src/bioimageio/spec/_internal/io.py
125 126 127 128 129 130 131 132 | |
format
¤
format() -> str
Source code in src/bioimageio/spec/_internal/io.py
153 154 155 | |
get_absolute
¤
get_absolute(
root: "RootHttpUrl | Path | AnyUrl | ZipFile",
) -> "AbsoluteFilePath | HttpUrl | ZipPath"
Source code in src/bioimageio/spec/_internal/io.py
217 218 219 220 221 222 223 224 225 226 227 228 229 | |
model_post_init
¤
model_post_init(__context: Any) -> None
add validation @private
Source code in src/bioimageio/spec/_internal/io.py
210 211 212 213 214 215 | |
RootHttpUrl
¤
Bases: ValidatedString
flowchart TD
bioimageio.spec.common.RootHttpUrl[RootHttpUrl]
bioimageio.spec._internal.validated_string.ValidatedString[ValidatedString]
bioimageio.spec._internal.validated_string.ValidatedString --> bioimageio.spec.common.RootHttpUrl
click bioimageio.spec.common.RootHttpUrl href "" "bioimageio.spec.common.RootHttpUrl"
click bioimageio.spec._internal.validated_string.ValidatedString href "" "bioimageio.spec._internal.validated_string.ValidatedString"
An untested HTTP URL, possibly a 'URL folder' or an invalid HTTP URL
-
v0_2HttpUrl -
v0_2HttpUrl -
v0_2HttpUrl -
v0_3HttpUrl -
v0_3HttpUrl -
v0_3HttpUrl -
v0_3HttpUrl -
v0_4HttpUrl -
v0_5HttpUrl -
API Reference
commonHttpUrl
- API Reference
Methods:
| Name | Description |
|---|---|
__get_pydantic_core_schema__ |
|
__get_pydantic_json_schema__ |
|
__new__ |
|
absolute |
analog to |
Attributes:
| Name | Type | Description |
|---|---|---|
host |
Optional[str]
|
|
parent |
RootHttpUrl
|
|
parents |
Iterable[RootHttpUrl]
|
iterate over all URL parents (max 100) |
path |
Optional[str]
|
|
root_model |
Type[RootModel[Any]]
|
the pydantic root model to validate the string |
scheme |
str
|
|
root_model
class-attribute
¤
the pydantic root model to validate the string
__get_pydantic_core_schema__
classmethod
¤
__get_pydantic_core_schema__(
source_type: Any, handler: GetCoreSchemaHandler
) -> CoreSchema
Source code in src/bioimageio/spec/_internal/validated_string.py
29 30 31 32 33 | |
__get_pydantic_json_schema__
classmethod
¤
__get_pydantic_json_schema__(
core_schema: CoreSchema, handler: GetJsonSchemaHandler
) -> JsonSchemaValue
Source code in src/bioimageio/spec/_internal/validated_string.py
35 36 37 38 39 40 41 42 43 44 | |
__new__
¤
__new__(object: object)
Source code in src/bioimageio/spec/_internal/validated_string.py
19 20 21 22 23 | |
absolute
¤
absolute()
analog to absolute method of pathlib.
Source code in src/bioimageio/spec/_internal/root_url.py
18 19 20 | |
Sha256
¤
Bases: ValidatedString
flowchart TD
bioimageio.spec.common.Sha256[Sha256]
bioimageio.spec._internal.validated_string.ValidatedString[ValidatedString]
bioimageio.spec._internal.validated_string.ValidatedString --> bioimageio.spec.common.Sha256
click bioimageio.spec.common.Sha256 href "" "bioimageio.spec.common.Sha256"
click bioimageio.spec._internal.validated_string.ValidatedString href "" "bioimageio.spec._internal.validated_string.ValidatedString"
A SHA-256 hash value
-
API Reference
utilsget_sha256
Methods:
| Name | Description |
|---|---|
__get_pydantic_core_schema__ |
|
__get_pydantic_json_schema__ |
|
__new__ |
|
Attributes:
| Name | Type | Description |
|---|---|---|
root_model |
Type[RootModel[Any]]
|
the pydantic root model to validate the string |
root_model
class-attribute
¤
root_model: Type[RootModel[Any]] = RootModel[
Annotated[
str,
StringConstraints(
strip_whitespace=True,
to_lower=True,
min_length=64,
max_length=64,
),
]
]
the pydantic root model to validate the string
__get_pydantic_core_schema__
classmethod
¤
__get_pydantic_core_schema__(
source_type: Any, handler: GetCoreSchemaHandler
) -> CoreSchema
Source code in src/bioimageio/spec/_internal/validated_string.py
29 30 31 32 33 | |
__get_pydantic_json_schema__
classmethod
¤
__get_pydantic_json_schema__(
core_schema: CoreSchema, handler: GetJsonSchemaHandler
) -> JsonSchemaValue
Source code in src/bioimageio/spec/_internal/validated_string.py
35 36 37 38 39 40 41 42 43 44 | |
__new__
¤
__new__(object: object)
Source code in src/bioimageio/spec/_internal/validated_string.py
19 20 21 22 23 | |