-
Notifications
You must be signed in to change notification settings - Fork 58
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
Add Converter.to_info
to customize info
and search
#1884
base: main
Are you sure you want to change the base?
Conversation
412664d
to
c1713c3
Compare
Converter.to_info
to customize info
and search
The stdatamodels downstream failure is unrelated: spacetelescope/stdatamodels#371 |
This is a nice feature. I wonder if there should be a keyword option to suppress this option in the cases it will really blow up the output (tables with lots of columns, or a very complex GWCS). |
Thanks for giving it a look. At the moment the output is subject to the
and then to:
There is also an existing
That output doesn't look too helpful so one option might be to not use We could add a flag
At the moment I'm leaning towards relying on |
I worry that if the very lengthy item comes before items of interest, |
While working on this and #1875 I noticed that
In this case the
Because
I think the existing
As you noted the details about how |
Yes, it ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Asking for a clarification on a code comment
asdf/_node_info.py
Outdated
if root_info is None: | ||
root_info = info | ||
|
||
if parent is not None: | ||
if parent.schema is not None and not cls.traversable(node): | ||
# Why check that __asdf_traverse__ doesn't exist here? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I understand the comment regarding transversable. It seems to be arguing against the check, but retains it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it makes sense to remove this note?
I added it while trying to understand the code and I think it leads to an issue:
#1892
It still doesn't make sense to me why not cls.traversable
(or with this PR not traversable
) is checked. This PR at the moment doesn't change the behavior (to try an keep things consistent). However I think that consistency is enforcing a bug.
If I remove the traversable
check no tests fail (in asdf or roman_datamodels) so I doubt anything is relying on this bug. We could fix it in this PR by removing the check. Any ideas why not cls.traversable(node)
was added?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not that I can recall. Sounds like we should try just getting rid of that and see what the consequences are. Yes, something may be relying on that, but there is a benefit to getting rid of it if nothing is depending on it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leave search usage as a hasattr(__asdf_traverse__) check since search doesn't have access to an extension manager Update info usage to allow use of an extension manager
The jwst downstream failure is unrelated. It's due to the use of |
Description
This PR adds support for a new
Converter
methodto_info
. This new method is for converting a custom object to an "info" container (list, tuple, dict) to provide additional information duringinfo
(and as a side effect duringsearch
since this uses common code in_node_info.py
).To provide an example where this is useful. Currently an
AsdfFile
with an astropyTable
renders with largely unhelpfulinfo
:With this PR the
Table
(andColumn
)Converter
s in asdf-astropy can be updated (only theTableConverter
update shown here).to improve the output:
This has the added benefit of allowing
search
to find column names for the above example:This PR uses the
Converter.to_info
feature to implement custom information ofndarray
/NDArrayType
. On main the following:produces:
with this PR the output is different:
During working on this feature several bugs were uncovered and a few were fixed:
info
search
andschema_info
do not use theAsdfFile.extension_manager
#1882info
output garbled when terminal does not support formatting #1889info
can loop infinitely leaking memory if passed a recursive list #1890Fixes #1882 #1889 #1890 #1892
Tasks
pre-commit
on your machinepytest
on your machineno-changelog-entry-needed
)changes/
:echo "changed something" > changes/<PR#>.<changetype>.rst
(see below for change types)docs/
pagenews fragment change types...
changes/<PR#>.feature.rst
: new featurechanges/<PR#>.bugfix.rst
: bug fixchanges/<PR#>.doc.rst
: documentation changechanges/<PR#>.removal.rst
: deprecation or removal of public APIchanges/<PR#>.general.rst
: infrastructure or miscellaneous change