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

Remove the last tag in the schemas #421

Merged
merged 7 commits into from
Feb 20, 2024
Merged
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
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ The stable ASDF Standard is v1.5.0
- Fix URI fragment format in quantity-1.2 schema [#374]
- Drop support for python 3.8 [#390]
- Add ``float16`` to ``ndarray-1.1.0`` [#411]
- Remove unneeded ``tag`` keyword from ``fits`` schema [#421]

1.0.3 (2022-08-08)
------------------
Expand Down
1 change: 0 additions & 1 deletion resources/schemas/stsci.edu/asdf/fits/fits-1.0.0.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ examples:
- [EXTNAME, ERR, extension name]
- [BUNIT, DN, Units of the error array]

tag: "tag:stsci.edu:asdf/fits/fits-1.0.0"
type: array
items:
description: >
Expand Down
1 change: 0 additions & 1 deletion resources/schemas/stsci.edu/asdf/fits/fits-1.1.0.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ examples:
- [EXTNAME, ERR, extension name]
- [BUNIT, DN, Units of the error array]

tag: "tag:stsci.edu:asdf/fits/fits-1.1.0"
type: array
items:
description: >
Expand Down
47 changes: 1 addition & 46 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,48 +116,6 @@ def docs_manifest_ids():
return result


def _get_tag(schema):
if "tag" in schema:
return schema["tag"]
elif "anyOf" in schema:
for elem in schema["anyOf"]:
if "tag" in elem:
return elem["tag"]
return None


@pytest.fixture(scope="session")
def latest_schema_tags(latest_schemas):
result = set()
for schema in latest_schemas:
tag = _get_tag(schema)
if tag is not None:
result.add(tag)
return result


@pytest.fixture(scope="session")
def schema_tags(schemas):
result = set()
for schema in schemas:
tag = _get_tag(schema)
if tag is not None:
result.add(tag)
return result


@pytest.fixture(scope="session")
def tag_to_schema(schemas):
result = {}
for schema in schemas:
tag = _get_tag(schema)
if tag is not None:
if tag not in result:
result[tag] = []
result[tag].append(schema)
return result


@pytest.fixture(scope="session")
def id_to_schema(schemas):
result = {}
Expand All @@ -170,7 +128,7 @@ def id_to_schema(schemas):


@pytest.fixture(scope="session")
def assert_schema_correct(tag_to_schema, id_to_schema):
def assert_schema_correct(id_to_schema):
def _assert_schema_correct(path):
__tracebackhide__ = True

Expand Down Expand Up @@ -200,9 +158,6 @@ def _assert_schema_correct(path):

assert len(id_to_schema[schema["id"]]) == 1, f"{path.name} does not have a unique id"

if "tag" in schema:
assert len(tag_to_schema[schema["tag"]]) == 1, f"{path.name} does not have a unique tag"

id_base, _ = split_id(schema["id"])
for example_id in list_example_ids(schema):
example_id_base, _ = split_id(example_id)
Expand Down
11 changes: 1 addition & 10 deletions tests/test_manifests.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@


@pytest.mark.parametrize("path", MANIFEST_PATHS)
def test_manifest(path, tag_to_schema):
def test_manifest(path):
manifest = load_yaml(path)

with asdf.config_context() as config:
Expand All @@ -21,14 +21,5 @@ def test_manifest(path, tag_to_schema):
assert "description" in manifest

for tag in manifest["tags"]:
if (
"time" not in tag["tag_uri"]
and "core" not in tag["tag_uri"]
and "unit" not in tag["tag_uri"]
and "wcs" not in tag["tag_uri"]
):
assert tag["tag_uri"] in tag_to_schema
schema = tag_to_schema[tag["tag_uri"]][0]
assert tag["schema_uri"] == schema["id"]
assert "title" in tag
assert "description" in tag
43 changes: 1 addition & 42 deletions tests/test_version_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@


@pytest.mark.parametrize("path", VERSION_MAP_PATHS)
def test_version_map(path, schema_tags):
def test_version_map(path):
assert VALID_FILENAME_RE.match(path.name) is not None, f"{path.name} is an invalid version map filename"

assert_yaml_header_and_footer(path)
Expand All @@ -33,11 +33,6 @@ def test_version_map(path, schema_tags):
assert vm["FILE_FORMAT"] in VALID_FILE_FORMAT_VERSIONS
assert vm["YAML_VERSION"] in VALID_YAML_VERSIONS

for tag_base, tag_version in vm["tags"].items():
tag = f"{tag_base}-{tag_version}"
if "time" not in tag and "core" not in tag and "unit" not in tag and "wcs" not in tag:
assert tag in schema_tags, f"{path.name} specifies missing tag {tag}"

assert len(vm["tags"].keys()) == len(set(vm["tags"].keys())), f"{path.name} contains duplicate tags"

sorted_tags = sorted(list(vm["tags"].keys()))
Expand All @@ -47,42 +42,6 @@ def test_version_map(path, schema_tags):
assert False, message


def test_latest_version_map(latest_schema_tags):
"""
The current latest version map has some special requirements.
"""
vm = load_yaml(LATEST_PATH)

tag_base_to_version = dict([tag.rsplit("-", 1) for tag in latest_schema_tags])

expected_tag_bases = {t for t in tag_base_to_version.keys() if not is_deprecated(t)}
vm_tag_bases = set(vm["tags"].keys())
if not expected_tag_bases.issubset(vm_tag_bases):
missing_tag_bases = expected_tag_bases - vm_tag_bases
insert_list = "\n".join(
sorted(f"""{tag_base}-{tag_base_to_version[tag_base]}""" for tag_base in missing_tag_bases)
)
message = (
f"{LATEST_PATH.name} must include the latest version of "
"every non-deprecated schema with a tag. Update the deprecation "
"list in tests/common.py, or add the following missing schemas: \n"
f"{insert_list}"
)
assert False, message

incorrect_tag_bases = sorted(tag for tag in expected_tag_bases if vm["tags"][tag] != tag_base_to_version[tag])
if len(incorrect_tag_bases) > 0:
update_list = "\n".join(
[f"""{tag}: {vm["tags"][tag]} --> {tag_base_to_version[tag]}""" for tag in incorrect_tag_bases]
)
message = (
f"{LATEST_PATH.name} must include the latest version of "
"every non-deprecated schema with a tag. Update the following: \n"
f"{update_list}"
)
assert False, message


@pytest.mark.parametrize("path, previous_path", zip(SORTED_PATHS[1:], SORTED_PATHS[0:-1]))
def test_version_map_tags_retained(path, previous_path):
"""
Expand Down
Loading