Skip to content

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

@alexander-held

Description

@alexander-held

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.

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions