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

use ValidationError from asdf.exceptions instead of jsonschema #234

Merged
merged 3 commits into from
Jul 10, 2023
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
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
keyword was meant to address; namely, passing a datamodel instance to the constructor for
that datamodel instance should return the instance back with no modifications. [#235]

- Use ValidationError from asdf.exceptions instead of jsonschema. Increase minimum
asdf version to 2.15.0. [#234]

0.16.1 (2023-06-27)
===================

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ classifiers = [
'Programming Language :: Python :: 3',
]
dependencies = [
'asdf >=2.14.2',
'asdf >=2.15.0',
'asdf-astropy >=0.4.0',
'gwcs >=0.18.1',
'psutil >=5.7.2',
Expand Down
2 changes: 1 addition & 1 deletion src/roman_datamodels/datamodels/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

import asdf
import numpy as np
from asdf.exceptions import ValidationError
from astropy.time import Time
from jsonschema import ValidationError

from roman_datamodels import stnode, validate

Expand Down
6 changes: 3 additions & 3 deletions src/roman_datamodels/stnode/_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
import asdf
import asdf.schema as asdfschema
import asdf.yamlutil as yamlutil
import jsonschema
import numpy as np
from asdf.exceptions import ValidationError
from asdf.tags.core import ndarray
from asdf.util import HashableDict
from astropy.time import Time
Expand All @@ -36,13 +36,13 @@ def _value_change(path, value, schema, pass_invalid_values, strict_validation, c
_check_value(value, schema, ctx)
update = True

except jsonschema.ValidationError as error:
except ValidationError as error:
update = False
errmsg = _error_message(path, error)
if pass_invalid_values:
update = True
if strict_validation:
raise jsonschema.ValidationError(errmsg)
raise ValidationError(errmsg)
else:
warnings.warn(errmsg, ValidationWarning)
return update
Expand Down
4 changes: 2 additions & 2 deletions src/roman_datamodels/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
from contextlib import contextmanager
from textwrap import dedent

import jsonschema
from asdf import AsdfFile
from asdf import schema as asdf_schema
from asdf import yamlutil
from asdf.exceptions import ValidationError
from asdf.util import HashableDict

__all__ = [
Expand Down Expand Up @@ -94,7 +94,7 @@ def value_change(value, pass_invalid_values, strict_validation):
try:
_check_value(value)
update = True
except jsonschema.ValidationError as errmsg:
except ValidationError as errmsg:
update = False
if pass_invalid_values:
update = True
Expand Down
2 changes: 1 addition & 1 deletion tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
import asdf
import numpy as np
import pytest
from asdf.exceptions import ValidationError
from astropy import units as u
from astropy.modeling import Model
from jsonschema import ValidationError
from numpy.testing import assert_array_equal

from roman_datamodels import datamodels
Expand Down