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

Deprecate AsdfFile.version_map #1745

Merged
merged 14 commits into from
Mar 25, 2024
Merged

Conversation

braingram
Copy link
Contributor

@braingram braingram commented Jan 30, 2024

Description

This PR:

  • deprecates AsdfFile.version_map
  • removes asdf uses of versioning.get_version_map (which this PR also renames to _get_version_map as it is undocumented, not listed in versioning.__all__ and unused by all known downstream packages)
  • no longer relies on the version maps in asdf-standard to map asdf standard versions to file format and yaml versions

Note that at the moment ASDF only supports file format 1.0.0 and yaml 1.1. This PR adds those constants to asdf.versioning.

When this PR is merged a new issue can be opened to track the removal of AsdfFile.version_map in asdf 4.0. The PR that removes version_map can also remove versioning._get_version_map. Once that PR is merged, the version map files can be removed from asdf standard.

sunpy downstream is failing due to pytest 8
weldx is failing due to new pandas deprecations

Checklist:

  • pre-commit checks ran successfully
  • tests ran successfully
  • for a public change, a changelog entry was added
  • for a public change, documentation was updated
  • for any new features, unit tests were added

asdf/_asdf.py Outdated
@@ -807,7 +809,7 @@ def _open_asdf(
msg = "Does not appear to be a ASDF file."
raise ValueError(msg) from e
self._file_format_version = cls._parse_header_line(header_line)
self.version = self._file_format_version
self.version = self.file_format_version
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems incorrect. self.version is the asdf standard version yet here it is being set to the file_format_version (which is always 1.0.0). self.version is overwritten for probably every file a few lines down (from the undocumented ASDF_STANDARD comment). As the ASDF standard does not define the comment or what to do in this case I'm inclined to leave in this behavior for this PR (as it's only tangentially related to deprecating version_map).

It is likely an improvement to change this to default to the default_version if the file doesn't define a version. However this would be a major change (switching from asdf standard 1.0.0 to 1.5.0) if there is any code that relies on this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My guess is that early (possibly pre-release) versions of ASDF did not include an #ASDF_STANDARD comment and this line is here to allow those files to be read.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good guess!

I changed this to just default to 1.0.0 if no #ASDF_STANDARD comment is found. That way it should hopefully not break for 2.0.0.

44fe69f

There were 2 tests that failed following this change. One was filling in the standard version for #ASDF (so should have been producing an error but was not), the other was expecting an unsupported standard version warning when the #ASDF version was incorrect. Both of these were updated. I wouldn't be surprised if there are more places where these two things are conflated :-/

@@ -408,62 +402,3 @@ def assert_no_warnings(warning_class=None):
assert not any(isinstance(w.message, warning_class) for w in recorded_warnings), display_warnings(
recorded_warnings,
)


def _assert_extension_type_correctness(extension, extension_type, resolver):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was unused so it was removed instead of updating it to not use get_version_map.

@braingram braingram marked this pull request as ready for review January 30, 2024 22:36
@braingram braingram requested a review from a team as a code owner January 30, 2024 22:36
@braingram braingram added this to the 3.1.0 milestone Jan 30, 2024
@braingram braingram force-pushed the version_map branch 3 times, most recently from 16c821e to 44fe69f Compare January 31, 2024 13:40
@@ -286,57 +275,6 @@ def _assert_roundtrip_tree(
asdf_check_func(ff)


def yaml_to_asdf(yaml_content, yaml_headers=True, standard_version=None):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was replaced with asdf.testing.helpers.yaml_to_asdf instead of updating it to remove the use of version_map.

Copy link
Contributor

@eslavich eslavich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@braingram braingram merged commit 1dbf3d7 into asdf-format:main Mar 25, 2024
48 of 49 checks passed
@braingram braingram deleted the version_map branch March 25, 2024 18:45
@braingram braingram mentioned this pull request Apr 5, 2024
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants