-
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
Option to skip validation in Workspace.get_measurement
and Workspace.model
?
#1745
Comments
What does your python calls look like right now for specifying the schema and version? That is |
Thanks for the quick reaction! The calls look like this: |
PS: to be more clear, the |
What is the file that it tries to open? If you put everything in Lines 389 to 390 in abde607
|
(For what it's worth, the #1609 is technically related to this anyway) |
The file it tries to look up is |
but I thought you modified
so I'm a little confused about why this would go back to the e.g. def _myvalidate(....):
...
import pyhf
pyhf.utils.validate = _myvalidate
... |
Oh, sorry, I don't think I made that clear. |
So |
i.e. in effect the code does the equivalent of this: import pyhf
def my_validate(...):
...
try:
pyhf.utils.validate(....) # ok if Model or Measurement or Workspace and version == '1.0.0'
except FileNotFoundError as e: # either the schema is not exposed, or the version is fake
# re-implementation of validate that refers to my custom paths
spec = make_a_spec(...)
my_validate(spec) # now I trust it
ws = pyhf.Workspace(spec, validate = False) # works
model = ws.model(validate = False) # FileNotFoundError |
Can you just try instead to do something like import pyhf
_validate = pyhf.utils.validate
def my_validate(...):
...
try:
_validate(....)
except:
...
spec = make_a_spec(...)
my_validate(spec) # now I trust it
ws = pyhf.Workspace(spec, validate = False) # works
model = ws.model(validate = False) # FileNotFoundError |
That still gives the same exception. Is there something missing in the code example? The only difference is it re-binds |
It should rebind import pyhf
pyhf.utils.validate = lambda *args, **kwargs: True at least until the linked issue gets implemented and we don't need the sort of hacky solutions like this. |
oooh I see what you meant. Then its just the final re-bind of |
How about for now I close this issue since technically, this will get solved when we have |
Absolutely, feel free to close this. |
Summary
Dear pyhf maintainers,
Would you be open to making validation skippable in
Workspace.get_measurement
andWorkspace.model
?I am trying to integrate a user-defined modifier into an existing workspace.
To still be able to validate the standard parts of the spec, I wrote a slightly relaxed set of schemas that validate custom modifiers.
To switch between the standard and relaxed schemas I gave the relaxed schemas a fake version number.
However the
Workspace.get_measurement
validation tries to use that fake version number in its validation to look up themeasurement.json
schema in the pyhf package directory.That of course raises a
FileNotFoundError
since there is no such schema version in pyhf, preventing me from getting a model out of my workspace.It would be very convenient if
Workspace.get_measurement
would accept thevalidate
kwarg likeModel
andWorkspace
already do on master, and ifWorkspace.model
would forward that option toWorkspace.get_measurement
.Additional Information
No response
Code of Conduct
The text was updated successfully, but these errors were encountered: