Skip to content

Commit

Permalink
Use referencing library
Browse files Browse the repository at this point in the history
  • Loading branch information
sameeul committed Nov 10, 2024
1 parent 17d6716 commit 4f16b6c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ dependencies = [
"toil[cwl]",
"fastapi",
"python-jose",
"uvicorn"
"uvicorn",
"referencing"
]

[project.readme]
Expand Down
9 changes: 5 additions & 4 deletions src/sophios/schemas/wic_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.'
Expand All @@ -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

0 comments on commit 4f16b6c

Please sign in to comment.