mirror of
https://github.com/clearml/clearml
synced 2025-02-11 23:33:21 +00:00
Fix several jsonschema DeprecationWarning (#1128)
* address DeprecationWarnings from jsonschema * use `referencing` for Python >= 3.8 * undo unrelated change by auto linter
This commit is contained in:
parent
489dee0e92
commit
e89b2a03a7
@ -1,7 +1,14 @@
|
|||||||
import abc
|
import abc
|
||||||
|
|
||||||
import jsonschema
|
|
||||||
import six
|
import six
|
||||||
|
from jsonschema.exceptions import FormatError, SchemaError, ValidationError
|
||||||
|
|
||||||
|
try:
|
||||||
|
# Since `referencing`` only supports Python >= 3.8, this try-except blocks maintain support
|
||||||
|
# for earlier python versions.
|
||||||
|
from referencing.exceptions import Unresolvable
|
||||||
|
except ImportError:
|
||||||
|
from jsonschema.exceptions import RefResolutionError as Unresolvable
|
||||||
|
|
||||||
from .apimodel import ApiModel
|
from .apimodel import ApiModel
|
||||||
from .datamodel import DataModel
|
from .datamodel import DataModel
|
||||||
@ -39,8 +46,7 @@ class BatchRequest(Request):
|
|||||||
|
|
||||||
_batched_request_cls = abc.abstractproperty()
|
_batched_request_cls = abc.abstractproperty()
|
||||||
|
|
||||||
_schema_errors = (jsonschema.SchemaError, jsonschema.ValidationError, jsonschema.FormatError,
|
_schema_errors = (SchemaError, ValidationError, FormatError, Unresolvable)
|
||||||
jsonschema.RefResolutionError)
|
|
||||||
|
|
||||||
def __init__(self, requests, validate_requests=False, allow_raw_requests=True, **kwargs):
|
def __init__(self, requests, validate_requests=False, allow_raw_requests=True, **kwargs):
|
||||||
super(BatchRequest, self).__init__(**kwargs)
|
super(BatchRequest, self).__init__(**kwargs)
|
||||||
@ -70,8 +76,7 @@ class BatchRequest(Request):
|
|||||||
for i, req in enumerate(self.requests):
|
for i, req in enumerate(self.requests):
|
||||||
try:
|
try:
|
||||||
req.validate()
|
req.validate()
|
||||||
except (jsonschema.SchemaError, jsonschema.ValidationError,
|
except (SchemaError, ValidationError, FormatError, Unresolvable) as e:
|
||||||
jsonschema.FormatError, jsonschema.RefResolutionError) as e:
|
|
||||||
raise Exception('Validation error in batch item #%d: %s' % (i, str(e)))
|
raise Exception('Validation error in batch item #%d: %s' % (i, str(e)))
|
||||||
|
|
||||||
def get_json(self):
|
def get_json(self):
|
||||||
|
@ -14,6 +14,7 @@ python-dateutil>=2.6.1
|
|||||||
pyjwt>=2.4.0,<2.9.0 ; python_version > '3.5'
|
pyjwt>=2.4.0,<2.9.0 ; python_version > '3.5'
|
||||||
pyjwt>=1.6.4,<2.0.0 ; python_version <= '3.5'
|
pyjwt>=1.6.4,<2.0.0 ; python_version <= '3.5'
|
||||||
PyYAML>=3.12
|
PyYAML>=3.12
|
||||||
|
referencing<0.40 ; python_version >= '3.8'
|
||||||
requests>=2.20.0
|
requests>=2.20.0
|
||||||
six>=1.13.0
|
six>=1.13.0
|
||||||
typing>=3.6.4 ; python_version < '3.5'
|
typing>=3.6.4 ; python_version < '3.5'
|
||||||
|
Loading…
Reference in New Issue
Block a user