-
Notifications
You must be signed in to change notification settings - Fork 74
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
Viewers now have human-readable IDs #722
Conversation
Codecov Report
@@ Coverage Diff @@
## main #722 +/- ##
==========================================
+ Coverage 62.12% 62.43% +0.31%
==========================================
Files 65 65
Lines 4222 4241 +19
==========================================
+ Hits 2623 2648 +25
+ Misses 1599 1593 -6
Continue to review full report at Codecov.
|
p.s. Did I also accidentally fix https://jira.stsci.edu/browse/JDAT-433 here? 🤔 (Ricky said no.) |
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.
This looks good, and doesn't seem to interfere with the way the other viz tools work under the hood. I don't think it closes the ticket you referenced (being able to rename viewers) - I think the intent there was to be able to double click the displayed name in the UI to rename it, or at least to have a rename_viewer
(or similar) API call to do that.
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 think this looks good. It checks off a few boxes from #361. One thing that may be an issue is when creating viewers from within the UI on the default
application, the reference and id names get assigned None
, and unknown-0
. E.g. if you create a default Application, then in the UI - click the Viewer Creator button - click Profile 1D (Specviz), you get a new spectrum 1d viewer but without proper ref/id names. Then other code fails when trying to reference either unknown-0
or the None
reference name. The same happens for any of the other viewers. I think we could similarly map reference names onto these.
app = Application('default')
print(app.get_viewer_reference_names())
print(app.get_viewer_ids())
[None]
['unknown-0']
I think it would be useful to also have a new method that lists all available reference names, e.g, app.list_available_viewer_references()
, that one could use when creating viewers programmatically. Something like viewer_registry.members
but returns a list or dictionary of available options. And a similar method to create a brand new viewer by reference name, e.g. app.create_viewer("spectrum-viewer")
. But perhaps these items are for a new PR?
This will improve the app.add_data_to_viewer
method as well, which accepts a viewer reference name as input. Side note: that method is slightly broken now since it seems the data labels assigned to loaded data changed at some point. But that's another issue.
Added tests.
@havok2063 , thanks for pointing that out! I did not even know As tempted as it may be, I decided not to change viewer reference set to Now, you should see something like this in your workflow: >>> from jdaviz import Application
>>> app = Application('default')
>>> app
>>> # Create some viewers interactively
>>> print(app.get_viewer_reference_names())
[None, None, None]
>>> print(app.get_viewer_ids())
['CubeVizImageView-0', 'ImvizImageView-0', 'ImvizImageView-1']
>>> v = app.get_viewer_by_id('ImvizImageView-1')
>>> v
<jdaviz.configs.imviz.plugins.viewers.ImvizImageView at ...> |
from jdaviz import __version__ | ||
|
||
@pytest.fixture | ||
def cubeviz_app(): |
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.
Other tests can also now take advantage of these new fixtures but that is out of scope here.
@pllim The updates look good. Do we want or need the id names to be consistent e.g. I believe the viewer reference name is the thing used to actually load data into the viewers by all the helpers/parsers in Jdaviz, e.g.
For use cases where a user creates a default application, and creates some viewers interactively, I think we want to retain the ability for them to access the viewer, add or remove data programmatically using |
@havok2063 , as far as I am concerned for Imviz, this patch allows me to manipulate sub-viewer programmatically. I don't care much how the viewer ID is named but I do slightly prefer Viewer ID is not purely cosmetic; it is the primary key to I agree improvements could be made on the app interface as a whole but I also agree they are out of scope here. If you are happy with this PR as-is, please approve. If not, please suggest things I should change. Thanks! |
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.
@pllim that makes sense to me. This is a good improvement and don't mean to drag it out. Just some food for thought. I approve it, although I think since I'm not technically a part of the Indigo team, they may want to have 2 approvals from the more reputable JDAT folks. ;)
Thanks for the approval! I'll keep it open as you requested. But FWIW, you are much more reputable than I am. 😸 |
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.
Cool!
Proof of concept
With this patch, such a thing is now possible (though the contour stuff is another issue, see #530).
New viewer IDs
With this patch, this is how different layouts now behave.