|
10 | 10 | from bioimageio.spec._internal.field_warning import as_warning, warn |
11 | 11 | from bioimageio.spec._internal.types import ( |
12 | 12 | AbsoluteFilePath, |
| 13 | + BioimageioYamlContent, |
13 | 14 | DeprecatedLicenseId, |
14 | 15 | Doi, |
15 | 16 | FileSource, |
|
21 | 22 | Version, |
22 | 23 | ) |
23 | 24 | from bioimageio.spec._internal.types.field_validation import WithSuffix |
24 | | -from bioimageio.spec._internal.validation_context import get_internal_validation_context |
| 25 | +from bioimageio.spec._internal.validation_context import InternalValidationContext, get_internal_validation_context |
| 26 | +from bioimageio.spec.generic.v0_2_converter import convert_from_older_format |
25 | 27 |
|
26 | 28 | KNOWN_SPECIFIC_RESOURCE_TYPES = ("application", "collection", "dataset", "model", "notebook") |
27 | 29 |
|
@@ -144,7 +146,7 @@ class LinkedResource(Node): |
144 | 146 |
|
145 | 147 |
|
146 | 148 | class GenericModelBase(ResourceDescriptionBase): |
147 | | - """Base with common fields""" |
| 149 | + """Base for all resource descriptions including of model descriptions""" |
148 | 150 |
|
149 | 151 | name: Annotated[NotEmpty[str], warn(MaxLen(128), "Longer than 128 characters.")] |
150 | 152 | """A human-friendly name of the resource description""" |
@@ -285,6 +287,19 @@ def warn_about_tag_categories(cls, value: List[str], info: ValidationInfo) -> Li |
285 | 287 |
|
286 | 288 |
|
287 | 289 | class GenericBase(GenericModelBase): |
| 290 | + """Base for all resource descriptions except for the model descriptions""" |
| 291 | + |
| 292 | + format_version: Literal["0.2.3"] = "0.2.3" |
| 293 | + """The format version of this resource specification |
| 294 | + (not the `version` of the resource description) |
| 295 | + When creating a new resource always use the latest micro/patch version described here. |
| 296 | + The `format_version` is important for any consumer software to understand how to parse the fields. |
| 297 | + """ |
| 298 | + |
| 299 | + @classmethod |
| 300 | + def convert_from_older_format(cls, data: BioimageioYamlContent, context: InternalValidationContext) -> None: |
| 301 | + convert_from_older_format(data, context) |
| 302 | + |
288 | 303 | badges: List[Badge] = Field(default_factory=list) |
289 | 304 | """badges associated with this resource""" |
290 | 305 |
|
@@ -324,17 +339,7 @@ def deprecated_spdx_license(cls, value: Optional[str]) -> Optional[str]: |
324 | 339 | ResourceDescriptionType = TypeVar("ResourceDescriptionType", bound=GenericBase) |
325 | 340 |
|
326 | 341 |
|
327 | | -class WithGenericFormatVersion(Node): |
328 | | - format_version: Literal["0.2.3"] = "0.2.3" |
329 | | - |
330 | | - """The format version of this resource specification |
331 | | - (not the `version` of the resource description) |
332 | | - When creating a new resource always use the latest micro/patch version described here. |
333 | | - The `format_version` is important for any consumer software to understand how to parse the fields. |
334 | | - """ |
335 | | - |
336 | | - |
337 | | -class Generic(GenericBase, WithGenericFormatVersion, extra="ignore", title="bioimage.io generic specification"): |
| 342 | +class Generic(GenericBase, extra="ignore", title="bioimage.io generic specification"): |
338 | 343 | """Specification of the fields used in a generic bioimage.io-compliant resource description file (RDF). |
339 | 344 |
|
340 | 345 | An RDF is a YAML file that describes a resource such as a model, a dataset, or a notebook. |
|
0 commit comments