Comments (4)
Above tests were done on current main and 2.15. On 2.15 (using the old CustomType system) behavior is different where in all 3 cases the object is loaded without any error but always (even in the case of the patch version mismatch) with a warning similar to:
AsdfWarning: File was created with extension class '__main__.FooV1p1p1Extension', which is not currently installed
from asdf.
To extend the examples, currently a jwst fgs distortion file exists on CRDS that works in 2.15.1 but presents in issue (although not one of consequence) for 3.0.0.
This file: https://jwst-crds.stsci.edu/browse/jwst_fgs_distortion_0003.asdf
Contains an unfortunate and incorrect header:
#ASDF 1.0.0
#ASDF_STANDARD 1.2.0
%YAML 1.1
%TAG ! tag:stsci.edu:asdf/
--- !core/asdf-1.0.0
ASDF standard 1.2.0 defines core/asdf-1.1.0 (not asdf-1.0.0) as the top-level tag.
When opened with 2.15.1 (where the top-level tag is handled by AsdfObjectType) this file loads with no warnings and the tree is an AsdfObject
instance:
>>> af = asdf.open('jwst_fgs_distortion_0003.asdf')
>>> type(af.tree)
asdf.tags.core.AsdfObject
However, because 3.0.0 deserializes AsdfObject
with a AsdfObjectConverter loading the same file produces a warning and tree that is a TaggedDict
instance:
>>> af = asdf.open('jwst_fgs_distortion_0003.asdf')
AsdfConversionWarning: tag:stsci.edu:asdf/core/asdf-1.0.0 is not recognized, converting to raw Python data structure
>>> type(af.tree)
asdf.tagged.TaggedDict
As AsdfObject
is simply a dict subclass, this appears to have no negative effect (outside of a new warning) but this would likely be more problematic for other types.
I am so far unable to find a mention in the standard how these types of errors (encountering a tag with an less-than-expected version) should be handled.
from asdf.
I'm proposing the following
- update the standard to describe:
- that the 'safest' option is to only deserialize tags that exactly match the supported version and that this is the only requirement for an ASDF implementation
- any support non-exact matching is not required in an ASDF implementation
- if non-exact matching is allowed, it should be documented and some level of control should be exposed to the user
- update asdf to
- by default, continue to only deserialize tags that are exact matches
- consider adding an option (off by default) to allow 'fuzzy' matching which follows the old 'type' behavior where a version mismatch will not stop deserialization. However, issue a warning for each mismatch
I took a quick stab at adding 'fuzzy' matching to converters (to make sure there wasn't something entirely incompatible). See the branch here. Most of what needed to be done was to:
- index converters by tag name (for the test I forced strict semantic versioning of all tags to work around issues with
split_tag_version
but this should be avoidable) - add a config setting
allow_tag_version_mismatch
- add a new warning
AsdfTagVersionMismatchWarning
- add some conditionals to
tagged_tree_to_custom_tree
to handled the version mismatches
I propose that we don't take implementing 'fuzzy' matching any further at this point and merely state in 3.0 docs that converters are now strict (as they have been) and that means the built-in tags/types are now strict. If we see issues (so far downstream testing has only revealed one inconsequential snag).
We should however update the standard to match the converter behavior as mentioned above.
from asdf.
Tagging @eslavich @perrygreenfield and @nden to get their opinions on the above proposal to update the asdf-standard docs to match how asdf converters handle tag version mismatches.
from asdf.
Related Issues (20)
- `asdf.treeutil.walk_and_modify` does not remove nodes in list
- asdf odd handling of `namedtuple` that prevents implementing a `Converter`
- ASDF swallows warnings raised by converters HOT 6
- `load_schema` does not resolve local references
- asdf pytest plugin is incompatible with pytest 8.1.dev
- `add_history_entry` validates the entire tree
- Objects that implement `__asdf_traverse__` are expected to have a `_tag`
- Raise a warning type specific to software version mismatches when wrong version of packages is installed
- Add schema manifest providing package version to asdf metadata and check schema packages on read
- Update `setuptools_scm` `write_to`
- Retire the "stable" branch HOT 4
- Combine package and build workflows
- masked arrays do not roundtrip with all false masks
- `AsdfSpec` misses expected match
- deprecate `AsdfSpec` and `format_tag`
- Tracking `sunpy` 6.0 and ASDF 1.6.0 HOT 1
- Old (<2.14) versions of asdf do not fully support ASDF standard 1.6.0
- `AsdfFile` instances are not pickleable HOT 1
- Chunking support HOT 2
- Investigate enabling `validate_checksum` as default `True`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from asdf.