Expose base_uri
in utils.validate
#1609
Labels
feat/enhancement
New feature or request
needs-triage
Needs a maintainer to categorize and assign
schema and spec
JSON schema
Summary
Would it be possible to expose the
base_uri
passed to the schema reference resolver as a parameter ofpyhf.utils.validate
?(and similarly the
path
used inpyhf.utils.load_schema
, too?)After the proposed change,
validate
would take an optional argument, defaulting to the currently used path to the package install location, and also forward that path toload_schema
, which similarly would take it as an argument (also with a default).This would make it much easier to validate specs against a custom schema (e.g. one extracted from a reference to the
defs.json
).Related problem
When trying to validate components of a to-be-assembled
Workspace
orModel
spec, thepyhf.utils
helper functions (validate
andload_schema
) search for schemas only in the package installation path.I do not really want to add files to the package install directories manually,
so I cannot use the
pyhf.utils
helpers to validate partial specs against component schemas (e.g.lumi
,sample
, orobservation
specs).My current work-around
I am currently working around the issue by having copy-pasted implementations of
pyhf.utils.validate
andpyhf.utils.load_schema
in my code,which I fall back on if the schema is not found by
pyhf.utils.load_schema
(meaning for everything exceptWorkspace
orModel
):But I feel this is a bit silly (and risks diverging from the pyhf implementation over time)
since the base path to look up schemas in is the only real difference of my copies to the originals.
Additional Information
Example usage after the suggestion is implemented
Validate a custom schema (that is extracted from
defs.json
or custom-defined) using the pyhf validation helper function:Relevant Issues and Pull Requests
Both of these are more tangential, but maybe there are examples of where this could be a useful feature:
Code of Conduct
The text was updated successfully, but these errors were encountered: