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

info don't show value for bad __str__ #1748

Merged
merged 4 commits into from
Feb 27, 2024
Merged

Conversation

braingram
Copy link
Contributor

@braingram braingram commented Feb 3, 2024

Description

if __str__ fails during asdf.info or returns multiple lines then don't show the value.

This fixes the current roman_datamodels downstream job which is failing due to a wcs which contains no transforms which causes gwcs to fail a __str__ call.

A PR is open to fix the __str__ issue in gwcs: spacetelescope/gwcs#489

However even with the above fix the WCS.__str__ result is a multi-line string which breaks info formatting. To deal with this, this PR also checks the __str__ output for multiple lines and in that case discards the __str__ result.

To provide a few examples using a tree containing gwcs.WCS(output_frame="icrs").

Without the gwcs PR and with asdf main, asdf.info returns:

File ~/projects/src/gwcs/gwcs/wcs.py:1347, in WCS.__str__(self)
   1344 for item in self._pipeline[: -1]:
   1345     #model = item[1]
   1346     model = item.transform
-> 1347     if model.name is not None:
   1348         col2.append(model.name)
   1349     else:

AttributeError: 'NoneType' object has no attribute 'name'

With the above gwcs PR with asdf 3.0.1 (the latest release), asdf.info returns:

└─w (WCS)

With the above gwcs PR and asdf main, asdf.info returns (note the break in formatting)

└─w (WCS):   From   Transform
-------- ---------
detector      None
    icrs      None

With (or without) the above gwcs PR and with this PR, asdf.info returns:

└─w (WCS)

Note that with this PR time formatting is still preserved (so the issue #1686) fixed by #1687 is still fixed:

└─t (Time): 2024-02-03 14:20:29.350503

Finally, this PR fixes the changelog error where #1687 is listed under the wrong version (see the changelog for 3.0.x).

The weldx downstream error is unrelated (and caused by a new pandas).

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

@braingram braingram marked this pull request as ready for review February 3, 2024 14:25
@braingram braingram requested a review from a team as a code owner February 3, 2024 14:25
@braingram braingram requested a review from eslavich February 3, 2024 14:33
@braingram braingram requested a review from nden February 27, 2024 13:03
@braingram braingram added this to the 3.1.0 milestone Feb 27, 2024
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

if __str__ fails or returns multiple lines
then don't show the value (similar to the old
behavior).
@braingram braingram enabled auto-merge February 27, 2024 13:40
@braingram braingram merged commit fca8136 into asdf-format:main Feb 27, 2024
39 of 40 checks passed
@braingram braingram deleted the info_str branch February 27, 2024 13:57
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