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

Update ndarray schema to 1.1 to fix issue 345 #350

Merged
merged 3 commits into from
Nov 30, 2022

Conversation

braingram
Copy link
Contributor

@braingram braingram commented Nov 21, 2022

Fixes #345

This PR should be merged after #349 so the time schema errors fixed in that PR do not result in test failures once this PR fixes #345.

@WilliamJamieson
Copy link
Contributor

Can you separate the change adding the new ndarray schema into a separate commit followed by all the supporting changes to make the history a bit easier to parse.

Also, can you post the diff between ndarray-1.0.0 and ndarray-1.1.0?

@braingram
Copy link
Contributor Author

I may be missing something but I am unable to (locally) get the asdf-development tests to pass without updating the legacy converters to support the new schemas. Specifically:

  • in astropy.io.misc.asdf)
    • table
    • column
  • in asdf
    • integer
    • ndarray

The failing test is test_version_map_core_support[version6] which fails with a rather unhelpful error:
AttributeError: 'MockContext' object has no attribute '_warn_tag_mismatch'
The MockContext here, meant to mimic an AsdfFile does not have that method. If a method is added (that does nothing, matching the default behavior in AsdfFile), the error becomes a more helpful:

E           AssertionError: ASDF Standard version 1.6.0 requires support for tag:stsci.edu:asdf/core/integer-1.1.0, but no ExtensionType exists that explicitly supports that version.
E           assert 'tag:stsci.ed...integer-1.0.0' == 'tag:stsci.ed...integer-1.1.0'
E             - tag:stsci.edu:asdf/core/integer-1.1.0
E             ?                                   ^
E             + tag:stsci.edu:asdf/core/integer-1.0.0
E             ?                                   ^

If I then add a supported_versions class attribute to the IntegerType in asdf the test no longer fails for the integer tag.

However, the NDArrayType class does not appear to support a similar fix. If I add a supported_versions class attribute I get an even less helpful error at time of class definition:

TypeError: __class__ set to <class 'asdf.tags.core.ndarray.NDArrayType'> defining 'NDArrayType' as <class 'asdf.tags.core.ndarray.NDArrayType'>

To move this PR forward, am I correct that the asdf-development tests will fail until the converters are updated or am I missing something?

Also, thanks for the feedback on the history changes, I'll make them once the content of the PR is sorted out.

Aside from the examples in the description the diff for ndarray-1.0.0 and ndarray-1.1.0 is as follows:

>     oneOf:
>       - required: [source]
>       - required: [data]
>

@WilliamJamieson
Copy link
Contributor

I may be missing something but I am unable to (locally) get the asdf-development tests to pass without updating the legacy converters to support the new schemas. Specifically:

  • in astropy.io.misc.asdf)

    • table
    • column
  • in asdf

    • integer
    • ndarray

The failing test is test_version_map_core_support[version6] which fails with a rather unhelpful error: AttributeError: 'MockContext' object has no attribute '_warn_tag_mismatch' The MockContext here, meant to mimic an AsdfFile does not have that method. If a method is added (that does nothing, matching the default behavior in AsdfFile), the error becomes a more helpful:

E           AssertionError: ASDF Standard version 1.6.0 requires support for tag:stsci.edu:asdf/core/integer-1.1.0, but no ExtensionType exists that explicitly supports that version.
E           assert 'tag:stsci.ed...integer-1.0.0' == 'tag:stsci.ed...integer-1.1.0'
E             - tag:stsci.edu:asdf/core/integer-1.1.0
E             ?                                   ^
E             + tag:stsci.edu:asdf/core/integer-1.0.0
E             ?                                   ^

If I then add a supported_versions class attribute to the IntegerType in asdf the test no longer fails for the integer tag.

However, the NDArrayType class does not appear to support a similar fix. If I add a supported_versions class attribute I get an even less helpful error at time of class definition:

TypeError: __class__ set to <class 'asdf.tags.core.ndarray.NDArrayType'> defining 'NDArrayType' as <class 'asdf.tags.core.ndarray.NDArrayType'>

To move this PR forward, am I correct that the asdf-development tests will fail until the converters are updated or am I missing something?

This should be paired with an asdf PR. Failures in astropy.io.misc.asdf are irrelevant.

@braingram
Copy link
Contributor Author

Here is a partial diff between ndarray-1.0.0 and ndarray-1.1.0 (most differences are updating references/tags from 1.0 to 1.1):

374a386,389
>     oneOf:
>       - required: [source]
>       - required: [data]
>

@braingram braingram marked this pull request as ready for review November 29, 2022 19:17
@braingram
Copy link
Contributor Author

There is 1 remaining reference to ndarray-1.0 in the asdf-schema-1.0.0 metaschema:

- $ref: "http://stsci.edu/schemas/asdf/core/ndarray-1.0.0#/definitions/datatype"

This references a portion of the ndarray-1.0.0 schema that is not affected by #345.

The CI failure of asdf-development tests is unavoidable as asdf does not yet have support for the new schemas (support will be added in this PR: asdf-format/asdf#1250).

I think it makes sense to merge this prior to the asdf PR so that the CI for that PR can hopefully have fewer errors (it will still fail some tests unless asdf-format/asdf#1247 is merged to allow xfailing certain new tags that are not supported in asdf).

@WilliamJamieson WilliamJamieson merged commit cc06359 into asdf-format:master Nov 30, 2022
@braingram braingram deleted the bug/ndarray_schema branch July 10, 2023 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Overly permissive ndarray schema leads to improper time validation
2 participants