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

inspect asdf_standard resources to find supported versions #1702

Closed
wants to merge 1 commit into from
Closed
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
11 changes: 2 additions & 9 deletions asdf/_core/_extensions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from asdf.extension import ManifestExtension
from asdf.versioning import supported_versions

from ._converters.complex import ComplexConverter
from ._converters.constant import ConstantConverter
Expand Down Expand Up @@ -37,15 +38,7 @@
]


MANIFEST_URIS = [
"asdf://asdf-format.org/core/manifests/core-1.0.0",
"asdf://asdf-format.org/core/manifests/core-1.1.0",
"asdf://asdf-format.org/core/manifests/core-1.2.0",
"asdf://asdf-format.org/core/manifests/core-1.3.0",
"asdf://asdf-format.org/core/manifests/core-1.4.0",
"asdf://asdf-format.org/core/manifests/core-1.5.0",
"asdf://asdf-format.org/core/manifests/core-1.6.0",
]
MANIFEST_URIS = [f"asdf://asdf-format.org/core/manifests/core-{version}" for version in supported_versions]


EXTENSIONS = [
Expand Down
23 changes: 14 additions & 9 deletions asdf/versioning.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
of the ASDF spec.
"""

import importlib.resources
from functools import total_ordering

import yaml
Expand Down Expand Up @@ -143,15 +144,19 @@ def __hash__(self):
return super().__hash__()


supported_versions = [
AsdfVersion("1.0.0"),
AsdfVersion("1.1.0"),
AsdfVersion("1.2.0"),
AsdfVersion("1.3.0"),
AsdfVersion("1.4.0"),
AsdfVersion("1.5.0"),
AsdfVersion("1.6.0"),
]
def _find_asdf_standard_version_map_versions():
Copy link
Contributor

Choose a reason for hiding this comment

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

I recommend basing this off of the manifest files, since they were meant to replace version_map-*.yml.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for taking a look and for this recommendation. I'm going to spend some time looking into this but will put some immediate thoughts/questions below.

One difference between the version maps and manifests is that the version maps contain entries for the file format and yaml version (see https://github.com/spacetelescope/stdatamodels/pull/253/files). Are these defined (or do they need to be defined) in the manifests?

Looking at how version map is used it determines the file format version:

fd.write(self.version_map["FILE_FORMAT"].encode("ascii"))

and yaml versIon:
yaml_version = tuple(int(x) for x in ctx.version_map["YAML_VERSION"].split("."))

used when writing the file.

During a (albeit quick) glance over the asdf-standard tests I don't see anything that checks that the version map and manifests agree :-/

As the changes in this PR assume the version map and manifests agree (in version) I will leave this PR as draft until the above can be sorted and the tests updated.

# each version has a map
version_map_filenames = (
importlib.resources.files("asdf_standard") / "resources" / "schemas" / "stsci.edu" / "asdf"
).glob("version_map-*.yaml")
versions = []
for version_map_filename in version_map_filenames:
_, version_string = version_map_filename.with_suffix("").name.split("-", 1)
versions.append(AsdfVersion(version_string))
return sorted(versions)


supported_versions = _find_asdf_standard_version_map_versions()


default_version = AsdfVersion("1.5.0")
Expand Down
Loading