mirror of
https://github.com/clearml/clearml-agent
synced 2025-02-07 13:26:08 +00:00
Fix using deprecated types validator argument raises an error (deprecated even before jsonschema 3.0.0 and unsupported since 4.0.0)
This commit is contained in:
parent
5d517c91b5
commit
669fb1a6e5
@ -66,11 +66,16 @@ class DataModel(object):
|
|||||||
}
|
}
|
||||||
|
|
||||||
def validate(self, schema=None):
|
def validate(self, schema=None):
|
||||||
jsonschema.validate(
|
schema = schema or self._schema
|
||||||
self.to_dict(),
|
validator = jsonschema.validators.validator_for(schema)
|
||||||
schema or self._schema,
|
validator_cls = jsonschema.validators.extend(
|
||||||
types=dict(array=(list, tuple), integer=six.integer_types),
|
validator=validator,
|
||||||
|
type_checker=validator.TYPE_CHECKER.redefine_many({
|
||||||
|
"array": lambda s, instance: isinstance(instance, (list, tuple)),
|
||||||
|
"integer": lambda s, instance: isinstance(instance, six.integer_types),
|
||||||
|
}),
|
||||||
)
|
)
|
||||||
|
jsonschema.validate(self.to_dict(), schema, cls=validator_cls)
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return '<{}.{}: {}>'.format(
|
return '<{}.{}: {}>'.format(
|
||||||
|
Loading…
Reference in New Issue
Block a user