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

Traceback when attempting to open image after successful connection to omero #13

Open
dstabley opened this issue Jun 26, 2020 · 13 comments
Labels
bug Something isn't working

Comments

@dstabley
Copy link

dstabley commented Jun 26, 2020

I'm able to connect to our Omero server using the master branch pulled from GIT, but when I attempt to pull an image I get a crash. The minimal reproducible step for me is to launch napari_omero from my env, log in using my credentials, and then double click an image to load. I am running this through VScode on an Ubuntu server using a virtual desktop.

(omeroenv) dstabley@ultra94:~/napari-omero$ napari_omero

** (python:83093): WARNING **: 10:31:37.834: AT-SPI: Could not obtain desktop path or name


** (python:83093): WARNING **: 10:31:37.882: AT-SPI: Could not obtain desktop path or name


** (python:83093): WARNING **: 10:31:37.882: atk-bridge: get_device_events_reply: unknown signature

** (python:83093): WARNING **: 10:31:37.882: atk-bridge: get_device_events_reply: unknown signature

** (python:83093): WARNING **: 10:31:37.882: atk-bridge: GetRegisteredEvents returned message with unknown signature

** (python:83093): WARNING **: 10:31:37.929: AT-SPI: Could not obtain desktop path or name


** (python:83093): WARNING **: 10:31:37.929: atk-bridge: get_device_events_reply: unknown signature

** (python:83093): WARNING **: 10:31:37.929: atk-bridge: get_device_events_reply: unknown signature

** (python:83093): WARNING **: 10:31:37.929: atk-bridge: GetRegisteredEvents returned message with unknown signature
/home/solecgrp/dstabley/anaconda3/envs/omeroenv/lib/python3.6/site-packages/napari/utils/dask_utils.py:173: UserWarning: For best performance with Dask arrays in napari, please upgrade Dask to v2.15.0 or later. Current version is 2.13.0
  'For best performance with Dask arrays in napari, please '
WARNING: Traceback (most recent call last):
  File "/home/solecgrp/dstabley/anaconda3/envs/omeroenv/lib/python3.6/site-packages/napari_omero-0.1.1.dev5+g6d45d4c-py3.6.egg/napari_omero/widgets/main.py", line 70, in _on_thumbnail_selected
  File "/home/solecgrp/dstabley/anaconda3/envs/omeroenv/lib/python3.6/site-packages/napari_omero-0.1.1.dev5+g6d45d4c-py3.6.egg/napari_omero/widgets/main.py", line 84, in load_image
  File "/home/solecgrp/dstabley/anaconda3/envs/omeroenv/lib/python3.6/site-packages/napari/components/layerlist.py", line 139, in remove_selected
    self.pop(i)
  File "/home/solecgrp/dstabley/anaconda3/envs/omeroenv/lib/python3.6/site-packages/napari/utils/list/_model.py", line 64, in pop
    self.events.removed(item=obj, index=key)
  File "/home/solecgrp/dstabley/anaconda3/envs/omeroenv/lib/python3.6/site-packages/napari/utils/event.py", line 508, in __call__
    self._invoke_callback(cb, event)
  File "/home/solecgrp/dstabley/anaconda3/envs/omeroenv/lib/python3.6/site-packages/napari/utils/event.py", line 529, in _invoke_callback
    cb_event=(cb, event),
  File "/home/solecgrp/dstabley/anaconda3/envs/omeroenv/lib/python3.6/site-packages/napari/utils/event.py", line 523, in _invoke_callback
    cb(event)
  File "/home/solecgrp/dstabley/anaconda3/envs/omeroenv/lib/python3.6/site-packages/napari/_qt/qt_viewer.py", line 264, in _remove_layer
    vispy_layer = self.layer_to_visual[layer]
KeyError: <Image layer '0' at 0x7f2ee3ca5630>
WARNING:vispy:Traceback (most recent call last):
  File "/home/solecgrp/dstabley/anaconda3/envs/omeroenv/lib/python3.6/site-packages/napari_omero-0.1.1.dev5+g6d45d4c-py3.6.egg/napari_omero/widgets/main.py", line 70, in _on_thumbnail_selected
  File "/home/solecgrp/dstabley/anaconda3/envs/omeroenv/lib/python3.6/site-packages/napari_omero-0.1.1.dev5+g6d45d4c-py3.6.egg/napari_omero/widgets/main.py", line 84, in load_image
  File "/home/solecgrp/dstabley/anaconda3/envs/omeroenv/lib/python3.6/site-packages/napari/components/layerlist.py", line 139, in remove_selected
    self.pop(i)
  File "/home/solecgrp/dstabley/anaconda3/envs/omeroenv/lib/python3.6/site-packages/napari/utils/list/_model.py", line 64, in pop
    self.events.removed(item=obj, index=key)
  File "/home/solecgrp/dstabley/anaconda3/envs/omeroenv/lib/python3.6/site-packages/napari/utils/event.py", line 508, in __call__
    self._invoke_callback(cb, event)
  File "/home/solecgrp/dstabley/anaconda3/envs/omeroenv/lib/python3.6/site-packages/napari/utils/event.py", line 529, in _invoke_callback
    cb_event=(cb, event),
  File "/home/solecgrp/dstabley/anaconda3/envs/omeroenv/lib/python3.6/site-packages/napari/utils/event.py", line 523, in _invoke_callback
    cb(event)
  File "/home/solecgrp/dstabley/anaconda3/envs/omeroenv/lib/python3.6/site-packages/napari/_qt/qt_viewer.py", line 264, in _remove_layer
    vispy_layer = self.layer_to_visual[layer]
KeyError: <Image layer '0' at 0x7f2ee3ca5630>
Aborted (core dumped)
(omeroenv) dstabley@ultra94:~/napari-omero$ napari_omero

** (python:83978): WARNING **: 10:36:18.327: AT-SPI: Could not obtain desktop path or name


** (python:83978): WARNING **: 10:36:18.361: AT-SPI: Could not obtain desktop path or name


** (python:83978): WARNING **: 10:36:18.361: atk-bridge: get_device_events_reply: unknown signature

** (python:83978): WARNING **: 10:36:18.362: atk-bridge: get_device_events_reply: unknown signature

** (python:83978): WARNING **: 10:36:18.362: atk-bridge: GetRegisteredEvents returned message with unknown signature

** (python:83978): WARNING **: 10:36:18.402: AT-SPI: Could not obtain desktop path or name


** (python:83978): WARNING **: 10:36:18.402: atk-bridge: get_device_events_reply: unknown signature

** (python:83978): WARNING **: 10:36:18.402: atk-bridge: get_device_events_reply: unknown signature

** (python:83978): WARNING **: 10:36:18.402: atk-bridge: GetRegisteredEvents returned message with unknown signature
/home/solecgrp/dstabley/anaconda3/envs/omeroenv/lib/python3.6/site-packages/napari/utils/dask_utils.py:173: UserWarning: For best performance with Dask arrays in napari, please upgrade Dask to v2.15.0 or later. Current version is 2.13.0
  'For best performance with Dask arrays in napari, please '
WARNING: Traceback (most recent call last):
  File "/home/solecgrp/dstabley/anaconda3/envs/omeroenv/lib/python3.6/site-packages/napari_omero-0.1.1.dev5+g6d45d4c-py3.6.egg/napari_omero/widgets/main.py", line 70, in _on_thumbnail_selected
  File "/home/solecgrp/dstabley/anaconda3/envs/omeroenv/lib/python3.6/site-packages/napari_omero-0.1.1.dev5+g6d45d4c-py3.6.egg/napari_omero/widgets/main.py", line 84, in load_image
  File "/home/solecgrp/dstabley/anaconda3/envs/omeroenv/lib/python3.6/site-packages/napari/components/layerlist.py", line 139, in remove_selected
    self.pop(i)
  File "/home/solecgrp/dstabley/anaconda3/envs/omeroenv/lib/python3.6/site-packages/napari/utils/list/_model.py", line 64, in pop
    self.events.removed(item=obj, index=key)
  File "/home/solecgrp/dstabley/anaconda3/envs/omeroenv/lib/python3.6/site-packages/napari/utils/event.py", line 508, in __call__
    self._invoke_callback(cb, event)
  File "/home/solecgrp/dstabley/anaconda3/envs/omeroenv/lib/python3.6/site-packages/napari/utils/event.py", line 529, in _invoke_callback
    cb_event=(cb, event),
  File "/home/solecgrp/dstabley/anaconda3/envs/omeroenv/lib/python3.6/site-packages/napari/utils/event.py", line 523, in _invoke_callback
    cb(event)
  File "/home/solecgrp/dstabley/anaconda3/envs/omeroenv/lib/python3.6/site-packages/napari/_qt/qt_viewer.py", line 264, in _remove_layer
    vispy_layer = self.layer_to_visual[layer]
KeyError: <Image layer '0' at 0x7fbe6d562630>
WARNING:vispy:Traceback (most recent call last):
  File "/home/solecgrp/dstabley/anaconda3/envs/omeroenv/lib/python3.6/site-packages/napari_omero-0.1.1.dev5+g6d45d4c-py3.6.egg/napari_omero/widgets/main.py", line 70, in _on_thumbnail_selected
  File "/home/solecgrp/dstabley/anaconda3/envs/omeroenv/lib/python3.6/site-packages/napari_omero-0.1.1.dev5+g6d45d4c-py3.6.egg/napari_omero/widgets/main.py", line 84, in load_image
  File "/home/solecgrp/dstabley/anaconda3/envs/omeroenv/lib/python3.6/site-packages/napari/components/layerlist.py", line 139, in remove_selected
    self.pop(i)
  File "/home/solecgrp/dstabley/anaconda3/envs/omeroenv/lib/python3.6/site-packages/napari/utils/list/_model.py", line 64, in pop
    self.events.removed(item=obj, index=key)
  File "/home/solecgrp/dstabley/anaconda3/envs/omeroenv/lib/python3.6/site-packages/napari/utils/event.py", line 508, in __call__
    self._invoke_callback(cb, event)
  File "/home/solecgrp/dstabley/anaconda3/envs/omeroenv/lib/python3.6/site-packages/napari/utils/event.py", line 529, in _invoke_callback
    cb_event=(cb, event),
  File "/home/solecgrp/dstabley/anaconda3/envs/omeroenv/lib/python3.6/site-packages/napari/utils/event.py", line 523, in _invoke_callback
    cb(event)
  File "/home/solecgrp/dstabley/anaconda3/envs/omeroenv/lib/python3.6/site-packages/napari/_qt/qt_viewer.py", line 264, in _remove_layer
    vispy_layer = self.layer_to_visual[layer]
KeyError: <Image layer '0' at 0x7fbe6d562630>
Aborted (core dumped)
(omeroenv) dstabley@ultra94:~/napari-omero$ napari_omero

** (python:84312): WARNING **: 10:36:37.100: AT-SPI: Could not obtain desktop path or name


** (python:84312): WARNING **: 10:36:37.121: AT-SPI: Could not obtain desktop path or name


** (python:84312): WARNING **: 10:36:37.122: atk-bridge: get_device_events_reply: unknown signature

** (python:84312): WARNING **: 10:36:37.122: atk-bridge: get_device_events_reply: unknown signature

** (python:84312): WARNING **: 10:36:37.122: atk-bridge: GetRegisteredEvents returned message with unknown signature

** (python:84312): WARNING **: 10:36:37.136: AT-SPI: Could not obtain desktop path or name


** (python:84312): WARNING **: 10:36:37.136: atk-bridge: get_device_events_reply: unknown signature

** (python:84312): WARNING **: 10:36:37.136: atk-bridge: get_device_events_reply: unknown signature

** (python:84312): WARNING **: 10:36:37.136: atk-bridge: GetRegisteredEvents returned message with unknown signature
/home/solecgrp/dstabley/anaconda3/envs/omeroenv/lib/python3.6/site-packages/napari/utils/dask_utils.py:173: UserWarning: For best performance with Dask arrays in napari, please upgrade Dask to v2.15.0 or later. Current version is 2.13.0
  'For best performance with Dask arrays in napari, please '
WARNING: Traceback (most recent call last):
  File "/home/solecgrp/dstabley/anaconda3/envs/omeroenv/lib/python3.6/site-packages/napari_omero-0.1.1.dev5+g6d45d4c-py3.6.egg/napari_omero/widgets/main.py", line 70, in _on_thumbnail_selected
  File "/home/solecgrp/dstabley/anaconda3/envs/omeroenv/lib/python3.6/site-packages/napari_omero-0.1.1.dev5+g6d45d4c-py3.6.egg/napari_omero/widgets/main.py", line 84, in load_image
  File "/home/solecgrp/dstabley/anaconda3/envs/omeroenv/lib/python3.6/site-packages/napari/components/layerlist.py", line 139, in remove_selected
    self.pop(i)
  File "/home/solecgrp/dstabley/anaconda3/envs/omeroenv/lib/python3.6/site-packages/napari/utils/list/_model.py", line 64, in pop
    self.events.removed(item=obj, index=key)
  File "/home/solecgrp/dstabley/anaconda3/envs/omeroenv/lib/python3.6/site-packages/napari/utils/event.py", line 508, in __call__
    self._invoke_callback(cb, event)
  File "/home/solecgrp/dstabley/anaconda3/envs/omeroenv/lib/python3.6/site-packages/napari/utils/event.py", line 529, in _invoke_callback
    cb_event=(cb, event),
  File "/home/solecgrp/dstabley/anaconda3/envs/omeroenv/lib/python3.6/site-packages/napari/utils/event.py", line 523, in _invoke_callback
    cb(event)
  File "/home/solecgrp/dstabley/anaconda3/envs/omeroenv/lib/python3.6/site-packages/napari/_qt/qt_viewer.py", line 264, in _remove_layer
    vispy_layer = self.layer_to_visual[layer]
KeyError: <Image layer '0' at 0x7efec754b630>
WARNING:vispy:Traceback (most recent call last):
  File "/home/solecgrp/dstabley/anaconda3/envs/omeroenv/lib/python3.6/site-packages/napari_omero-0.1.1.dev5+g6d45d4c-py3.6.egg/napari_omero/widgets/main.py", line 70, in _on_thumbnail_selected
  File "/home/solecgrp/dstabley/anaconda3/envs/omeroenv/lib/python3.6/site-packages/napari_omero-0.1.1.dev5+g6d45d4c-py3.6.egg/napari_omero/widgets/main.py", line 84, in load_image
  File "/home/solecgrp/dstabley/anaconda3/envs/omeroenv/lib/python3.6/site-packages/napari/components/layerlist.py", line 139, in remove_selected
    self.pop(i)
  File "/home/solecgrp/dstabley/anaconda3/envs/omeroenv/lib/python3.6/site-packages/napari/utils/list/_model.py", line 64, in pop
    self.events.removed(item=obj, index=key)
  File "/home/solecgrp/dstabley/anaconda3/envs/omeroenv/lib/python3.6/site-packages/napari/utils/event.py", line 508, in __call__
    self._invoke_callback(cb, event)
  File "/home/solecgrp/dstabley/anaconda3/envs/omeroenv/lib/python3.6/site-packages/napari/utils/event.py", line 529, in _invoke_callback
    cb_event=(cb, event),
  File "/home/solecgrp/dstabley/anaconda3/envs/omeroenv/lib/python3.6/site-packages/napari/utils/event.py", line 523, in _invoke_callback
    cb(event)
  File "/home/solecgrp/dstabley/anaconda3/envs/omeroenv/lib/python3.6/site-packages/napari/_qt/qt_viewer.py", line 264, in _remove_layer
    vispy_layer = self.layer_to_visual[layer]
KeyError: <Image layer '0' at 0x7efec754b630>
Aborted (core dumped)
@tlambert03
Copy link
Owner

hi @dstabley, looks like you're in a somewhat old environment (based on that dask version error). I don't yet know what's going on here... but do you still do you get the same error if you work in a fresh environment as described here? (note, you'll need to pip install from github ... so use pip install git+git://github.com/tlambert03/napari-omero.git instead of pip install napari-omero

depending on how you installed napari-omero (for instance, if you didn't use an editable install, but then you recloned), it may also be that your napari_omero command script is stale and that you need to reinstall

@dstabley
Copy link
Author

@tlambert03 I had been using my project's dev environment, but I just confirmed this with a brand new environment following your instructions. I cloned the repo to my local drive, made an env from your yml file, then ran the setup.py script. I then launched napari_omero, got the gui, saw that it was connected and could see my images. However, when I double click an image I get the same error as previously.

The only thing I can't test thus far is the direct pip install git+git//URL method as this linux server seems to have that route blocked (keeps timing out).

@tlambert03
Copy link
Owner

oh actually... are you always double clicking? I can actually see why that might cause this bug (which is fundamentally a problem with the way I'm clearing the viewer when loading a new image). if you single click and wait does it change anything?

@dstabley
Copy link
Author

@tlambert03 just confirmed that single click also does the same thing. I can navigate the entire tree but can't open anything.

@tlambert03 tlambert03 added the bug Something isn't working label Jun 26, 2020
@tlambert03
Copy link
Owner

ok thanks for checking. one more question: The stack trace indicates this is a bug in napari with removing a layer (and napari-omero attempts to remove all layers before loading one). but I'm still a little confused why it would happen on the first load, and not 2nd+ ... do you happen to have any layers already loaded in napari when you do this? (not that you shouldn't be able to do that... just curious)

@dstabley
Copy link
Author

@tlambert03 I don't have any layers loaded. I just ran an interesting test, though. I uploaded a new synthetic data TIFF I had to my server and it loaded fine. I then noticed the images I had been trying to access have a common bug we were having where the metadata Z and T series were swapped. I'm guessing that maybe the plugin can't handle this metadata mismatch. Omero handles it on the server side, but if you're pulling on the assumption of a given number of planes or data shape it may cause a problem. One other detail is that the image that worked is 8 bit and the one that crashed is 16 bit.

@tlambert03
Copy link
Owner

definitely interesting. I can certainly see how that might create a problem. but i can't quite see how it would result in the KeyError in this stack track! 😅 i can probably prevent that key error... which may then reveal an additional problem if you have a metadata mismatch.

@dstabley
Copy link
Author

Ok great, let me know. I'm happy to run additional tests.

@dstabley
Copy link
Author

@tlambert03 one more question - what is the most efficient way to grab an image that is loaded into Napari as a numpy stack in the backend? I haven't done this yet but pulling an Omero image and doing an operation on it would be cool.

@tlambert03
Copy link
Owner

all of the layers have a data attribute that holds the numpy array.
so for example:

import napari
import numpy as np

with napari.gui_qt():
    viewer = napari.Viewer()
    # just as an example to get a layer... it doesn't matter
    # where the layer comes from, could have been loaded from OMERO
    napari.add_image(np.random.rand(16,128,128))

    # once you have a loaded layer, you need to get the layer object, like the "first" layer
    layer = viewer.layers[0]
    # here's the actual numpy (or dask, in the case of napari-omero) array
    layer.data

@dstabley
Copy link
Author

dstabley commented Jun 26, 2020

@tlambert03 some more interesting behavior. When I load an image through the standalone napari_omero viewer it loads fine, but when I add the napari_omero extension as a dockable widget in the embedded napari viewer in my application as such:

class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
    def __init__(self, *args, obj=None, **kwargs):
          self.viewer = napari.Viewer()
          self.viewer.window.add_dock_widget(OMEROWidget(), area="right")

I get the following when trying the same operation (note that there were no layers in the napari viewer as it had just been initialized and no operations had been performed):

WARNING: Traceback (most recent call last):
  File "C:\Users\Daniel\anaconda3\envs\NIML_Lattice_Tools\lib\site-packages\napari_omero-0.1.1.dev5+g6d45d4c-py3.6.egg\napari_omero\widgets\main.py", line 70, in _on_thumbnail_selected
  File "C:\Users\Daniel\anaconda3\envs\NIML_Lattice_Tools\lib\site-packages\napari_omero-0.1.1.dev5+g6d45d4c-py3.6.egg\napari_omero\widgets\main.py", line 84, in load_image
  File "C:\Users\Daniel\anaconda3\envs\NIML_Lattice_Tools\lib\site-packages\napari\components\layerlist.py", line 139, in remove_selected
    self.pop(i)
  File "C:\Users\Daniel\anaconda3\envs\NIML_Lattice_Tools\lib\site-packages\napari\utils\list\_model.py", line 64, in pop
    self.events.removed(item=obj, index=key)
  File "C:\Users\Daniel\anaconda3\envs\NIML_Lattice_Tools\lib\site-packages\napari\utils\event.py", line 508, in __call__
    self._invoke_callback(cb, event)
  File "C:\Users\Daniel\anaconda3\envs\NIML_Lattice_Tools\lib\site-packages\napari\utils\event.py", line 529, in _invoke_callback
    cb_event=(cb, event),
  File "C:\Users\Daniel\anaconda3\envs\NIML_Lattice_Tools\lib\site-packages\napari\utils\event.py", line 523, in _invoke_callback
    cb(event)
  File "C:\Users\Daniel\anaconda3\envs\NIML_Lattice_Tools\lib\site-packages\napari\_qt\qt_viewer.py", line 246, in _remove_layer
    vispy_layer = self.layer_to_visual[layer]
KeyError: <Image layer '0' at 0x1c94e8972e8>
WARNING:vispy:Traceback (most recent call last):
  File "C:\Users\Daniel\anaconda3\envs\NIML_Lattice_Tools\lib\site-packages\napari_omero-0.1.1.dev5+g6d45d4c-py3.6.egg\napari_omero\widgets\main.py", line 70, in _on_thumbnail_selected
  File "C:\Users\Daniel\anaconda3\envs\NIML_Lattice_Tools\lib\site-packages\napari_omero-0.1.1.dev5+g6d45d4c-py3.6.egg\napari_omero\widgets\main.py", line 84, in load_image
  File "C:\Users\Daniel\anaconda3\envs\NIML_Lattice_Tools\lib\site-packages\napari\components\layerlist.py", line 139, in remove_selected
    self.pop(i)
  File "C:\Users\Daniel\anaconda3\envs\NIML_Lattice_Tools\lib\site-packages\napari\utils\list\_model.py", line 64, in pop
    self.events.removed(item=obj, index=key)
  File "C:\Users\Daniel\anaconda3\envs\NIML_Lattice_Tools\lib\site-packages\napari\utils\event.py", line 508, in __call__
    self._invoke_callback(cb, event)
  File "C:\Users\Daniel\anaconda3\envs\NIML_Lattice_Tools\lib\site-packages\napari\utils\event.py", line 529, in _invoke_callback
    cb_event=(cb, event),
  File "C:\Users\Daniel\anaconda3\envs\NIML_Lattice_Tools\lib\site-packages\napari\utils\event.py", line 523, in _invoke_callback
    cb(event)
  File "C:\Users\Daniel\anaconda3\envs\NIML_Lattice_Tools\lib\site-packages\napari\_qt\qt_viewer.py", line 246, in _remove_layer
    vispy_layer = self.layer_to_visual[layer]
KeyError: <Image layer '0' at 0x1c94e8972e8>

@dstabley
Copy link
Author

dstabley commented Jun 26, 2020

@tlambert03 Further development on the previous post - if I pre-load a points layer into my application's embedded Napari viewer before clicking on the Omero image selection it works properly. This is reproducible. I suspect that maybe this comes from https://github.com/tlambert03/napari-omero/blob/master/src/napari_omero/widgets/main.py line 83 and 84:

def load_image(self, wrapper: BlitzObjectWrapper):
        self.viewer.layers.select_all()
        self.viewer.layers.remove_selected()

        type_ = wrapper.__class__.__name__[1:-7]
        id_ = wrapper.getId()
        self.viewer.open(f"{type_}:{id_}", plugin="omero")

Where the function selects all layers - is it possible that because my window initializes with no layers that this is throwing an exception? It's all I can think of as for why creating a null points layer fixes the crash.

@tlambert03
Copy link
Owner

It’s definitely related to those two lines, but it should still not be an error to call remove_selected with no layers in the viewer. I need to look closer at the napari events there to see why it might be happening

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

No branches or pull requests

2 participants