-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Add ability to export subsets #2760
Conversation
273d0bb
to
fc5694a
Compare
Since #2755 still in draft and this depends on that one, I have turned this into draft. Thanks for your understanding! |
fc5694a
to
c93aaa0
Compare
3759314
to
d81c41d
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2760 +/- ##
==========================================
+ Coverage 88.72% 88.80% +0.08%
==========================================
Files 110 110
Lines 16353 16394 +41
==========================================
+ Hits 14509 14559 +50
+ Misses 1844 1835 -9 ☔ View full report in Codecov by Sentry. |
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 opened CubevizExample.ipynb
, loaded the file, created a spatial subset, and opened Export
:
When I toggle from any viewer to any other, I get the following traceback:
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
File ~/miniconda3/envs/jdaviz-only-7/lib/python3.11/site-packages/ipywidgets/widgets/widget.py:773, in Widget._handle_msg(self, msg)
771 if 'buffer_paths' in data:
772 _put_buffers(state, data['buffer_paths'], msg['buffers'])
--> 773 self.set_state(state)
775 # Handle a state request.
776 elif method == 'request_state':
File ~/miniconda3/envs/jdaviz-only-7/lib/python3.11/site-packages/ipywidgets/widgets/widget.py:650, in Widget.set_state(self, sync_data)
645 self._send(msg, buffers=echo_buffers)
647 # The order of these context managers is important. Properties must
648 # be locked when the hold_trait_notification context manager is
649 # released and notifications are fired.
--> 650 with self._lock_property(**sync_data), self.hold_trait_notifications():
651 for name in sync_data:
652 if name in self.keys:
File ~/miniconda3/envs/jdaviz-only-7/lib/python3.11/contextlib.py:144, in _GeneratorContextManager.__exit__(self, typ, value, traceback)
142 if typ is None:
143 try:
--> 144 next(self.gen)
145 except StopIteration:
146 return False
File ~/miniconda3/envs/jdaviz-only-7/lib/python3.11/site-packages/traitlets/traitlets.py:1510, in HasTraits.hold_trait_notifications(self)
1508 for changes in cache.values():
1509 for change in changes:
-> 1510 self.notify_change(change)
File ~/miniconda3/envs/jdaviz-only-7/lib/python3.11/site-packages/ipywidgets/widgets/widget.py:701, in Widget.notify_change(self, change)
698 if name in self.keys and self._should_send_property(name, getattr(self, name)):
699 # Send new state to front-end
700 self.send_state(key=name)
--> 701 super().notify_change(change)
File ~/miniconda3/envs/jdaviz-only-7/lib/python3.11/site-packages/traitlets/traitlets.py:1525, in HasTraits.notify_change(self, change)
1523 def notify_change(self, change: Bunch) -> None:
1524 """Notify observers of a change event"""
-> 1525 return self._notify_observers(change)
File ~/miniconda3/envs/jdaviz-only-7/lib/python3.11/site-packages/traitlets/traitlets.py:1568, in HasTraits._notify_observers(self, event)
1565 elif isinstance(c, EventHandler) and c.name is not None:
1566 c = getattr(self, c.name)
-> 1568 c(event)
File ~/git/jdaviz/jdaviz/configs/default/plugins/export/export.py:189, in Export._sync_singleselect(self, event)
187 setattr(self, attr, '')
188 if attr == 'subset_selected':
--> 189 self._set_subset_not_supported_msg()
File ~/git/jdaviz/jdaviz/configs/default/plugins/export/export.py:199, in Export._set_subset_not_supported_msg(self, msg)
197 if self.subset.selected is not None:
198 subset = self.app.get_subsets(self.subset.selected)
--> 199 if self.app._is_subset_spectral(subset[0]):
200 self.subset_invalid_msg = 'Export for spectral subsets not supported.'
201 elif len(subset) > 1:
KeyError: 0
Any idea what's up there?
@bmorris3 did my recent commit fix the error you were getting? |
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.
@bmorris3 - that is by design, you currently can select any single item across all the sections for export. |
@kecnry @cshanahan1 I assumed something was wrong because the de-select happens and then nothing is exported. So I suppose only the latter part is the bug. 🙈 Could we have a message in the subset section that says "Selected subsets will be exported from all viewers". |
It's a single subset - defined the same way in all viewers, right? Is the confusion whether you'll get the spatial subset itself or the spectrum collapsed/extracted from that subset? (If so, that should go away when we stop sending spatial subsets through glue auto-collapse and instead generate data entries that will be listed as data entries here eventually) |
Correct – if I export a spatial subset, it appears in three viewers because it could have at least three outputs (flux-viewer output, uncer-viewer output, spectrum-viewer output). It might be sensible to return specific outputs, but this UI doesn't explain itself to me. |
This will export the subset definition itself (and is one PR in a larger effort that was already planned/designed, so some of this is probably out of scope and can be dealt with in the final design review). Would just changing the heading from "Subset" to "Subset Definition" (or similar) help? |
(I promise I'm not trying to be annoying) Even I'm not sure what "subset definition" means in this context if I'm exporting a FITS file – is it a binary mask with metadata that we can pass into glue? Exporting a region is clearer to me. |
It exports as a region, yes. But I don't think we use the "region" terminology anywhere in the UI right now. What would help in the heading to make this more clear ("Subset (region)"? "Subset as region"?) |
I used the UI to learn that it was a region by looking at the export formats, which are Maybe my confusion stems from the name "Export". If you're coming to this UI as a user without the glue background, you could interpret an "exported subset" to be:
So when I selected |
I could add some text under the Subsets section heading? |
I'm happy with:
|
I feel like 2. would break the convention in the plugin that the (single) selected item is what is going to be exported, maybe? |
Yes, this conflicts with the design. If a viewer is selected, you get the "screenshot" of that viewer. Eventually we also need batch export where you can select both a viewer (screenshot) AND a subset (region) resulting in a zip/tar file containing both. Maybe adding short descriptions under each heading would be useful. For viewers: "export image of plot shown in viewer" and for subsets: "export subset definition as an astropy region", or similar. |
I see what I was missing now, thanks. That sounds good! Maybe we could make the viewer selector say "screenshot from viewer"? |
bda912c
to
e9ee4fe
Compare
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.
Thanks! I think we can/should address some of @bmorris3's concerns further as we implement the rest of the plugin and get the final UI/UX review, but this works for me for now.
<div v-if="subset_items.length > 0"> | ||
<j-plugin-section-header style="margin-top: 12px">Subsets</j-plugin-section-header> | ||
<v-row> | ||
<span class="v-messages v-messages__message text--secondary"> Save subset as astropy region. </span> |
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.
Awesome. 👌🏻
Blocked by
Description
This PR adds the ability to export non-composite spatial subsets through the export plugin.
(JDAT 4239)
(I branched off of #2755, which should be merged first.)
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.
trivial
label.