You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
instead of having users overwriting the value by assignment, do you think there is value in offering a pyhf.utils.update_schema_path or something that performs this operation through the API?
I second @matthewfeickert's suggestion to change schemas via function call rather than assignment. It is much simpler to add functionality to a function if it ever becomes necessary, than to replace an entire existing module with a class instance with a property.
I'd even go so far to say that a context manager doubling as an update function would be ideal IMO:
# in pyhf.utils_SCHEMAS=Path(...)
classuse_schema_path: # snake_case to remind of function-like usagedef__init__(self, path):
global_SCHEMASself._old_schemas=_SCHEMAS_SCHEMAS=pathlib.Path(path)
def__enter__(self):
passdef__exit__(self, *args, **kwargs):
global_SCHEMAS_SCHEMAS=self._old_schemas
which can still be called as a function (only executing __init__), so short scripts etc. are not forced to use with blocks.
But it can also be used like so:
So as a user writing code on top of pyhf, I don't have to worry about resesetting the global variable, the CM does it for me, and there are fewer mistakes to make.
Originally posted by @lhenkelm in #1753 (comment)
The text was updated successfully, but these errors were encountered: