-
Notifications
You must be signed in to change notification settings - Fork 14
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
import ValidationError from asdf, drop jsonschema as a dependency #295
Conversation
Codecov ReportAll modified lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #295 +/- ##
=======================================
Coverage 98.28% 98.28%
=======================================
Files 40 40
Lines 2451 2452 +1
=======================================
+ Hits 2409 2410 +1
Misses 42 42
☔ View full report in Codecov by Sentry. |
setup.cfg
Outdated
asdf>=2.9.2 | ||
asdf>=2.15.1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for the PR. I think this is my main issue with this, I am not sure it's really practical for us to pull in the very latest version of asdf.
Does asdf throw a version warning if you load a file with new asdf or just third party plugins?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for taking and look and for the response.
I tested reading and writing asdf files across versions (2.9.2 and 2.15.0). In both cases the file was produced with:
t = astropy.time.Time(1.0, format='mjd')
af = asdf.AsdfFile({'t': t})
af.write_to('time.asdf')
For 2.9.2 I installed asdf-astropy==0.1.1
(to match the minimum pin in this package). For 2.15.0 I installed asdf-astropy==0.4.0
.
Opening the file written with asdf 2.9.2 in asdf 2.15.0 produced no warnings as all the extensions used to produce the file were installed and were at least the same (or in this case newer) versions.
Opening the file written with asdf 2.15.0 in asdf 2.9.2 produced two warnings, one for the asdf-astropy extension and one for the builtin
extension that handles the asdf core objects:
/Users/bgraham/.pyenv/versions/3.10.6/envs/dkist_asdf_downstream/lib/python3.10/site-packages/asdf/asdf.py:348: AsdfWarning: File 'file:///Users/bgraham/Desktop/time.asdf' was created with extension class 'asdf.extension.BuiltinExtension' (from package asdf==2.15.0), but older package (asdf==2.9.2) is installed.
warnings.warn(msg, AsdfWarning)
/Users/bgraham/.pyenv/versions/3.10.6/envs/dkist_asdf_downstream/lib/python3.10/site-packages/asdf/asdf.py:348: AsdfWarning: File 'file:///Users/bgraham/Desktop/time.asdf' was created with extension URI 'asdf://asdf-format.org/core/extensions/core-1.5.0' (from package asdf-astropy==0.4.0), but older package (asdf-astropy==0.1.1) is installed.
warnings.warn(msg, AsdfWarning)
I'm trying to think of a way to not pin asdf to at least 2.15.0. I can think of three options:
-
Drop jsonschema as a dependency and import
ValidationError
from the top levelasdf
. It appears that this was available at least as far back as 2.9. I should note that havingValidationError
exposed at the top levelasdf
will likely be deprecated in asdf 3.x.x and removed in 4.0.0. It's probably ambitious to say 4.0.0 will come out in the next 6 months (and as we don't yet have a concrete roadmap for the included changes it will likely take longer) but the deprecation ofasdf.ValidationError
in favor ofasdf.exceptions.ValidationError
will come much sooner and likely soon after the 3.0.0 release (which I'm hoping will happen in the next few months at the latest). This deprecation warning can always be ignored so this does seem like an ok option for keeping the lower pin at 2.9.2 and dropping jsonschema. -
Keep jsonschema as a dependency and change the
ValidationError
imports to first try fromasdf.exceptions
and then fall back to jsonschema. -
Drop jsonschema and change the imports to first try from
asdf.exceptions
and then fromasdf
. I kind of like this option the best but I'm happy to make whatever changes you'd like.
I will update this PR for option 3 above but please let me know if you'd rather go with one of the other options or if you have other plans for keeping the pin. Thanks!
6a8e7b5
to
2621e4a
Compare
first try to import ValidationError from asdf.exceptions then fallback to importing from the top level asdf if this fails.
33a8d80
to
ddb0284
Compare
ddb0284
to
22171f9
Compare
…ISTDC#295) * import ValidationError from asdf, drop jsonschema as a dependency * add changelog entry * fix import order * incraese minimum asdf-transform-schemas version * add attempt to import ValidationError first try to import ValidationError from asdf.exceptions then fallback to importing from the top level asdf if this fails. * sort imports * add changelog entry * add comment about ValidationError import
asdf has recently run into compatibility issues with jsonschema 4.18+. The newer versions of jsonschema dropped support for a feature required in asdf which left us with little choice but to vendorize jsonschema. This presented an opportunity to clean up some leaky bits of the asdf API including the issue that
jsonschema.ValidationError
was transparently passed to user code and libraries (like dkist) had to importValidationError
from jsonschema.asdf 2.15 introduced
ValidationError
as part of the public api available atasdf.exceptions.ValidationError
. This PR changes the importValidationError
fromasdf.exceptions
(instead of jsonschema).asdf 2.15.1 includes the vendorized jsonschema, keeps jsonschema as a dependency and attempts to use the exceptions from the installed jsonschema (to not break some downstream libraries that use asdf). We are planning to drop jsonschema as a dependency and stop using it's exceptions in asdf 3.0 (or possibly in 2.15.2 if further changes to jsonschema make it's exceptions incompatible).
Please see the What's New page in the asdf 2.15.1 docs for more information and let me know if you have any questions, comments or concerns.