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

switch convert_unknown_ndarray_subclasses to False #1858

Merged
merged 4 commits into from
Nov 8, 2024

Conversation

braingram
Copy link
Contributor

@braingram braingram commented Oct 31, 2024

Description

Switches the default value for convert_unknown_ndarray_subclasses to False and issues an AsdfDeprecationWarning if this setting is enabled. We can remove it in asdf 5.0.

Tasks

  • run pre-commit on your machine
  • run pytest on your machine
  • Does this PR add new features and / or change user-facing code / API? (if not, label with no-changelog-entry-needed)
    • write news fragment(s) in changes/: echo "changed something" > changes/<PR#>.<changetype>.rst (see below for change types)
    • update relevant docstrings and / or docs/ page
    • for any new features, add unit tests
news fragment change types...
  • changes/<PR#>.feature.rst: new feature
  • changes/<PR#>.bugfix.rst: bug fix
  • changes/<PR#>.doc.rst: documentation change
  • changes/<PR#>.removal.rst: deprecation or removal of public API
  • changes/<PR#>.general.rst: infrastructure or miscellaneous change

@braingram braingram marked this pull request as ready for review October 31, 2024 16:50
@braingram braingram requested a review from a team as a code owner October 31, 2024 16:50
@braingram braingram added this to the 4.0.0 milestone Oct 31, 2024
@braingram
Copy link
Contributor Author

braingram commented Oct 31, 2024

Running jwst regtests as fitsrec was the motivation for this setting: https://github.com/spacetelescope/RegressionTests/actions/runs/11616650882

EDIT: these ran with only 1 unrelated failure (same as on main)

Copy link
Contributor

@nden nden left a comment

Choose a reason for hiding this comment

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

LGTM. Left a couple comments.

asdf/config.py Outdated Show resolved Hide resolved
@@ -40,7 +40,7 @@ the currently active config:
all_array_compression: input
all_array_compression_kwargs: None
default_array_save_base: True
convert_unknown_ndarray_subclasses: True
convert_unknown_ndarray_subclasses: False
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this count as an API change? I'm not sure how asdf deals with changes like this and I don't know if there are any cases in practice that will be affected.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree this counts as an API change.

When this feature was introduced (3.0.0) a warning was also added:

asdf/asdf/yamlutil.py

Lines 305 to 310 in abeef0e

warnings.warn(
f"A ndarray subclass ({type(obj)}) was converted as a ndarray. "
"This behavior will be removed from a future version of ASDF. "
"See https://asdf.readthedocs.io/en/latest/asdf/config.html#convert-unknown-ndarray-subclasses",
AsdfConversionWarning,
)

and a section in the linked docs:

In a future version of asdf this default will change to False, a deprecation warning will be issued and finally the conversion of instances of subclasses will be removed.

We are now in the future! This PR adds the deprecation warning and asdf 5.0.0 we can remove the setting and the behavior.

Co-authored-by: Nadia Dencheva <[email protected]>
@braingram
Copy link
Contributor Author

I opened an issue to track adding this to "what's new": #1865

@braingram braingram merged commit 2ed29f0 into asdf-format:main Nov 8, 2024
48 of 49 checks passed
@braingram braingram deleted the ndarray_subclasses branch November 8, 2024 14:30
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