mobie / mobie-utils-python

Python tools for MoBIE
MIT License
9 stars 5 forks source link

schema issue #95

Closed martinschorb closed 1 year ago

martinschorb commented 1 year ago

Hi,

when running a CI test, I get some schema validation errors.

>       mod.run()
tests/test_materialize.py:185: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
rmaddons/materialize/addtomobie.py:72: in run
    self.addtomobieproject(self.args['xmlpath'], self.args['outpath'])
rmaddons/materialize/addtomobie.py:65: in addtomobieproject
    move_data=True)
/opt/conda/lib/python3.7/site-packages/mobie/image_data.py:155: in add_bdv_image
    move_only=move_only, int_to_uint=int_to_uint)
/opt/conda/lib/python3.7/site-packages/mobie/image_data.py:223: in add_image
    contrast_limits=contrast_limits)
/opt/conda/lib/python3.7/site-packages/mobie/utils.py:93: in require_dataset_and_view
    validate_view_metadata(view, sources=[source_name])
/opt/conda/lib/python3.7/site-packages/mobie/validation/metadata.py:258: in validate_view_metadata
    validate_with_schema(view, "view")
/opt/conda/lib/python3.7/site-packages/mobie/validation/utils.py:51: in validate_with_schema
    jsonschema.validate(instance=metadata, schema=schema)
/opt/conda/lib/python3.7/site-packages/jsonschema/validators.py:540: in validate
    cls.check_schema(schema)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
cls = <class 'jsonschema.validators.create.<locals>.Validator'>
schema = {'$id': 'https://raw.githubusercontent.com/mobie/mobie.github.io/master/schema/view.schema.json', '$schema': 'http://j... 'max': {...}, 'min': {...}, ...}, 'required': ['min', 'max', 'sources'], ...}}, 'required': ['crop'], ...}, ...}, ...}
    @classmethod
    def check_schema(cls, schema):
        for error in cls(cls.META_SCHEMA).iter_errors(schema):
>           raise SchemaError.create_from(error)
E           jsonschema.exceptions.SchemaError: {'type': 'number', 'exclusiveMinimum': 0} is not valid under any of the given schemas
E           
E           Failed validating 'anyOf' in schema['properties']['definitions']['additionalProperties']['properties']['properties']['additionalProperties']['properties']['properties']['additionalProperties']['properties']['items']:
E               {'anyOf': [{'$ref': '#'}, {'$ref': '#/definitions/schemaArray'}],
E                'default': {}}
E           
E           On instance['definitions']['segmentationDisplay']['properties']['segmentationDisplay']['properties']['resolution3dView']['items']:
E               {'exclusiveMinimum': 0, 'type': 'number'}
/opt/conda/lib/python3.7/site-packages/jsonschema/validators.py:83: SchemaError

I cannot reproduce them locally (tried both on Mac and Linux with versions 0.4.1 and the current 0.4.3)

Do you have an idea what could be the reason?

martinschorb commented 1 year ago

this is the test:

https://git.embl.de/schorb/rendermodules-addons/-/blob/337d910258a20dc00c02f55d71782a0f86081043/tests/test_materialize.py#L160

constantinpape commented 1 year ago

Hmm, I am not sure what's going on there. It seems to complain that exclusiveMinimum here is not valid jsonschema. But this doesn't make sense since this is part of the latest schemas, and there is mobie CI checking this... Maybe the CI you have running is pulling a very old jsonschema version?! Maybe you can fix it by adding an explicit dependency to jsonschema in the CI file and demanding some recent version.

martinschorb commented 1 year ago

Yes that seems to be the reason. The environment has jsonschema 2.6. The issue is that many of the underlying packages require it and there are some version restrictions. What minimum version does mobie-python require? I need to find out what can be updated without breaking other dependencies...

martinschorb commented 1 year ago

Ha, seems I can force installation of a newer jsonschema after the other dependencies and my tests still run.

Now I need to check my production conda env and see if it works there as well...