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

Hide Cubeviz import button after importing data #1495

Merged
merged 5 commits into from
Jul 19, 2022

Conversation

ojustino
Copy link
Contributor

@ojustino ojustino commented Jul 14, 2022

Description

Here is an attempt that would close #1345. Do we like keeping the buffer on the left of the subset creation button or should it be flush with the left app border after the import button disappears?

Screen.Recording.2022-07-14.at.6.56.42.PM.mov

I also added a load_data() method to the Cubeviz class in order to raise an error if someone attempts to programmatically add a cube when one is already present in the app. I didn't allow for keyword arguments like some of the other configs' versions do: specifying a data_type (flux, mask, uncert) doesn't make sense if we only allow data to be loaded once, and using data_label to apply labels with glue seems like it should be internal.

Thanks to @kecnry for helping me get started.

Checklist for package maintainer(s)

This checklist is meant to remind the package maintainer(s) who will review this pull request of some common things to look for. This list is not exhaustive.

  • Are two approvals required? Branch protection rule does not check for the second approval. If a second approval is not necessary, please apply the trivial label.
  • Do the proposed changes actually accomplish desired goals? Also manually run the affected example notebooks, if necessary.
  • Do the proposed changes follow the STScI Style Guides?
  • Are tests added/updated as required? If so, do they follow the STScI Style Guides?
  • Are docs added/updated as required? If so, do they follow the STScI Style Guides?
  • Did the CI pass? If not, are the failures related?
  • Is a change log needed? If yes, is it added to CHANGES.rst?
  • Is a milestone set?
  • After merge, any internal documentations need updating (e.g., JIRA, Innerspace)?

@github-actions github-actions bot added cubeviz embed Regarding issues with front-end embedding mosviz labels Jul 14, 2022
@ojustino ojustino added this to the 2.8 milestone Jul 14, 2022
Copy link
Member

@kecnry kecnry left a comment

Choose a reason for hiding this comment

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

Seems to do the trick well and the implementation is nice and clean. Nice work, thanks!

Edit: woops, just noticed that CI is failing, that will need to get fixed before merge!

Comment on lines +41 to +42
<j-tooltip v-if="config == 'cubeviz' && item.name == 'g-data-tools' && state.data_items.length !== 0"></j-tooltip>
<j-tooltip v-else :tipid="item.name">
Copy link
Member

Choose a reason for hiding this comment

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

could probably either make the first (empty) v-if entry a div instead of a j-tooltip and/or invert the v-if and not render any entry in the case of hiding the import button (but that might be harder logic to parse).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Giving both the same element seemed more intuitive to me. I did want to put the conditional for hiding in the v-else statement since it's rarer, but the logic for the v-if seems like it would need to be long – I get something like v-if="(config !== 'cubeviz') || ((config == 'cubeviz') && (item.name !== 'g-data-tools' || (item.name == 'g-data-tools' && state.data_items.length == 0)))".

Comment on lines +52 to +53
if len(self.app.state.data_items) != 0:
raise RuntimeError('only one cube may be loaded per Cubeviz instance')
Copy link
Member

Choose a reason for hiding this comment

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

just realized that some day we might want to allow loading 1d spectra and only forbid cubes, but that will require quite a bit more advanced logic, especially on the UI side, so I think this is fine for now until/unless we get a request to re-enable that.

@codecov
Copy link

codecov bot commented Jul 15, 2022

Codecov Report

Merging #1495 (2489839) into main (4964c8e) will increase coverage by 0.05%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main    #1495      +/-   ##
==========================================
+ Coverage   85.41%   85.47%   +0.05%     
==========================================
  Files          91       91              
  Lines        8483     8555      +72     
==========================================
+ Hits         7246     7312      +66     
- Misses       1237     1243       +6     
Impacted Files Coverage Δ
jdaviz/configs/cubeviz/plugins/parsers.py 56.57% <ø> (ø)
jdaviz/configs/mosviz/helper.py 86.77% <ø> (ø)
jdaviz/configs/cubeviz/helper.py 88.88% <100.00%> (+0.88%) ⬆️
jdaviz/configs/imviz/plugins/compass/compass.py 69.44% <0.00%> (-3.29%) ⬇️
...nfigs/default/plugins/plot_options/plot_options.py 99.18% <0.00%> (-0.82%) ⬇️
jdaviz/core/template_mixin.py 91.43% <0.00%> (-0.03%) ⬇️
jdaviz/app.py 92.43% <0.00%> (+0.02%) ⬆️
...z/configs/imviz/plugins/coords_info/coords_info.py 97.56% <0.00%> (+0.06%) ⬆️
jdaviz/configs/imviz/plugins/viewers.py 82.55% <0.00%> (+0.10%) ⬆️
jdaviz/configs/cubeviz/plugins/viewers.py 89.00% <0.00%> (+0.11%) ⬆️
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4964c8e...2489839. Read the comment docs.

@ojustino
Copy link
Contributor Author

It looks like I couldn't get away with not allowing keyword arguments for Cubeviz.load_data(), so I added them. Otherwise, updating CHANGES.rst was the other failing test, so I expect this is good to go pending another review.

Copy link
Collaborator

@duytnguyendtn duytnguyendtn left a comment

Choose a reason for hiding this comment

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

Works well on my side! My main concern is a user might be confused why the import button disappears after loading, not understanding that they can only load one at a time.

I'm not sure if I'm in the minority, but my general suggestion would be not to hide the button, but to grey it out and display a hover tooltip saying "Only one cube at a time! To load a second, open a second instance of Cubeviz" or something. Thoughts?

@@ -28,7 +28,7 @@ def parse_data(app, file_obj, data_type=None, data_label=None):
----------
app : `~jdaviz.app.Application`
The application-level object used to reference the viewers.
file_path : str
file_obj : str
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not quite groking this change here; the docstring still explicitly states "path" , so presumably if this change is to explicitly allowing a Spectrum1D to be loaded directly, then I think the docstring should be updated too?

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 mainly did this for consistency – if you search, file_path doesn't appear anywhere else in the file. I'm guessing the argument was originally named file_path and was later renamed as file_obj without a corresponding update to the docstring. I don't do anything to introduce support for Spectrum1D in this PR. Are you saying that happened elsewhere and should have been mentioned in the docstring?

@ojustino
Copy link
Contributor Author

@duytnguyendtn, the "gray out" idea came up when the team discussed this ticket at a Daily Scrum a few weeks ago, but the consensus was that the prior precedent in jdaviz is to remove buttons instead. Jenn also said this approach was reasonable from a UX perspective.

That said, I do agree that it's important to make the "one cube per instance" rule clear. It's in the load_data() docstring. Could there be a note added to the text seen when you click the "Import Data" button, too? Should something be added on ReadTheDocs?

@pllim
Copy link
Contributor

pllim commented Jul 15, 2022

Disclaimer: I don't have a chance to install this branch and play with it.

That said, I have a question: In the future, when we allow data deletion (#1420), is the button supposed to re-appear when the cube is deleted?

@ojustino
Copy link
Contributor Author

@pllim, the button currently does reappear when I set cubeviz.app.state.data_items to an empty list. It's a rough check, but that behavior makes sense to me.

@duytnguyendtn
Copy link
Collaborator

👍 on the greyed out button consensus. As for making the rule known, my concern is mainly for the desktop app, where the user can't easily query the docstring like in the notebook. I DEFINITELY think this should be on the documentation, but also I wish there were some way to indicate this to the user in Desktop App mode, especially when the button disappears

@kecnry
Copy link
Member

kecnry commented Jul 18, 2022

@duytnguyendtn @pllim - are your concerns that a disappearing button will be jarring only because it is a change from previous behavior (and other apps don't do it - although maybe mosviz should) or do you think that users will want to try to load a second cube and be confused that they can't find a button to do that?

The embedded version on MAST, has no import button at all, and I haven't heard anyone be confused by that. And in the case of loading data in cubeviz from the API before showing the app, you'll now never see the import button... so will anyone even miss it? The added benefit is that we gain significant real estate in the top bar in cubeviz once data is loaded. I'm in favor of trying this (since it does have some advantages and is simpler to implement) and reconsider if we get user feedback/questions? 🤷

@pllim
Copy link
Contributor

pllim commented Jul 18, 2022

If I am using Photoshop, a button that pops in and out would annoy me. That was my baseline. But I agree to let users decide.

@ojustino
Copy link
Contributor Author

It looks like the instructional text for the "Import Data" button is shared between configurations in jdaviz/configs/default/plugins/data_tools/data_tools.vue, so does anyone have advice on how to append a Cubeviz-specific advisory for the single file rule?

Meanwhile, I'm seeing that it's already addressed at the top of the Cubeviz documentation on importing data:

image

@pllim
Copy link
Contributor

pllim commented Jul 18, 2022

Re: Vue.js

Can we use something like v-if to toggle a special text for Cubeviz? I think @kecnry has enabled the JS side to figure out which config Jdaviz is in from Python.

@ojustino
Copy link
Contributor Author

@pllim, thanks for the nudge in the right direction. I went with an in-line conditional to avoid duplicating the majority of the v-card-text element, but I can switch to v-if/v-else if others prefer that setup.

@pllim
Copy link
Contributor

pllim commented Jul 19, 2022

I see this already has one approval. Should a PO approve the second slot? I never know which one they want to personally approve or not.

Copy link
Collaborator

@duytnguyendtn duytnguyendtn left a comment

Choose a reason for hiding this comment

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

Okay after the explanation, I think I'm happy with this; I think having that text in the Import Data button really helps here. If a user tries to load multiple cubes via API, they'll get the traceback that warns them they can't. If a user tries to load via GUI, they'll see that warning message. The only case we're missing here is if a user loads data initially through the API, then tries to load from the GUI, only to realize the button is gone. But I think that use case is quite small, so I think I'm OK with proceeding from now. Thanks Justin!

@pllim
Copy link
Contributor

pllim commented Jul 19, 2022

Given there are 2 approvals, let's merge. Thanks!

@pllim pllim merged commit 098f696 into spacetelescope:main Jul 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cubeviz embed Regarding issues with front-end embedding mosviz
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEAT] Cubeviz: Multiple import with data cubes
4 participants