-
Notifications
You must be signed in to change notification settings - Fork 85
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
fix: Populate the schema cache with local defs.json
again
#1917
fix: Populate the schema cache with local defs.json
again
#1917
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1917 +/- ##
=======================================
Coverage 98.26% 98.26%
=======================================
Files 69 69
Lines 4439 4443 +4
Branches 748 748
=======================================
+ Hits 4362 4366 +4
Misses 45 45
Partials 32 32
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
I'm trying to figure out or remind myself if this was removed to allow for a custom |
For your tests, the easiest way is to monkeypatch any part of the necessary call to |
I don't remember an explicit discussion in that set of issues/PRs. I might have missed it though. I guess strictly speaking this breaks some assumptions of what the version and schema-id mean, if someine changes the schema they should change at least one of those too. Maybe we could add some logic to the schema-path setter that checks and warns/raises if some of the schemas found at the new path would cause this error? Because as long as the schema-id+version is unique to a definition, the cache should work fine. |
Yeah this is why the tests the PR is currently proposing to monkey-patch |
3d311bb
to
6c837fe
Compare
@lhenkelm just to check, is this ready for review? I assume yes, but I just wanted to make sure that you didn't have anything that you wanted to come back and add before it got reviewed and went in. |
@matthewfeickert having thought some more about @kratsg's concern about users overriding the default schema using the default version and id, I would like to add a bit of code to at least clear the cache if the schema path/version are changed, to preempt these confusions. A second step might be to also merge the I am a bit busy ATM but I'll get on this this week and ping you once I am done. |
I wonder if we can simplify the PR via https://pypi.org/project/pytest-socket/ using the ( |
@matthewfeickert from my side this is ready to review.
|
lets us see both failures, also reduces repetition
034d9e7
to
84342b4
Compare
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.
it is action, not prep
Co-authored-by: Matthew Feickert <matthew.feickert@cern.ch>
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.
LGTM. 👍 Thanks very much for your contribution @lhenkelm!
Description
Resolves #1916 by re-introducing the pre-population of the schema cache that had been done before the re-write of the schema utilities in #1753. Since
defs.json
is in the cache under its id,jsonschema.RefResolver
will not attempt to connect to"https://scikit-hep.org"
to find it, which can crash code using pyhf in environments where the resource is not reachable.I also tried to include a test to avoid future regression, but I am not happy with it.
A better/more robust test would be a dedicated run in a sandboxed (i.e. no internet access / relevant ports blocked) environment, e.g. as part of the CI. But I have no clue how to set that up.
Checklist Before Requesting Reviewer
Before Merging
For the PR Assignees: