We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
jsonschema cannot find path specified \\1.0.0\\def.json
### Summary

When I try to install pyhf in a venv and then create a simple model, it gives me a n error 
```
<urlopen error [WinError 3] The system cannot find the path specified: '\\1.0.0\\defs.json'>
```

When i check the path to the schema with 
```
>>> pyhf.schema.path
WindowsPath('C:/Users/alexh/Downloads/pyhf_test/pyhf_venv/Lib/site-packages/pyhf/schemas')
```
Following this path then into the 1.0.0 folder, defs.json exists.

### OS / Environment

```console
# Windows 11
# Python 3.11.6
```


### Steps to Reproduce


```
$ python -m venv venv_pyhf
$ venv_pyhf/Scripts/activate.ps1
$ pip install pyhf
$ python
>>> import pyhf
>>> model = pyhf.simplemodels.uncorrelated_background(signal=[1,2,3], bkg=[4,5,6], bkg_uncertainty=[2,3,4])
_RefResolutionError: <urlopen error [WinError 3] The system cannot find the path specified: '\\1.0.0\\defs.json'>
```


### File Upload (optional)

_No response_

### Expected Results

Expected to get a pyhf.pdf.Model.

### Actual Results

```console
Traceback (most recent call last):
  File "C:\Users\alexh\Downloads\pyhf_test\pyhf_venv\Lib\site-packages\jsonschema\validators.py", line 1097, in resolve_from_url
    document = self.store[url]
               ~~~~~~~~~~^^^^^
  File "C:\Users\alexh\Downloads\pyhf_test\pyhf_venv\Lib\site-packages\jsonschema\_utils.py", line 20, in __getitem__
    return self.store[self.normalize(uri)]
           ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^
KeyError: 'file://C:\\Users\\alexh\\Downloads\\pyhf_test\\pyhf_venv\\Lib\\site-packages\\pyhf\\schemas/1.0.0/defs.json'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.1776.0_x64__qbz5n2kfra8p0\Lib\urllib\request.py", line 1505, in open_local_file
    stats = os.stat(localfile)
            ^^^^^^^^^^^^^^^^^^
FileNotFoundError: [WinError 3] The system cannot find the path specified: '\\1.0.0\\defs.json'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\alexh\Downloads\pyhf_test\pyhf_venv\Lib\site-packages\jsonschema\validators.py", line 1100, in resolve_from_url
    document = self.resolve_remote(url)
               ^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\alexh\Downloads\pyhf_test\pyhf_venv\Lib\site-packages\jsonschema\validators.py", line 1204, in resolve_remote
    with urlopen(uri) as url:
         ^^^^^^^^^^^^
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.1776.0_x64__qbz5n2kfra8p0\Lib\urllib\request.py", line 216, in urlopen
    return opener.open(url, data, timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.1776.0_x64__qbz5n2kfra8p0\Lib\urllib\request.py", line 519, in open
    response = self._open(req, data)
               ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.1776.0_x64__qbz5n2kfra8p0\Lib\urllib\request.py", line 536, in _open
    result = self._call_chain(self.handle_open, protocol, protocol +
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.1776.0_x64__qbz5n2kfra8p0\Lib\urllib\request.py", line 496, in _call_chain
    result = func(*args)
             ^^^^^^^^^^^
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.1776.0_x64__qbz5n2kfra8p0\Lib\urllib\request.py", line 1483, in file_open
    return self.open_local_file(req)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.1776.0_x64__qbz5n2kfra8p0\Lib\urllib\request.py", line 1522, in open_local_file
    raise URLError(exp)
urllib.error.URLError: <urlopen error [WinError 3] The system cannot find the path specified: '\\1.0.0\\defs.json'>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\alexh\Downloads\pyhf_test\pyhf_venv\Lib\site-packages\pyhf\simplemodels.py", line 149, in uncorrelated_background
    return Model(spec, batch_size=batch_size, validate=validate)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\alexh\Downloads\pyhf_test\pyhf_venv\Lib\site-packages\pyhf\pdf.py", line 769, in __init__
    schema.validate(self.spec, self.schema, version=self.version)
  File "C:\Users\alexh\Downloads\pyhf_test\pyhf_venv\Lib\site-packages\pyhf\schema\validator.py", line 93, in validate
    return validator.validate(spec)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\alexh\Downloads\pyhf_test\pyhf_venv\Lib\site-packages\jsonschema\validators.py", line 434, in validate
    for error in self.iter_errors(*args, **kwargs):
  File "C:\Users\alexh\Downloads\pyhf_test\pyhf_venv\Lib\site-packages\jsonschema\validators.py", line 368, in iter_errors
    for error in errors:
  File "C:\Users\alexh\Downloads\pyhf_test\pyhf_venv\Lib\site-packages\jsonschema\_keywords.py", line 284, in ref
    yield from validator._validate_reference(ref=ref, instance=instance)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\alexh\Downloads\pyhf_test\pyhf_venv\Lib\site-packages\jsonschema\validators.py", line 461, in _validate_reference
    scope, resolved = resolve(ref)
                      ^^^^^^^^^^^^
  File "C:\Users\alexh\Downloads\pyhf_test\pyhf_venv\Lib\site-packages\jsonschema\validators.py", line 1086, in resolve
    return url, self._remote_cache(url)
                ^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\alexh\Downloads\pyhf_test\pyhf_venv\Lib\site-packages\jsonschema\validators.py", line 1102, in resolve_from_url
    raise exceptions._RefResolutionError(exc)
jsonschema.exceptions._RefResolutionError: <urlopen error [WinError 3] The system cannot find the path specified: '\\1.0.0\\defs.json'>
```


### pyhf Version

```console
pyhf, version 0.7.4
```


### Code of Conduct

- [X] I agree to follow the Code of Conduct

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `src/pyhf/schema/validator.py`
Content:
```
1 import numbers
2 from typing import Mapping, Union
3 
4 import jsonschema
5 
6 import pyhf.exceptions
7 from pyhf import tensor
8 from pyhf.schema import variables
9 from pyhf.schema.loader import load_schema
10 
11 
12 def _is_array_or_tensor(checker, instance):
13     """
14     A helper function for allowing the validation of tensors as list types in schema validation.
15 
16     .. warning:
17 
18         This will check for valid array types using any backends that have been loaded so far.
19     """
20     return isinstance(instance, (list, *tensor.array_types))
21 
22 
23 def _is_number_or_tensor_subtype(checker, instance):
24     """
25     A helper function for allowing the validation of tensor contents as number types in schema validation.
26 
27     .. warning:
28         This will check for valid array subtypes using any backends that have been loaded so far.
29     """
30     is_number = jsonschema._types.is_number(checker, instance)
31     if is_number:
32         return True
33     return isinstance(instance, (numbers.Number, *tensor.array_subtypes))
34 
35 
36 def validate(
37     spec: Mapping,
38     schema_name: str,
39     *,
40     version: Union[str, None] = None,
41     allow_tensors: bool = True,
42 ):
43     """
44     Validate the provided instance, ``spec``, against the schema associated with ``schema_name``.
45 
46     Args:
47         spec (:obj:`object`): An object instance to validate against a schema.
48         schema_name (:obj:`string`): The name of a schema to validate against.
49          See :func:`pyhf.schema.load_schema` for more details.
50         version (:obj:`string`): The version of the schema to use.
51          See :func:`pyhf.schema.load_schema` for more details.
52         allow_tensors (:obj:`bool`): A flag to enable or disable tensors as part of schema validation.
53          If enabled, tensors in the ``spec`` will be treated like python :obj:`list`.
54          Default: ``True``.
55 
56     Raises:
57         ~pyhf.exceptions.InvalidSpecification: if the provided instance does not validate against the schema.
58 
59     Returns:
60         None: if there are no errors with the provided instance.
61 
62     Example:
63         >>> import pyhf
64         >>> model = pyhf.simplemodels.uncorrelated_background(
65         ...     signal=[12.0, 11.0], bkg=[50.0, 52.0], bkg_uncertainty=[3.0, 7.0]
66         ... )
67         >>> pyhf.schema.validate(model.spec, "model.json")
68         >>>
69     """
70 
71     version = version or variables.SCHEMA_VERSION
72 
73     schema = load_schema(f'{version}/{schema_name}')
74 
75     # note: trailing slash needed for RefResolver to resolve correctly
76     resolver = jsonschema.RefResolver(
77         base_uri=f"file://{variables.schemas}/{version}/",
78         referrer=f"{schema_name}",
79         store=variables.SCHEMA_CACHE,
80     )
81 
82     Validator = jsonschema.Draft6Validator
83 
84     if allow_tensors:
85         type_checker = Validator.TYPE_CHECKER.redefine(
86             "array", _is_array_or_tensor
87         ).redefine("number", _is_number_or_tensor_subtype)
88         Validator = jsonschema.validators.extend(Validator, type_checker=type_checker)
89 
90     validator = Validator(schema, resolver=resolver, format_checker=None)
91 
92     try:
93         return validator.validate(spec)
94     except jsonschema.ValidationError as err:
95         raise pyhf.exceptions.InvalidSpecification(err, schema_name)
96
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/src/pyhf/schema/validator.py b/src/pyhf/schema/validator.py
--- a/src/pyhf/schema/validator.py
+++ b/src/pyhf/schema/validator.py
@@ -1,4 +1,5 @@
 import numbers
+from pathlib import Path
 from typing import Mapping, Union
 
 import jsonschema
@@ -70,12 +71,15 @@
 
     version = version or variables.SCHEMA_VERSION
 
-    schema = load_schema(f'{version}/{schema_name}')
+    schema = load_schema(str(Path(version).joinpath(schema_name)))
 
-    # note: trailing slash needed for RefResolver to resolve correctly
+    # note: trailing slash needed for RefResolver to resolve correctly and by
+    # design, pathlib strips trailing slashes. See ref below:
+    # * https://bugs.python.org/issue21039
+    # * https://github.com/python/cpython/issues/65238
     resolver = jsonschema.RefResolver(
-        base_uri=f"file://{variables.schemas}/{version}/",
-        referrer=f"{schema_name}",
+        base_uri=f"{Path(variables.schemas).joinpath(version).as_uri()}/",
+        referrer=schema_name,
         store=variables.SCHEMA_CACHE,
     )

{"golden_diff": "diff --git a/src/pyhf/schema/validator.py b/src/pyhf/schema/validator.py\n--- a/src/pyhf/schema/validator.py\n+++ b/src/pyhf/schema/validator.py\n@@ -1,4 +1,5 @@\n import numbers\n+from pathlib import Path\n from typing import Mapping, Union\n \n import jsonschema\n@@ -70,12 +71,15 @@\n \n     version = version or variables.SCHEMA_VERSION\n \n-    schema = load_schema(f'{version}/{schema_name}')\n+    schema = load_schema(str(Path(version).joinpath(schema_name)))\n \n-    # note: trailing slash needed for RefResolver to resolve correctly\n+    # note: trailing slash needed for RefResolver to resolve correctly and by\n+    # design, pathlib strips trailing slashes. See ref below:\n+    # * https://bugs.python.org/issue21039\n+    # * https://github.com/python/cpython/issues/65238\n     resolver = jsonschema.RefResolver(\n-        base_uri=f\"file://{variables.schemas}/{version}/\",\n-        referrer=f\"{schema_name}\",\n+        base_uri=f\"{Path(variables.schemas).joinpath(version).as_uri()}/\",\n+        referrer=schema_name,\n         store=variables.SCHEMA_CACHE,\n     )\n", "issue": "jsonschema cannot find path specified \\\\1.0.0\\\\def.json\n### Summary\r\n\r\nWhen I try to install pyhf in a venv and then create a simple model, it gives me a n error \r\n```\r\n<urlopen error [WinError 3] The system cannot find the path specified: '\\\\1.0.0\\\\defs.json'>\r\n```\r\n\r\nWhen i check the path to the schema with \r\n```\r\n>>> pyhf.schema.path\r\nWindowsPath('C:/Users/alexh/Downloads/pyhf_test/pyhf_venv/Lib/site-packages/pyhf/schemas')\r\n```\r\nFollowing this path then into the 1.0.0 folder, defs.json exists.\r\n\r\n### OS / Environment\r\n\r\n```console\r\n# Windows 11\r\n# Python 3.11.6\r\n```\r\n\r\n\r\n### Steps to Reproduce\r\n\r\n\r\n```\r\n$ python -m venv venv_pyhf\r\n$ venv_pyhf/Scripts/activate.ps1\r\n$ pip install pyhf\r\n$ python\r\n>>> import pyhf\r\n>>> model = pyhf.simplemodels.uncorrelated_background(signal=[1,2,3], bkg=[4,5,6], bkg_uncertainty=[2,3,4])\r\n_RefResolutionError: <urlopen error [WinError 3] The system cannot find the path specified: '\\\\1.0.0\\\\defs.json'>\r\n```\r\n\r\n\r\n### File Upload (optional)\r\n\r\n_No response_\r\n\r\n### Expected Results\r\n\r\nExpected to get a pyhf.pdf.Model.\r\n\r\n### Actual Results\r\n\r\n```console\r\nTraceback (most recent call last):\r\n  File \"C:\\Users\\alexh\\Downloads\\pyhf_test\\pyhf_venv\\Lib\\site-packages\\jsonschema\\validators.py\", line 1097, in resolve_from_url\r\n    document = self.store[url]\r\n               ~~~~~~~~~~^^^^^\r\n  File \"C:\\Users\\alexh\\Downloads\\pyhf_test\\pyhf_venv\\Lib\\site-packages\\jsonschema\\_utils.py\", line 20, in __getitem__\r\n    return self.store[self.normalize(uri)]\r\n           ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^\r\nKeyError: 'file://C:\\\\Users\\\\alexh\\\\Downloads\\\\pyhf_test\\\\pyhf_venv\\\\Lib\\\\site-packages\\\\pyhf\\\\schemas/1.0.0/defs.json'\r\n\r\nDuring handling of the above exception, another exception occurred:\r\n\r\nTraceback (most recent call last):\r\n  File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.11_3.11.1776.0_x64__qbz5n2kfra8p0\\Lib\\urllib\\request.py\", line 1505, in open_local_file\r\n    stats = os.stat(localfile)\r\n            ^^^^^^^^^^^^^^^^^^\r\nFileNotFoundError: [WinError 3] The system cannot find the path specified: '\\\\1.0.0\\\\defs.json'\r\n\r\nDuring handling of the above exception, another exception occurred:\r\n\r\nTraceback (most recent call last):\r\n  File \"C:\\Users\\alexh\\Downloads\\pyhf_test\\pyhf_venv\\Lib\\site-packages\\jsonschema\\validators.py\", line 1100, in resolve_from_url\r\n    document = self.resolve_remote(url)\r\n               ^^^^^^^^^^^^^^^^^^^^^^^^\r\n  File \"C:\\Users\\alexh\\Downloads\\pyhf_test\\pyhf_venv\\Lib\\site-packages\\jsonschema\\validators.py\", line 1204, in resolve_remote\r\n    with urlopen(uri) as url:\r\n         ^^^^^^^^^^^^\r\n  File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.11_3.11.1776.0_x64__qbz5n2kfra8p0\\Lib\\urllib\\request.py\", line 216, in urlopen\r\n    return opener.open(url, data, timeout)\r\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\n  File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.11_3.11.1776.0_x64__qbz5n2kfra8p0\\Lib\\urllib\\request.py\", line 519, in open\r\n    response = self._open(req, data)\r\n               ^^^^^^^^^^^^^^^^^^^^^\r\n  File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.11_3.11.1776.0_x64__qbz5n2kfra8p0\\Lib\\urllib\\request.py\", line 536, in _open\r\n    result = self._call_chain(self.handle_open, protocol, protocol +\r\n             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\n  File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.11_3.11.1776.0_x64__qbz5n2kfra8p0\\Lib\\urllib\\request.py\", line 496, in _call_chain\r\n    result = func(*args)\r\n             ^^^^^^^^^^^\r\n  File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.11_3.11.1776.0_x64__qbz5n2kfra8p0\\Lib\\urllib\\request.py\", line 1483, in file_open\r\n    return self.open_local_file(req)\r\n           ^^^^^^^^^^^^^^^^^^^^^^^^^\r\n  File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.11_3.11.1776.0_x64__qbz5n2kfra8p0\\Lib\\urllib\\request.py\", line 1522, in open_local_file\r\n    raise URLError(exp)\r\nurllib.error.URLError: <urlopen error [WinError 3] The system cannot find the path specified: '\\\\1.0.0\\\\defs.json'>\r\n\r\nDuring handling of the above exception, another exception occurred:\r\n\r\nTraceback (most recent call last):\r\n  File \"<stdin>\", line 1, in <module>\r\n  File \"C:\\Users\\alexh\\Downloads\\pyhf_test\\pyhf_venv\\Lib\\site-packages\\pyhf\\simplemodels.py\", line 149, in uncorrelated_background\r\n    return Model(spec, batch_size=batch_size, validate=validate)\r\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\n  File \"C:\\Users\\alexh\\Downloads\\pyhf_test\\pyhf_venv\\Lib\\site-packages\\pyhf\\pdf.py\", line 769, in __init__\r\n    schema.validate(self.spec, self.schema, version=self.version)\r\n  File \"C:\\Users\\alexh\\Downloads\\pyhf_test\\pyhf_venv\\Lib\\site-packages\\pyhf\\schema\\validator.py\", line 93, in validate\r\n    return validator.validate(spec)\r\n           ^^^^^^^^^^^^^^^^^^^^^^^^\r\n  File \"C:\\Users\\alexh\\Downloads\\pyhf_test\\pyhf_venv\\Lib\\site-packages\\jsonschema\\validators.py\", line 434, in validate\r\n    for error in self.iter_errors(*args, **kwargs):\r\n  File \"C:\\Users\\alexh\\Downloads\\pyhf_test\\pyhf_venv\\Lib\\site-packages\\jsonschema\\validators.py\", line 368, in iter_errors\r\n    for error in errors:\r\n  File \"C:\\Users\\alexh\\Downloads\\pyhf_test\\pyhf_venv\\Lib\\site-packages\\jsonschema\\_keywords.py\", line 284, in ref\r\n    yield from validator._validate_reference(ref=ref, instance=instance)\r\n               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\n  File \"C:\\Users\\alexh\\Downloads\\pyhf_test\\pyhf_venv\\Lib\\site-packages\\jsonschema\\validators.py\", line 461, in _validate_reference\r\n    scope, resolved = resolve(ref)\r\n                      ^^^^^^^^^^^^\r\n  File \"C:\\Users\\alexh\\Downloads\\pyhf_test\\pyhf_venv\\Lib\\site-packages\\jsonschema\\validators.py\", line 1086, in resolve\r\n    return url, self._remote_cache(url)\r\n                ^^^^^^^^^^^^^^^^^^^^^^^\r\n  File \"C:\\Users\\alexh\\Downloads\\pyhf_test\\pyhf_venv\\Lib\\site-packages\\jsonschema\\validators.py\", line 1102, in resolve_from_url\r\n    raise exceptions._RefResolutionError(exc)\r\njsonschema.exceptions._RefResolutionError: <urlopen error [WinError 3] The system cannot find the path specified: '\\\\1.0.0\\\\defs.json'>\r\n```\r\n\r\n\r\n### pyhf Version\r\n\r\n```console\r\npyhf, version 0.7.4\r\n```\r\n\r\n\r\n### Code of Conduct\r\n\r\n- [X] I agree to follow the Code of Conduct\n", "before_files": [{"content": "import numbers\nfrom typing import Mapping, Union\n\nimport jsonschema\n\nimport pyhf.exceptions\nfrom pyhf import tensor\nfrom pyhf.schema import variables\nfrom pyhf.schema.loader import load_schema\n\n\ndef _is_array_or_tensor(checker, instance):\n    \"\"\"\n    A helper function for allowing the validation of tensors as list types in schema validation.\n\n    .. warning:\n\n        This will check for valid array types using any backends that have been loaded so far.\n    \"\"\"\n    return isinstance(instance, (list, *tensor.array_types))\n\n\ndef _is_number_or_tensor_subtype(checker, instance):\n    \"\"\"\n    A helper function for allowing the validation of tensor contents as number types in schema validation.\n\n    .. warning:\n        This will check for valid array subtypes using any backends that have been loaded so far.\n    \"\"\"\n    is_number = jsonschema._types.is_number(checker, instance)\n    if is_number:\n        return True\n    return isinstance(instance, (numbers.Number, *tensor.array_subtypes))\n\n\ndef validate(\n    spec: Mapping,\n    schema_name: str,\n    *,\n    version: Union[str, None] = None,\n    allow_tensors: bool = True,\n):\n    \"\"\"\n    Validate the provided instance, ``spec``, against the schema associated with ``schema_name``.\n\n    Args:\n        spec (:obj:`object`): An object instance to validate against a schema.\n        schema_name (:obj:`string`): The name of a schema to validate against.\n         See :func:`pyhf.schema.load_schema` for more details.\n        version (:obj:`string`): The version of the schema to use.\n         See :func:`pyhf.schema.load_schema` for more details.\n        allow_tensors (:obj:`bool`): A flag to enable or disable tensors as part of schema validation.\n         If enabled, tensors in the ``spec`` will be treated like python :obj:`list`.\n         Default: ``True``.\n\n    Raises:\n        ~pyhf.exceptions.InvalidSpecification: if the provided instance does not validate against the schema.\n\n    Returns:\n        None: if there are no errors with the provided instance.\n\n    Example:\n        >>> import pyhf\n        >>> model = pyhf.simplemodels.uncorrelated_background(\n        ...     signal=[12.0, 11.0], bkg=[50.0, 52.0], bkg_uncertainty=[3.0, 7.0]\n        ... )\n        >>> pyhf.schema.validate(model.spec, \"model.json\")\n        >>>\n    \"\"\"\n\n    version = version or variables.SCHEMA_VERSION\n\n    schema = load_schema(f'{version}/{schema_name}')\n\n    # note: trailing slash needed for RefResolver to resolve correctly\n    resolver = jsonschema.RefResolver(\n        base_uri=f\"file://{variables.schemas}/{version}/\",\n        referrer=f\"{schema_name}\",\n        store=variables.SCHEMA_CACHE,\n    )\n\n    Validator = jsonschema.Draft6Validator\n\n    if allow_tensors:\n        type_checker = Validator.TYPE_CHECKER.redefine(\n            \"array\", _is_array_or_tensor\n        ).redefine(\"number\", _is_number_or_tensor_subtype)\n        Validator = jsonschema.validators.extend(Validator, type_checker=type_checker)\n\n    validator = Validator(schema, resolver=resolver, format_checker=None)\n\n    try:\n        return validator.validate(spec)\n    except jsonschema.ValidationError as err:\n        raise pyhf.exceptions.InvalidSpecification(err, schema_name)\n", "path": "src/pyhf/schema/validator.py"}], "after_files": [{"content": "import numbers\nfrom pathlib import Path\nfrom typing import Mapping, Union\n\nimport jsonschema\n\nimport pyhf.exceptions\nfrom pyhf import tensor\nfrom pyhf.schema import variables\nfrom pyhf.schema.loader import load_schema\n\n\ndef _is_array_or_tensor(checker, instance):\n    \"\"\"\n    A helper function for allowing the validation of tensors as list types in schema validation.\n\n    .. warning:\n\n        This will check for valid array types using any backends that have been loaded so far.\n    \"\"\"\n    return isinstance(instance, (list, *tensor.array_types))\n\n\ndef _is_number_or_tensor_subtype(checker, instance):\n    \"\"\"\n    A helper function for allowing the validation of tensor contents as number types in schema validation.\n\n    .. warning:\n        This will check for valid array subtypes using any backends that have been loaded so far.\n    \"\"\"\n    is_number = jsonschema._types.is_number(checker, instance)\n    if is_number:\n        return True\n    return isinstance(instance, (numbers.Number, *tensor.array_subtypes))\n\n\ndef validate(\n    spec: Mapping,\n    schema_name: str,\n    *,\n    version: Union[str, None] = None,\n    allow_tensors: bool = True,\n):\n    \"\"\"\n    Validate the provided instance, ``spec``, against the schema associated with ``schema_name``.\n\n    Args:\n        spec (:obj:`object`): An object instance to validate against a schema.\n        schema_name (:obj:`string`): The name of a schema to validate against.\n         See :func:`pyhf.schema.load_schema` for more details.\n        version (:obj:`string`): The version of the schema to use.\n         See :func:`pyhf.schema.load_schema` for more details.\n        allow_tensors (:obj:`bool`): A flag to enable or disable tensors as part of schema validation.\n         If enabled, tensors in the ``spec`` will be treated like python :obj:`list`.\n         Default: ``True``.\n\n    Raises:\n        ~pyhf.exceptions.InvalidSpecification: if the provided instance does not validate against the schema.\n\n    Returns:\n        None: if there are no errors with the provided instance.\n\n    Example:\n        >>> import pyhf\n        >>> model = pyhf.simplemodels.uncorrelated_background(\n        ...     signal=[12.0, 11.0], bkg=[50.0, 52.0], bkg_uncertainty=[3.0, 7.0]\n        ... )\n        >>> pyhf.schema.validate(model.spec, \"model.json\")\n        >>>\n    \"\"\"\n\n    version = version or variables.SCHEMA_VERSION\n\n    schema = load_schema(str(Path(version).joinpath(schema_name)))\n\n    # note: trailing slash needed for RefResolver to resolve correctly and by\n    # design, pathlib strips trailing slashes. See ref below:\n    # * https://bugs.python.org/issue21039\n    # * https://github.com/python/cpython/issues/65238\n    resolver = jsonschema.RefResolver(\n        base_uri=f\"{Path(variables.schemas).joinpath(version).as_uri()}/\",\n        referrer=schema_name,\n        store=variables.SCHEMA_CACHE,\n    )\n\n    Validator = jsonschema.Draft6Validator\n\n    if allow_tensors:\n        type_checker = Validator.TYPE_CHECKER.redefine(\n            \"array\", _is_array_or_tensor\n        ).redefine(\"number\", _is_number_or_tensor_subtype)\n        Validator = jsonschema.validators.extend(Validator, type_checker=type_checker)\n\n    validator = Validator(schema, resolver=resolver, format_checker=None)\n\n    try:\n        return validator.validate(spec)\n    except jsonschema.ValidationError as err:\n        raise pyhf.exceptions.InvalidSpecification(err, schema_name)\n", "path": "src/pyhf/schema/validator.py"}]}