Skip to content

Commit

Permalink
update schema validatoin code
Browse files Browse the repository at this point in the history
  • Loading branch information
sameeul committed Nov 11, 2024
1 parent 2e26d0d commit bf24452
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/sophios/schemas/wic_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import graphviz
from jsonschema import Draft202012Validator
from referencing import Registry, Resource
from referencing.jsonschema import DRAFT202012
import yaml

import sophios
Expand Down Expand Up @@ -681,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 @@ -697,9 +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.
resource: Resource = Resource.from_contents(schema_store)
initial_registry: Registry = Registry()
registry: Registry = resource @ initial_registry
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 Down

0 comments on commit bf24452

Please sign in to comment.