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

Update validation pipeline to use a json schema #420

Merged
merged 22 commits into from
Jun 24, 2020

Conversation

yolile
Copy link
Member

@yolile yolile commented Jun 18, 2020

closes #403

yolile added 10 commits June 18, 2020 15:01
Signed-off-by: Yohanna Lisnichuk <yohanitalisnichuk@gmail.com>
Signed-off-by: Yohanna Lisnichuk <yohanitalisnichuk@gmail.com>
Signed-off-by: Yohanna Lisnichuk <yohanitalisnichuk@gmail.com>
Signed-off-by: Yohanna Lisnichuk <yohanitalisnichuk@gmail.com>
Signed-off-by: Yohanna Lisnichuk <yohanitalisnichuk@gmail.com>
Signed-off-by: Yohanna Lisnichuk <yohanitalisnichuk@gmail.com>
Signed-off-by: Yohanna Lisnichuk <yohanitalisnichuk@gmail.com>
Signed-off-by: Yohanna Lisnichuk <yohanitalisnichuk@gmail.com>
Signed-off-by: Yohanna Lisnichuk <yohanitalisnichuk@gmail.com>
@yolile yolile requested a review from jpmckinney June 22, 2020 15:52
@yolile
Copy link
Member Author

yolile commented Jun 22, 2020

@jpmckinney the json schema check is failing due to camel case codelist and fields, but I think that we cannot avoid this, right?

Copy link
Member

@jpmckinney jpmckinney left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments, but the approach is good!

requirements.in Outdated Show resolved Hide resolved
kingfisher_scrapy/items.py Outdated Show resolved Hide resolved
kingfisher_scrapy/pipelines.py Outdated Show resolved Hide resolved
kingfisher_scrapy/pipelines.py Outdated Show resolved Hide resolved
tests/test_validate.py Show resolved Hide resolved
kingfisher_scrapy/item_schema/item_schema.json Outdated Show resolved Hide resolved
kingfisher_scrapy/item_schema/item_schema.json Outdated Show resolved Hide resolved
kingfisher_scrapy/item_schema/item_schema.json Outdated Show resolved Hide resolved
kingfisher_scrapy/item_schema/item_schema.json Outdated Show resolved Hide resolved
kingfisher_scrapy/item_schema/item_schema.json Outdated Show resolved Hide resolved
Signed-off-by: Yohanna Lisnichuk <yohanitalisnichuk@gmail.com>
Signed-off-by: Yohanna Lisnichuk <yohanitalisnichuk@gmail.com>
Signed-off-by: Yohanna Lisnichuk <yohanitalisnichuk@gmail.com>
Signed-off-by: Yohanna Lisnichuk <yohanitalisnichuk@gmail.com>
Signed-off-by: Yohanna Lisnichuk <yohanitalisnichuk@gmail.com>
Signed-off-by: Yohanna Lisnichuk <yohanitalisnichuk@gmail.com>
@yolile yolile requested a review from jpmckinney June 23, 2020 13:33
@yolile
Copy link
Member Author

yolile commented Jun 23, 2020

@jpmckinney I'm still having some json schema errors

@jpmckinney
Copy link
Member

@yolile No worries - I'll relax the validations today. (They are strict because so far we've only used JSON Schema for the standard.)

Copy link
Member

@jpmckinney jpmckinney left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to make a release of JSCC, then tests should pass.

kingfisher_scrapy/item_schema/file.json Outdated Show resolved Hide resolved
kingfisher_scrapy/pipelines.py Outdated Show resolved Hide resolved
for item in ['file', 'file_error', 'file_item']:
filename = os.path.join(schema_path, f'{item}.json')
with open(filename) as f:
schema = jsonref.load(f, base_uri=pathlib.Path(os.path.join(schema_path), 'item_schema').as_uri())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, 'item_schema' is outside the os.path.join call (which we don't need if it's only one argument), and in any case schema_path already contains item_schema. I'm not sure how this works.

Since we're re-using the base_uri parameter value, we can set schema_path to it above.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jpmckinney I changed it but for some reason jsonref fails if I don't put 'item_schema' again in base_uri I'm not sure why

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aha, I had to add a trailing slash to the URI.

kingfisher_scrapy/pipelines.py Outdated Show resolved Hide resolved
…e into 403-json-schema-validate

Signed-off-by: Yohanna Lisnichuk <yohanitalisnichuk@gmail.com>
Signed-off-by: Yohanna Lisnichuk <yohanitalisnichuk@gmail.com>
…e into 403-json-schema-validate

Signed-off-by: Yohanna Lisnichuk <yohanitalisnichuk@gmail.com>
Signed-off-by: Yohanna Lisnichuk <yohanitalisnichuk@gmail.com>
@yolile yolile requested a review from jpmckinney June 24, 2020 15:38
Copy link
Member

@jpmckinney jpmckinney left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

@yolile yolile merged commit ec8552e into master Jun 24, 2020
@yolile yolile deleted the 403-json-schema-validate branch June 24, 2020 17:03
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

Successfully merging this pull request may close these issues.

Use JSON Schema to validate items
2 participants