diff --git a/src/allotropy/allotrope/allotrope.py b/src/allotropy/allotrope/allotrope.py index a328e47397..74e51d5eaf 100644 --- a/src/allotropy/allotrope/allotrope.py +++ b/src/allotropy/allotrope/allotrope.py @@ -1,5 +1,6 @@ from __future__ import annotations +import copy from typing import Any import jsonschema @@ -11,6 +12,12 @@ AllotropeValidationError, ) +# Override format checker to remove "uri-reference" check, which ASM schemas fail against. +FORMAT_CHECKER = copy.deepcopy( + jsonschema.validators.Draft202012Validator.FORMAT_CHECKER +) +FORMAT_CHECKER.checkers.pop("uri-reference", None) + def serialize_and_validate_allotrope(model: Any) -> dict[str, Any]: try: @@ -26,11 +33,11 @@ def serialize_and_validate_allotrope(model: Any) -> dict[str, Any]: raise AllotropeSerializationError(msg) from e try: - jsonschema.validate( - allotrope_dict, - allotrope_schema, - cls=jsonschema.validators.Draft202012Validator, + jsonschema.validators.Draft202012Validator.check_schema( + allotrope_schema, format_checker=FORMAT_CHECKER ) + validator = jsonschema.validators.Draft202012Validator(allotrope_schema) + validator.validate(allotrope_dict) except Exception as e: msg = f"Failed to validate allotrope model against schema: {e}" raise AllotropeValidationError(msg) from e diff --git a/src/allotropy/testing/utils.py b/src/allotropy/testing/utils.py index d2c4c44ed2..bc8853d1a3 100644 --- a/src/allotropy/testing/utils.py +++ b/src/allotropy/testing/utils.py @@ -45,6 +45,7 @@ def _replace_asm_converter_version(allotrope_dict: DictType) -> DictType: "batch identifier", "data source identifier", "device identifier", + "device method identifier", "experimental data identifier", "flow cell identifier", "group identifier",