From 2c6dafc7f6779a7dd97a49d127ff9b8cd43ffa18 Mon Sep 17 00:00:00 2001 From: Sameeul Samee Date: Sun, 10 Nov 2024 08:14:50 -0500 Subject: [PATCH] Use referencing library --- pyproject.toml | 3 ++- src/sophios/schemas/wic_schema.py | 9 +++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 261cbfe6..f9a20db6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -42,7 +42,8 @@ dependencies = [ "toil[cwl]", "fastapi", "python-jose", - "uvicorn" + "uvicorn", + "referencing" ] [project.readme] diff --git a/src/sophios/schemas/wic_schema.py b/src/sophios/schemas/wic_schema.py index d5d07db4..a32e354e 100644 --- a/src/sophios/schemas/wic_schema.py +++ b/src/sophios/schemas/wic_schema.py @@ -5,7 +5,8 @@ import networkx as nx import graphviz -from jsonschema import RefResolver, Draft202012Validator +from jsonschema import Draft202012Validator +import referencing import yaml import sophios @@ -696,7 +697,7 @@ def get_validator(tools_cwl: Tools, yml_stems: List[str], schema_store: Dict[str # The $ref tag refers to URIs defined in $id tags, NOT relative paths on # the local filesystem! We need to create a global mapping between ids and schemas # i.e. schema_store. - resolver = RefResolver.from_schema(schema, store=schema_store) + registry = referencing.Registry(retrieve=lambda uri: schema_store.get(uri)) """ Use check_schema to 'first verify that the provided schema is itself valid, since not doing so can lead to less obvious error messages and fail in less obvious or consistent ways.' @@ -707,5 +708,5 @@ def get_validator(tools_cwl: Tools, yml_stems: List[str], schema_store: Dict[str # try temporarily commenting this line out to generate the schema anyway. # Then, in any yml file, the very first line should show a "schema stack trace" Draft202012Validator.check_schema(schema) - validator = Draft202012Validator(schema, resolver=resolver) - return validator + validator = Draft202012Validator(schema, registry=registry) + return validator \ No newline at end of file