Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove jsonschema version constrain #287

Merged
merged 5 commits into from
Nov 12, 2024
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
5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ dependencies = [
# This 'graphviz' is equivalent to `conda install python-graphviz` or
# `sudo apt install python3-graphviz` ONLY.
"graphviz",
"jsonschema<4.18", # temporarily downgrade due to severe performance regression
"jsonschema",
"pyyaml",
"requests",
"mergedeep",
Expand All @@ -42,7 +42,8 @@ dependencies = [
"toil[cwl]",
"fastapi",
"python-jose",
"uvicorn"
"uvicorn",
"referencing"
]

[project.readme]
Expand Down
13 changes: 9 additions & 4 deletions src/sophios/schemas/wic_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@

import networkx as nx
import graphviz
from jsonschema import RefResolver, Draft202012Validator
from jsonschema import Draft202012Validator
from referencing import Registry, Resource
from referencing.jsonschema import DRAFT202012
import yaml

import sophios
Expand Down Expand Up @@ -680,7 +682,6 @@ def get_validator(tools_cwl: Tools, yml_stems: List[str], schema_store: Dict[str

schema = wic_main_schema(tools_cwl, yml_stems, schema_store, hypothesis)
schema_store[schema['$id']] = schema
schema_store['wic_tag'] = wic_tag_schema(hypothesis)
if write_to_disk:
with open('autogenerated/schemas/wic.json', mode='w', encoding='utf-8') as f:
f.write(json.dumps(schema, indent=2))
Expand All @@ -696,7 +697,11 @@ 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)
schema_store_resource: Resource = Resource(contents=schema_store, specification=DRAFT202012) # type: ignore
registry: Registry = Registry().with_resource(uri="wic_schema_store", resource=schema_store_resource)
wic_tag_schema_resource: Resource = Resource(contents=wic_tag_schema(
hypothesis), specification=DRAFT202012) # type: ignore
registry = registry.with_resource(uri="wic_tag", resource=wic_tag_schema_resource)
""" 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 +712,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)
validator = Draft202012Validator(schema, registry=registry)
return validator
Loading