-
Notifications
You must be signed in to change notification settings - Fork 29
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
build schema_validators dict for bluesky issue #1197 #79
Conversation
This looks on track so me so I have gone ahead and marked it as ready for review so that CI will start running against it. Please update all the places that we use event-model/event_model/__init__.py Line 73 in 54e9259
to use these validators instead. Please also update the |
added schema_validators to __all__ replaced calls to jsonschema.validate() with schema_validators[].validate()
I think I have corrected those embarrassing oversights. |
Haha, not at all! Very useful PR for Week 3 on the team! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is ready. I have taken it for a spin interactively and it holds up.
This should get at least one more pair of eyes before being merged, given its importance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, thanks @jklynch!
Left a minor question regarding imports, otherwise good to go.
|
||
__all__ = ['DocumentNames', 'schemas', 'compose_run'] | ||
import jsonschema | ||
import numpy |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did those imports moved from their original places?
PEP8 compulsion. I was weak.
…On Thu, May 23, 2019 at 3:50 PM Maksim Rakitin ***@***.***> wrote:
***@***.**** approved this pull request.
Looks good to me, thanks @jklynch <https://github.com/jklynch>!
Left a minor question regarding imports, otherwise good to go.
------------------------------
In event_model/__init__.py
<#79 (comment)>:
>
-__all__ = ['DocumentNames', 'schemas', 'compose_run']
+import jsonschema
+import numpy
Why did those imports moved from their original places?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#79?email_source=notifications&email_token=ABCI2RLNPV7RQS3FFNCVHF3PW3YO5A5CNFSM4HOWEV32YY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOBZR237I#pullrequestreview-241413629>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABCI2RMAIQQC6VMKR2JKWL3PW3YO5ANCNFSM4HOWEV3Q>
.
|
I don't think we ever really decided whether we would adopt the "builtins, then external libs, then package-local libs" breakdown, but I have heard it argued for and I am happy to adopt it. |
I really like it though, as I expressed it some time ago myself. PyCharm normally does it for you "for free" ("Optimize imports" menu or something like that). |
A dict 'schema_validators' is constructed of jsonschema.Validator instances. The intention is that this dict be imported by code wanting to validate JSON.
Motivation and Context
This change is in support of using jsonschema>3: bluesky/bluesky#1197.
jsonschema.validate() is currently used in bluesky but has been deprecated. The 'new' method is to extend a jsonschema validator class which takes about 4 lines of code. I suggest putting those 4 lines in event-model and caching one validator for each schema.
How Has This Been Tested?