Skip to content

Commit

Permalink
Merge pull request #202 from marl/jsonschema3
Browse files Browse the repository at this point in the history
Support jsonschema>=3.0
  • Loading branch information
bmcfee authored Aug 13, 2019
2 parents ebdfd77 + a9857eb commit 9088b87
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
10 changes: 5 additions & 5 deletions jams/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ def validate(self, strict=True):
valid = True

try:
jsonschema.validate(self.__json__, self.__schema__)
schema.VALIDATOR.validate(self.__json__, self.__schema__)

except jsonschema.ValidationError as invalid:
if strict:
Expand Down Expand Up @@ -766,12 +766,12 @@ def validate(self, strict=True):
valid = True

try:
jsonschema.validate(self.__json_light__(data=False),
schema.JAMS_SCHEMA)
schema.VALIDATOR.validate(self.__json_light__(data=False),
schema.JAMS_SCHEMA)

# validate each record in the frame
data_ser = [serialize_obj(obs) for obs in self.data]
jsonschema.validate(data_ser, ann_schema)
schema.VALIDATOR.validate(data_ser, ann_schema)

except jsonschema.ValidationError as invalid:
if strict:
Expand Down Expand Up @@ -1805,7 +1805,7 @@ def validate(self, strict=True):
'''
valid = True
try:
jsonschema.validate(self.__json_light__, schema.JAMS_SCHEMA)
schema.VALIDATOR.validate(self.__json_light__, schema.JAMS_SCHEMA)

for ann in self.annotations:
if isinstance(ann, Annotation):
Expand Down
4 changes: 3 additions & 1 deletion jams/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@
from pkg_resources import resource_filename

import numpy as np
import jsonschema

from .exceptions import NamespaceError, JamsError

__all__ = ['add_namespace', 'namespace', 'is_dense', 'values', 'get_dtypes']
__all__ = ['add_namespace', 'namespace', 'is_dense', 'values', 'get_dtypes', 'VALIDATOR']

__NAMESPACE__ = dict()

Expand Down Expand Up @@ -248,3 +249,4 @@ def __load_jams_schema():
NS_SCHEMA_DIR = os.path.join(SCHEMA_DIR, 'namespaces')

JAMS_SCHEMA = __load_jams_schema()
VALIDATOR = jsonschema.Draft4Validator(JAMS_SCHEMA)
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
install_requires=[
'pandas',
'sortedcontainers>=2.0.0',
'jsonschema==2.6',
'jsonschema>=3.0.0',
'numpy>=1.8.0',
'six',
'decorator',
Expand Down

0 comments on commit 9088b87

Please sign in to comment.