Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions src/allotropy/allotrope/allotrope.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

import copy
from typing import Any

import jsonschema
Expand All @@ -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:
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/allotropy/testing/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Loading