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

Imviz: Unable to reload same file multiple times #689

Closed
Jdaviz-Triage-Bot opened this issue Jun 17, 2021 · 5 comments · Fixed by #1649
Closed

Imviz: Unable to reload same file multiple times #689

Jdaviz-Triage-Bot opened this issue Jun 17, 2021 · 5 comments · Fixed by #1649
Labels
bug Something isn't working imviz

Comments

@Jdaviz-Triage-Bot
Copy link

Jdaviz-Triage-Bot commented Jun 17, 2021

Reporter: pllim

Workflow:

  1. Open Imviz app.
  2. Load an image using imviz.load_data("myfile.fits")
  3. Run Step 2 a few times.
  4. See the reload fails and emits warnings.

The screenshot below was from testing #680 but the bug existed even before that PR.

Screenshot 2021-06-16 165217

🐱


DISCLAIMER: This issue was autocreated by the Jdaviz Issue Creation Bot on behalf of the reporter. If any information is incorrect, please contact Duy Nguyen

@pllim
Copy link
Contributor

pllim commented Jun 8, 2022

This came up during Roman Hack Day too when someone was trying to reload the same object into existing Imviz but unable to do so.

@camipacifici
Copy link
Contributor

camipacifici commented Sep 13, 2022

This now works loading the same image a second time, but complains at the third time when adding the image to the viewer.

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
File .../ipyvue/VueTemplateWidget.py:60, in Events._handle_event(self, _, content, buffers)
     58     getattr(self, "vue_" + event)(data, buffers)
     59 else:
---> 60     getattr(self, "vue_" + event)(data)

File .../jdaviz/app.py:1248, in Application.vue_data_item_selected(self, event)
   1245 else:
   1246     selected_items = {k: v for k, v in viewer_item['selected_data_items'].items() if k != item_id}  # noqa
-> 1248 self._update_selected_data_items(viewer_id, selected_items)

File .../jdaviz/app.py:1302, in Application._update_selected_data_items(self, viewer_id, selected_items)
   1300 # Include any selected data in the viewer
   1301 for data_id, visibility in selected_items.items():
-> 1302     label = self._get_data_item_by_id(data_id)['name']
   1304     if label is None:
   1305         warnings.warn(f"No data item with id '{data_id}' found in "
   1306                       f"viewer '{viewer_id}'.")

TypeError: 'NoneType' object is not subscriptable

@kecnry
Copy link
Member

kecnry commented Sep 13, 2022

This traceback has come up in a few different scenarios now, including #1614 (and is caused by the new data-menu from #1313 and follow-up efforts)

@kecnry
Copy link
Member

kecnry commented Sep 16, 2022

#1649 removes the traceback, but is still giving unexpected behavior:

import warnings
warnings.simplefilter('ignore')

from astropy.utils.data import download_file
from jdaviz import Imviz

imviz = Imviz()
acs_47tuc_1 = download_file('https://mast.stsci.edu/api/v0.1/Download/file?uri=mast:HST/product/jbqf03gjq_flc.fits', cache=True)

imviz.load_data(acs_47tuc_1)

imviz.show()

this loads the data entry with the default data_label='acs_47tuc_1[SCI,1]' (label "A")

loading the same data file again creates a new data entry with data_label='acs_47tuc_1[SCI,1]_2' (label "B")

imviz.load_data(acs_47tuc_1)

calling a third time, the user would reasonably expect a new data entry with data_label='acs_47tuc_1[SCI,1]_3' (label "C"), but instead the second entry is removed from the viewer (but still available in the app).

imviz.load_data(acs_47tuc_1)
print(imviz.app.data_collection)

@pllim
Copy link
Contributor

pllim commented Sep 16, 2022

Re: #689 (comment)

This was because of some "0th order" fix for #600 (#680) that is not ideal. I added a commit to #1649 to address this. Though I think that is the opposite of what people actually want (they want to reload rather than create even more data) but at least it is more consistent now. True reloading already has its own ticket.

Also see https://github.com/spacetelescope/jdaviz/pull/680/files#r652051761

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working imviz
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants