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

Switching between data in code causes infinite loop #185

Closed
javerbukh opened this issue Jul 2, 2020 · 4 comments · Fixed by #202 or #427
Closed

Switching between data in code causes infinite loop #185

javerbukh opened this issue Jul 2, 2020 · 4 comments · Fixed by #202 or #427
Labels
bug Something isn't working

Comments

@javerbukh
Copy link
Contributor

The following code, which is used to switch from visualizing an old spectrum to a new one, causes an infinite loop:

        # Replace old spectrum with new one with updated units.
        self.app.add_data(converted_spec, new_label)
        self.app.add_data_to_viewer("spectrum-viewer", new_label)
        self.app.remove_data_from_viewer("spectrum-viewer", old_label)

This bug usually comes after the second round of unit conversion. Example:

Jul-02-2020 10-33-34

@eteq
Copy link
Contributor

eteq commented Jul 16, 2020

This is now more acute with #180 merged, as it seems to suffer from the bug.

@camipacifici
Copy link
Contributor

In the notebook, with jdaviz version 1.0.4.dev239+ge02daf6
I call Specviz, then I load a bunch of spectra with a for loop. If I do not wait for the spectra to finish loading and click the hammer and screwdriver icon, I get this traceback (when the loading is done)


IndexError Traceback (most recent call last)
~/miniconda3/envs/jdaviz_jan21/lib/python3.9/site-packages/ipywidgets/widgets/widget.py in _handle_msg(self, msg)
674 if 'buffer_paths' in data:
675 _put_buffers(state, data['buffer_paths'], msg['buffers'])
--> 676 self.set_state(state)
677
678 # Handle a state request.
~/miniconda3/envs/jdaviz_jan21/lib/python3.9/site-packages/ipywidgets/widgets/widget.py in set_state(self, sync_data)
543 from_json = self.trait_metadata(name, 'from_json',
544 self._trait_from_json)
--> 545 self.set_trait(name, from_json(sync_data[name], self))
546
547 def send(self, content, buffers=None):
~/miniconda3/envs/jdaviz_jan21/lib/python3.9/site-packages/glue_jupyter/state_traitlets_helpers.py in update_state_from_json(self, json, widget)
149 self._block_on_state_change = True
150 try:
--> 151 update_state_from_dict(state, json)
152 finally:
153 self._block_on_state_change = False
~/miniconda3/envs/jdaviz_jan21/lib/python3.9/site-packages/glue_jupyter/state_traitlets_helpers.py in update_state_from_dict(state, changes)
49 update_state_from_dict(callback_list[i], changes[name][i])
50 else:
---> 51 if (changes[name][i] != MAGIC_IGNORE and
52 callback_list[i] != changes[name][i]):
53 callback_list[i] = changes[name][i]
IndexError: list index out of range

Then if I go in the Data menu and start unclicking data, the ghost is back. Data gets clicked and unclicked in a loop with no manual input.

@camipacifici camipacifici reopened this Jan 27, 2021
mariobuikhuizen added a commit to mariobuikhuizen/jdaviz that referenced this issue Feb 16, 2021
mariobuikhuizen added a commit to mariobuikhuizen/jdaviz that referenced this issue Feb 16, 2021
Fixes the error when interacting with the GUI while data is
loading in spacetelescope#185.
mariobuikhuizen added a commit to mariobuikhuizen/jdaviz that referenced this issue Feb 16, 2021
mariobuikhuizen added a commit to mariobuikhuizen/jdaviz that referenced this issue Feb 16, 2021
Fixes the error when interacting with the GUI while data is
loading in spacetelescope#185.
@rosteen
Copy link
Collaborator

rosteen commented Feb 24, 2021

@mariobuikhuizen It turns out that I was a little hasty in merging #427 - I noticed today when testing out something that would be enabled by that PR that it unfortunately got rid of the looping bug by getting rid of something we need. Specifically, adding data to a viewer programmatically via app.add_data_to_viewer() no longer updates which datasets are checked in the UI data dropdown. You can see an example of this by using the Unit Conversion plugin to switch to a different spectral axis unit in Specviz: the data in the viewer will change to the newly created dataset, but if you open the data selection menu for the viewer it will still appear as though the original data is selected. I think this is due to removing the lines:

viewer_item = self._viewer_item_by_id(viewer_id)

and

viewer_item['selected_data_items'] = selected_items.

I'm not sure what the best course of action is here in terms of opening a new issue vs reopening this one.

@mariobuikhuizen
Copy link
Collaborator

mariobuikhuizen commented Mar 1, 2021

Looking at #446 I found out that the v-treeview component has a bug (vuetifyjs/vuetify#13181) that causes the removed lines to be problematic.

Maybe we can use another component for the list (or tree) of checkboxes?

I tested out if another component would fix it in: #450. I chose a toggle button groups as that was the easiest to implement.

rosteen added a commit that referenced this issue Mar 8, 2021
…st_of_checkboxes

A better fix for the GUI update loop #185
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants