Giter Club home page Giter Club logo

Comments (4)

braingram avatar braingram commented on July 20, 2024

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.

braingram avatar braingram commented on July 20, 2024

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.

braingram avatar braingram commented on July 20, 2024

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.

braingram avatar braingram commented on July 20, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.