Skip to content

Commit 9109c4d

Browse files
chore: Skip uri-reference schema format check (#1063)
If the python environment has certain validators installed, jsonschema will add the uri-reference format validator, which the ASM schemas currently fail against. So, remove it from our validation check.
1 parent 20f0202 commit 9109c4d

2 files changed

Lines changed: 12 additions & 4 deletions

File tree

src/allotropy/allotrope/allotrope.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import annotations
22

3+
import copy
34
from typing import Any
45

56
import jsonschema
@@ -11,6 +12,12 @@
1112
AllotropeValidationError,
1213
)
1314

15+
# Override format checker to remove "uri-reference" check, which ASM schemas fail against.
16+
FORMAT_CHECKER = copy.deepcopy(
17+
jsonschema.validators.Draft202012Validator.FORMAT_CHECKER
18+
)
19+
FORMAT_CHECKER.checkers.pop("uri-reference", None)
20+
1421

1522
def serialize_and_validate_allotrope(model: Any) -> dict[str, Any]:
1623
try:
@@ -26,11 +33,11 @@ def serialize_and_validate_allotrope(model: Any) -> dict[str, Any]:
2633
raise AllotropeSerializationError(msg) from e
2734

2835
try:
29-
jsonschema.validate(
30-
allotrope_dict,
31-
allotrope_schema,
32-
cls=jsonschema.validators.Draft202012Validator,
36+
jsonschema.validators.Draft202012Validator.check_schema(
37+
allotrope_schema, format_checker=FORMAT_CHECKER
3338
)
39+
validator = jsonschema.validators.Draft202012Validator(allotrope_schema)
40+
validator.validate(allotrope_dict)
3441
except Exception as e:
3542
msg = f"Failed to validate allotrope model against schema: {e}"
3643
raise AllotropeValidationError(msg) from e

src/allotropy/testing/utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ def _replace_asm_converter_version(allotrope_dict: DictType) -> DictType:
4545
"batch identifier",
4646
"data source identifier",
4747
"device identifier",
48+
"device method identifier",
4849
"experimental data identifier",
4950
"flow cell identifier",
5051
"group identifier",

0 commit comments

Comments
 (0)