From bfae019caba607777080f0fe825e9052366b15dd Mon Sep 17 00:00:00 2001 From: fynnbe Date: Tue, 17 Oct 2023 09:35:43 +0200 Subject: [PATCH 1/3] sort imports --- bioimageio/spec/model/v0_3/schema.py | 11 +++++++++- bioimageio/spec/model/v0_4/schema.py | 32 +++++++++++++++++++++++++--- 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/bioimageio/spec/model/v0_3/schema.py b/bioimageio/spec/model/v0_3/schema.py index 0cf27c08f..d97412058 100644 --- a/bioimageio/spec/model/v0_3/schema.py +++ b/bioimageio/spec/model/v0_3/schema.py @@ -3,7 +3,15 @@ from copy import deepcopy from types import ModuleType -from marshmallow import RAISE, ValidationError, missing as missing_, post_load, pre_dump, pre_load, validates_schema +from marshmallow import ( + RAISE, + ValidationError, + post_load, + pre_dump, + pre_load, + validates_schema, +) +from marshmallow import missing as missing_ from bioimageio.spec.rdf import v0_2 as rdf from bioimageio.spec.shared import field_validators, fields @@ -15,6 +23,7 @@ SharedProcessingSchema, ) from bioimageio.spec.shared.utils import get_ref_url + from . import raw_nodes Author = rdf.schema.Author diff --git a/bioimageio/spec/model/v0_4/schema.py b/bioimageio/spec/model/v0_4/schema.py index b406baa02..0a62bc3b0 100644 --- a/bioimageio/spec/model/v0_4/schema.py +++ b/bioimageio/spec/model/v0_4/schema.py @@ -3,23 +3,49 @@ from types import ModuleType import numpy -from marshmallow import RAISE, ValidationError, missing, pre_load, validates, validates_schema +from marshmallow import ( + RAISE, + ValidationError, + missing, + pre_load, + validates, + validates_schema, +) from bioimageio.spec.dataset.v0_2.schema import Dataset as _Dataset from bioimageio.spec.model.v0_3.schema import ( KerasHdf5WeightsEntry as KerasHdf5WeightsEntry03, +) +from bioimageio.spec.model.v0_3.schema import ( OnnxWeightsEntry as OnnxWeightsEntry03, +) +from bioimageio.spec.model.v0_3.schema import ( Postprocessing as Postprocessing03, +) +from bioimageio.spec.model.v0_3.schema import ( Preprocessing as Preprocessing03, +) +from bioimageio.spec.model.v0_3.schema import ( TensorflowJsWeightsEntry as TensorflowJsWeightsEntry03, +) +from bioimageio.spec.model.v0_3.schema import ( TensorflowSavedModelBundleWeightsEntry as TensorflowSavedModelBundleWeightsEntry03, - _WeightsEntryBase as _WeightsEntryBase03, +) +from bioimageio.spec.model.v0_3.schema import ( _common_sha256_hint, ) +from bioimageio.spec.model.v0_3.schema import ( + _WeightsEntryBase as _WeightsEntryBase03, +) from bioimageio.spec.rdf import v0_2 as rdf from bioimageio.spec.shared import LICENSES, field_validators, fields from bioimageio.spec.shared.common import get_args, get_args_flat -from bioimageio.spec.shared.schema import ImplicitOutputShape, ParametrizedInputShape, SharedBioImageIOSchema +from bioimageio.spec.shared.schema import ( + ImplicitOutputShape, + ParametrizedInputShape, + SharedBioImageIOSchema, +) + from . import raw_nodes From e84cd11176d48bd392f226e6d9fcc9d1dda8f772 Mon Sep 17 00:00:00 2001 From: fynnbe Date: Tue, 17 Oct 2023 09:36:14 +0200 Subject: [PATCH 2/3] remove suffix validation --- bioimageio/spec/model/v0_3/schema.py | 9 +-------- bioimageio/spec/model/v0_4/schema.py | 9 +-------- bioimageio/spec/shared/fields.py | 14 ++++---------- 3 files changed, 6 insertions(+), 26 deletions(-) diff --git a/bioimageio/spec/model/v0_3/schema.py b/bioimageio/spec/model/v0_3/schema.py index d97412058..bb982c8bf 100644 --- a/bioimageio/spec/model/v0_3/schema.py +++ b/bioimageio/spec/model/v0_3/schema.py @@ -512,14 +512,7 @@ class Meta: documentation = fields.Union( [ fields.URL(), - fields.Path( - validate=field_validators.Attribute( - "suffix", - field_validators.Equal( - ".md", error="{!r} is invalid; expected markdown file with '.md' extension." - ), - ) - ), + fields.Path(), ], required=True, bioimageio_description="Relative path to file with additional documentation in markdown. This means: 1) only " diff --git a/bioimageio/spec/model/v0_4/schema.py b/bioimageio/spec/model/v0_4/schema.py index 0a62bc3b0..877430f77 100644 --- a/bioimageio/spec/model/v0_4/schema.py +++ b/bioimageio/spec/model/v0_4/schema.py @@ -382,14 +382,7 @@ def warn_on_missing_cite(self, data: dict, **kwargs): documentation = fields.Union( [ fields.URL(), - fields.Path( - validate=field_validators.Attribute( - "suffix", - field_validators.Equal( - ".md", error="{!r} is invalid; expected markdown file with '.md' extension." - ), - ) - ), + fields.Path(), ], required=True, bioimageio_description="Relative path or URL to file with additional documentation in markdown. " diff --git a/bioimageio/spec/shared/fields.py b/bioimageio/spec/shared/fields.py index 1023de713..ba062de61 100644 --- a/bioimageio/spec/shared/fields.py +++ b/bioimageio/spec/shared/fields.py @@ -1,13 +1,14 @@ """fields to be used in the versioned schemas (may return shared raw nodes on `deserialize`""" import datetime -import packaging.version import logging import pathlib import typing import marshmallow_union import numpy -from marshmallow import Schema, ValidationError, fields as marshmallow_fields, missing +import packaging.version +from marshmallow import Schema, ValidationError, missing +from marshmallow import fields as marshmallow_fields from . import field_validators, raw_nodes from .utils._docs import resolve_bioimageio_descrcription @@ -361,14 +362,7 @@ def _deserialize(self, *args, **kwargs) -> typing.Any: source_file_field = Union( [ URL(), - Path( - validate=field_validators.Attribute( - "suffix", - field_validators.Equal( - ".py", error="{!r} is invalid; expected python source file with '.py' extension." - ), - ) - ), + Path(), ] ) return raw_nodes.ImportableSourceFile( From 8d8cf2d45f3d1b2d5b055a0975f93aa624991c15 Mon Sep 17 00:00:00 2001 From: fynnbe Date: Tue, 17 Oct 2023 09:36:14 +0200 Subject: [PATCH 3/3] bump post --- bioimageio/spec/VERSION | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bioimageio/spec/VERSION b/bioimageio/spec/VERSION index 8973731e8..133b99885 100644 --- a/bioimageio/spec/VERSION +++ b/bioimageio/spec/VERSION @@ -1,3 +1,3 @@ { - "version": "0.4.9post2" -} \ No newline at end of file + "version": "0.4.9post3" +}