Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in object detection schema #70

Closed
rohanakut opened this issue Jul 22, 2021 · 14 comments
Closed

Error in object detection schema #70

rohanakut opened this issue Jul 22, 2021 · 14 comments
Assignees

Comments

@rohanakut
Copy link
Contributor

In the dimensions field


"prefixItems": [
                        { "type": "number", "minimum": 0, "maximum": 1 },
                        { "type": "number", "minimum": 0, "maximum": 1 },
                        { "type": "number", "minimum": 0, "maximum": 1 },
                        { "type": "number", "minimum": 0, "maximum": 1 }
                    ],
                    "items": false,
                    "minItems": 4

needs to be changed to

"items": [
                        { "type": "number", "minimum": 0, "maximum": 1 },
                        { "type": "number", "minimum": 0, "maximum": 1 },
                        { "type": "number", "minimum": 0, "maximum": 1 },
                        { "type": "number", "minimum": 0, "maximum": 1 }
                    ],
                    "minItems": 4

@JRegimbal tagging you to double-check the modification

@rohanakut rohanakut self-assigned this Jul 22, 2021
@JRegimbal
Copy link
Collaborator

Ah the prefixItems is a feature of the new draft for this (2020-12 IIRC), so it's actually valid but not backwards compatible.

@rohanakut
Copy link
Contributor Author

should i create a new PR to make the changes?

@JRegimbal
Copy link
Collaborator

What's the actual issue that's happening?

@rohanakut
Copy link
Contributor Author

when i try to validate it throws the following error:

False schema does not allow 0.026533996683250415

Failed validating None in schema['properties']['objects']['items']['properties']['dimensions']:
    False

@JRegimbal
Copy link
Collaborator

How are you trying to validate it?

@rohanakut
Copy link
Contributor Author

rohanakut commented Jul 22, 2021

I am validating using a draft7validator

This is my exact code:


try:
        validator = jsonschema.Draft7Validator(data_schema)
        validator.validate(things)
except jsonschema.exceptions.ValidationError as e:
          logging.error(e)
          return jsonify("Invalid Preprocessor JSON format"), 500

And the data schema is called in the following way:

with open('./schemas/preprocessors/object-detection.schema.json') as jsonfile:
            data_schema = json.load(jsonfile)

@JRegimbal
Copy link
Collaborator

Alright that explains it. This isn't a draft 7 schema and so it isn't understood by validator. A quick check suggests this is a much bigger issue as jsonschema doesn't support draft 2020-12 (although python-jsonschema/jsonschema#817 would add support). I'd hate to say it but it might be necessary to do rewriting of a lot of schema files if support isn't added soon.

@rohanakut
Copy link
Contributor Author

The fix i suggested above works well as my schema gets validated with that fix. So for now should I start with the object detection schema and then move on to other schemas?

@JRegimbal
Copy link
Collaborator

A lot of other changes would be necessary, including to the containers that actually are validating it as a draft 2020-12 schema and would fail with this change.

@rohanakut
Copy link
Contributor Author

As far as i know, only the object detection schema throws this error. this is because all the other models have been validated using draft7validator and none of them threw this error. So I don't think that any other schemas need to be changed

@JRegimbal
Copy link
Collaborator

The actual request schema itself uses the prefixItems key as well and all of them are draft 2020-12. Since I don't know how well validators handle multi-file schemas based on different drafts, it might be best to just drop everything to draft 7. This will fix your problem as well.

@rohanakut
Copy link
Contributor Author

So as a solution should we go ahead with jschon or should we change the schemas?

@JRegimbal
Copy link
Collaborator

Changing the schemas now. I like jschon and I think it'll be an option later, but it is still new and I get the sense we might have to deal with bugs. I already have the schemas updated (downdated?) in the draft7 branch and am testing changes to my many containers that expected a 2020-12 schema.

@JRegimbal
Copy link
Collaborator

Fixed. Main now validates against draft7 and the schema branch contains all schemas in a draft 7 format.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants