Skip to content
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

Forced measurement object schema validation through ws.model() #2457

Open
alexander-held opened this issue Mar 15, 2024 · 1 comment
Open
Assignees
Labels
bug Something isn't working

Comments

@alexander-held
Copy link
Member

I am unsure if this is a bug / feature / something else: as far as I can see, a ws.model(validate=False) call will trigger get_measurement()

pyhf/src/pyhf/workspace.py

Lines 428 to 431 in adddb07

measurement = self.get_measurement(
measurement_name=measurement_name,
measurement_index=measurement_index,
)
and subsequently that one will feature a forced schema validation:
schema.validate(measurement, 'measurement.json', version=self.version)

I noticed this while trying out pyhf on https://marimo.app/ with something like

import micropip
await micropip.install("pyhf")

import pyhf

spec = {
    "channels": [
        {
            "name": "Signal_region",
            "samples": [
                {
                    "data": [140.0],
                    "modifiers": [
                        {
                            "data": {
                                "hi": 1.08,
                                "lo": 0.92
                            },
                            "name": "luminosity",
                            "type": "normsys"
                        }
                    ],
                    "name": "Dummy"
                }
            ]
        }
    ],
    "measurements": [
        {
            "config": {"parameters": [], "poi": ""},
            "name": "Luminosity uncertainty example"
        }
    ],
    "observations": [
        {
            "data": [140.0],
            "name": "Signal_region"
        }
    ],
    "version": "1.0.0"
}

ws = pyhf.Workspace(spec, validate=False)
model = ws.model(validate=False)

which occasionally gives me jsonschema.exceptions.RefResolutionError (may be a glitch with the site and not necessarily a pyhf issue) and I expected I would be able to skip all validation with validate=False.

@matthewfeickert matthewfeickert self-assigned this Mar 15, 2024
@matthewfeickert matthewfeickert added the bug Something isn't working label Mar 15, 2024
@matthewfeickert
Copy link
Member

Thanks @alexander-held. I think from a user perspective this would qualify as a bug as you're explicitly indicated that you don't want validation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants