jni / zarpaint

Paint segmentations directly to on-disk/remote zarr arrays
BSD 3-Clause "New" or "Revised" License
14 stars 8 forks source link

AttributeError: 'Image' object has no attribute 'value' #34

Closed GenevieveBuckley closed 2 years ago

GenevieveBuckley commented 2 years ago

I am consistently seeing this attribute error when I use zarpaint: AttributeError: 'Image' object has no attribute 'value'.

It doesn't seem to crash the program, but I think we should still try to get rid of it (if nothing else, it's been confusing the issue for me when I run into other errors that do cause zarpaint to crash, and makes it harder to debug)

Full error message (click to expand) ```python-traceback In [1]: import numpy as np In [2]: import napari In [3]: data = np.ones((500,500,500)) In [4]: viewer = napari.view_image(data) Traceback (most recent call last): File "C:\Users\CryoEM\.conda\envs\zarpaint-dev\lib\site-packages\magicgui\widgets\_bases\value_widget.py", line 57, in _on_value_change self.changed.emit(value) File "psygnal\\_signal.py", line 682, in psygnal._signal.SignalInstance.emit File "psygnal\\_signal.py", line 724, in psygnal._signal.SignalInstance._run_emit_loop File "psygnal\\_signal.py", line 725, in psygnal._signal.SignalInstance._run_emit_loop File "psygnal\\_signal.py", line 745, in psygnal._signal.SignalInstance._run_emit_loop File "C:\Users\CryoEM\.conda\envs\zarpaint-dev\lib\site-packages\toolz\functoolz.py", line 306, in __call__ return self._partial(*args, **kwargs) File "c:\users\cryoem\documents\github\zarpaint\src\zarpaint\_zarpaint.py", line 20, in _set_default_labels_path source_image = source_image_event.value AttributeError: 'Image' object has no attribute 'value' If you suspect this is an IPython 8.3.0 bug, please report it at: https://github.com/ipython/ipython/issues or send an email to the mailing list at ipython-dev@python.org You can print a more detailed traceback right now with "%tb", or use "%debug" to interactively debug it. Extra-detailed tracebacks for bug-reporting purposes can be enabled via: %config Application.verbose_crash=True ```

Operating system: Windows 10 Python version: python 3.9.12

conda list (click to expand) (Note: I'm using a dev version of zarpaint in this conda env, but I've seen the same error message happen in other situations too) ``` (zarpaint-dev) C:\Users\CryoEM\Documents\GitHub\zarpaint>conda list # packages in environment at C:\Users\CryoEM\.conda\envs\zarpaint-dev: # # Name Version Build Channel alabaster 0.7.12 py_0 conda-forge aom 3.3.0 h0e60522_1 conda-forge appdirs 1.4.4 pyh9f0ad1d_0 conda-forge asciitree 0.3.3 py_2 conda-forge asttokens 2.0.5 pyhd8ed1ab_0 conda-forge attrs 21.4.0 pyhd8ed1ab_0 conda-forge babel 2.10.1 pyhd8ed1ab_0 conda-forge backcall 0.2.0 pyh9f0ad1d_0 conda-forge backports 1.0 py_2 conda-forge backports.functools_lru_cache 1.6.4 pyhd8ed1ab_0 conda-forge blosc 1.21.1 h74325e0_2 conda-forge bokeh 2.4.2 py39hcbf5309_1 conda-forge brotli 1.0.9 h8ffe710_7 conda-forge brotli-bin 1.0.9 h8ffe710_7 conda-forge brotlipy 0.7.0 py39hb82d6ee_1004 conda-forge bzip2 1.0.8 h8ffe710_4 conda-forge c-blosc2 2.1.1 h09319c2_0 conda-forge ca-certificates 2021.10.8 h5b45459_0 conda-forge cachey 0.2.1 pyh9f0ad1d_0 conda-forge certifi 2021.10.8 py39hcbf5309_2 conda-forge cffi 1.15.0 py39h0878f49_0 conda-forge cfitsio 4.1.0 h5a969a9_0 conda-forge charls 2.3.4 h39d44d4_0 conda-forge charset-normalizer 2.0.12 pyhd8ed1ab_0 conda-forge click 8.1.3 py39hcbf5309_0 conda-forge cloudpickle 2.0.0 pyhd8ed1ab_0 conda-forge colorama 0.4.4 pyh9f0ad1d_0 conda-forge cryptography 36.0.2 py39h7bc7c5c_1 conda-forge cycler 0.11.0 pyhd8ed1ab_0 conda-forge cytoolz 0.11.2 py39hb82d6ee_2 conda-forge dask 2022.5.0 pyhd8ed1ab_0 conda-forge dask-core 2022.5.0 pyhd8ed1ab_0 conda-forge debugpy 1.6.0 py39h415ef7b_0 conda-forge decorator 5.1.1 pyhd8ed1ab_0 conda-forge distributed 2022.5.0 pyhd8ed1ab_0 conda-forge docstring_parser 0.13 pyhd8ed1ab_0 conda-forge docutils 0.15.2 py39hcbf5309_3 conda-forge entrypoints 0.4 pyhd8ed1ab_0 conda-forge executing 0.8.3 pyhd8ed1ab_0 conda-forge fasteners 0.17.3 pyhd8ed1ab_0 conda-forge fonttools 4.33.3 py39hb82d6ee_0 conda-forge freetype 2.10.4 h546665d_1 conda-forge freetype-py 2.3.0 pyhd8ed1ab_0 conda-forge fsspec 2022.3.0 pyhd8ed1ab_0 conda-forge giflib 5.2.1 h8d14728_2 conda-forge heapdict 1.0.1 py_0 conda-forge hsluv 5.0.2 pyh44b312d_0 conda-forge icu 69.1 h0e60522_0 conda-forge idna 3.3 pyhd8ed1ab_0 conda-forge imagecodecs 2022.2.22 py39hc1e9cd8_4 conda-forge imageio 2.19.1 pyhcf75d05_0 conda-forge imagesize 1.3.0 pyhd8ed1ab_0 conda-forge importlib-metadata 4.11.3 py39hcbf5309_1 conda-forge importlib_resources 5.7.1 pyhd8ed1ab_0 conda-forge intel-openmp 2022.0.0 h57928b3_3663 conda-forge intervaltree 3.0.2 py_0 conda-forge ipykernel 6.13.0 py39h832f523_0 conda-forge ipython 8.3.0 py39hcbf5309_0 conda-forge ipython_genutils 0.2.0 py_1 conda-forge jbig 2.1 h8d14728_2003 conda-forge jedi 0.18.1 py39hcbf5309_1 conda-forge jinja2 3.0.3 pyhd8ed1ab_0 conda-forge jpeg 9e h8ffe710_1 conda-forge jsonschema 4.5.1 pyhd8ed1ab_0 conda-forge jupyter_client 7.3.1 pyhd8ed1ab_0 conda-forge jupyter_core 4.9.2 py39hcbf5309_0 conda-forge jxrlib 1.1 h8ffe710_2 conda-forge kiwisolver 1.4.2 py39h2e07f2f_1 conda-forge krb5 1.19.3 h1176d77_0 conda-forge lcms2 2.12 h2a16943_0 conda-forge lerc 3.0 h0e60522_0 conda-forge libaec 1.0.6 h39d44d4_0 conda-forge libavif 0.10.1 h8ffe710_0 conda-forge libblas 3.9.0 14_win64_mkl conda-forge libbrotlicommon 1.0.9 h8ffe710_7 conda-forge libbrotlidec 1.0.9 h8ffe710_7 conda-forge libbrotlienc 1.0.9 h8ffe710_7 conda-forge libcblas 3.9.0 14_win64_mkl conda-forge libclang 13.0.1 default_h81446c8_0 conda-forge libcurl 7.83.0 h789b8ee_0 conda-forge libdeflate 1.10 h8ffe710_0 conda-forge libffi 3.4.2 h8ffe710_5 conda-forge liblapack 3.9.0 14_win64_mkl conda-forge libpng 1.6.37 h1d00b33_2 conda-forge libsodium 1.0.18 h8d14728_1 conda-forge libssh2 1.10.0 h680486a_2 conda-forge libtiff 4.3.0 hc4061b1_3 conda-forge libwebp 1.2.2 h57928b3_0 conda-forge libwebp-base 1.2.2 h8ffe710_1 conda-forge libxcb 1.13 hcd874cb_1004 conda-forge libzlib 1.2.11 h8ffe710_1014 conda-forge libzopfli 1.0.3 h0e60522_0 conda-forge locket 1.0.0 pyhd8ed1ab_0 conda-forge lz4 4.0.0 py39h0878066_1 conda-forge lz4-c 1.9.3 h8ffe710_1 conda-forge m2w64-gcc-libgfortran 5.3.0 6 conda-forge m2w64-gcc-libs 5.3.0 7 conda-forge m2w64-gcc-libs-core 5.3.0 7 conda-forge m2w64-gmp 6.1.0 2 conda-forge m2w64-libwinpthread-git 5.0.0.4634.697f757 2 conda-forge magicgui 0.4.0 pyhd8ed1ab_0 conda-forge markupsafe 2.1.1 py39hb82d6ee_1 conda-forge matplotlib-base 3.5.2 py39h581301d_0 conda-forge matplotlib-inline 0.1.3 pyhd8ed1ab_0 conda-forge mkl 2022.0.0 h0e2418a_796 conda-forge msgpack-python 1.0.3 py39h2e07f2f_1 conda-forge msys2-conda-epoch 20160418 1 conda-forge munkres 1.1.4 pyh9f0ad1d_0 conda-forge napari 0.4.14 pyhd8ed1ab_0 conda-forge napari-console 0.0.4 pyhd8ed1ab_1 conda-forge napari-plugin-engine 0.2.0 pyhd8ed1ab_2 conda-forge napari-svg 0.1.5 pyhd8ed1ab_0 conda-forge nest-asyncio 1.5.5 pyhd8ed1ab_0 conda-forge networkx 2.8 pyhd8ed1ab_0 conda-forge npe2 0.3.0 pyhd8ed1ab_0 conda-forge numcodecs 0.9.1 py39h415ef7b_2 conda-forge numpy 1.22.3 py39h0948cea_2 conda-forge numpydoc 1.3.1 pyhd8ed1ab_0 conda-forge openjpeg 2.4.0 hb211442_1 conda-forge openssl 1.1.1o h8ffe710_0 conda-forge packaging 21.3 pyhd8ed1ab_0 conda-forge pandas 1.4.2 py39h2e25243_1 conda-forge parso 0.8.3 pyhd8ed1ab_0 conda-forge partd 1.2.0 pyhd8ed1ab_0 conda-forge pickleshare 0.7.5 py_1003 conda-forge pillow 9.1.0 py39ha53f419_2 conda-forge pint 0.19.2 pyhd8ed1ab_0 conda-forge pip 22.0.4 pyhd8ed1ab_0 conda-forge pooch 1.6.0 pyhd8ed1ab_0 conda-forge prompt-toolkit 3.0.29 pyha770c72_0 conda-forge psutil 5.9.0 py39hb82d6ee_1 conda-forge psygnal 0.3.4 py39h2e07f2f_0 conda-forge pthread-stubs 0.4 hcd874cb_1001 conda-forge pure_eval 0.2.2 pyhd8ed1ab_0 conda-forge pycparser 2.21 pyhd8ed1ab_0 conda-forge pydantic 1.9.0 py39hb82d6ee_1 conda-forge pygments 2.12.0 pyhd8ed1ab_0 conda-forge pyopengl 3.1.6 pyh6c4a22f_0 conda-forge pyopenssl 22.0.0 pyhd8ed1ab_0 conda-forge pyparsing 3.0.9 pyhd8ed1ab_0 conda-forge pyqt 5.12.3 py39hcbf5309_8 conda-forge pyqt-impl 5.12.3 py39h415ef7b_8 conda-forge pyqt5-sip 4.19.18 py39h415ef7b_8 conda-forge pyqtchart 5.12 py39h415ef7b_8 conda-forge pyqtwebengine 5.12.1 py39h415ef7b_8 conda-forge pyrsistent 0.18.1 py39hb82d6ee_1 conda-forge pysocks 1.7.1 py39hcbf5309_5 conda-forge python 3.9.12 h9a09f29_1_cpython conda-forge python-dateutil 2.8.2 pyhd8ed1ab_0 conda-forge python_abi 3.9 2_cp39 conda-forge pytomlpp 1.0.11 py39h1f6ef14_0 conda-forge pytz 2022.1 pyhd8ed1ab_0 conda-forge pywavelets 1.3.0 py39h5d4886f_1 conda-forge pywin32 303 py39hb82d6ee_0 conda-forge pyyaml 6.0 py39hb82d6ee_4 conda-forge pyzmq 22.3.0 py39he46f08e_2 conda-forge qt 5.12.9 h556501e_6 conda-forge qtconsole-base 5.3.0 pyhd8ed1ab_0 conda-forge qtpy 2.1.0 pyhd8ed1ab_0 conda-forge requests 2.27.1 pyhd8ed1ab_0 conda-forge scikit-image 0.19.2 py39h2e25243_0 conda-forge scipy 1.8.0 py39hc0c34ad_1 conda-forge setuptools 62.2.0 py39hcbf5309_0 conda-forge shellingham 1.4.0 pyh44b312d_0 conda-forge six 1.16.0 pyh6c4a22f_0 conda-forge snappy 1.1.9 h82413e6_0 conda-forge snowballstemmer 2.2.0 pyhd8ed1ab_0 conda-forge sortedcontainers 2.4.0 pyhd8ed1ab_0 conda-forge sphinx 4.5.0 pyh6c4a22f_0 conda-forge sphinxcontrib-applehelp 1.0.2 py_0 conda-forge sphinxcontrib-devhelp 1.0.2 py_0 conda-forge sphinxcontrib-htmlhelp 2.0.0 pyhd8ed1ab_0 conda-forge sphinxcontrib-jsmath 1.0.1 py_0 conda-forge sphinxcontrib-qthelp 1.0.3 py_0 conda-forge sphinxcontrib-serializinghtml 1.1.5 pyhd8ed1ab_2 conda-forge sqlite 3.38.5 h8ffe710_0 conda-forge stack_data 0.2.0 pyhd8ed1ab_0 conda-forge superqt 0.3.2 pyhd8ed1ab_0 conda-forge tbb 2021.5.0 h2d74725_1 conda-forge tblib 1.7.0 pyhd8ed1ab_0 conda-forge tensorstore 0.1.20 pypi_0 pypi tifffile 2022.5.4 pyhd8ed1ab_0 conda-forge tk 8.6.12 h8ffe710_0 conda-forge toolz 0.11.2 pyhd8ed1ab_0 conda-forge tornado 6.1 py39hb82d6ee_3 conda-forge tqdm 4.64.0 pyhd8ed1ab_0 conda-forge traitlets 5.2.0 pyhd8ed1ab_0 conda-forge typer 0.4.1 pyhd8ed1ab_0 conda-forge typing-extensions 4.2.0 hd8ed1ab_1 conda-forge typing_extensions 4.2.0 pyha770c72_1 conda-forge tzdata 2022a h191b570_0 conda-forge ucrt 10.0.20348.0 h57928b3_0 conda-forge unicodedata2 14.0.0 py39hb82d6ee_1 conda-forge urllib3 1.26.9 pyhd8ed1ab_0 conda-forge vc 14.2 hb210afc_6 conda-forge vispy 0.10.0 py39h5d4886f_0 conda-forge vs2015_runtime 14.29.30037 h902a5da_6 conda-forge wcwidth 0.2.5 pyh9f0ad1d_2 conda-forge wheel 0.37.1 pyhd8ed1ab_0 conda-forge win_inet_pton 1.1.0 py39hcbf5309_4 conda-forge wrapt 1.14.1 py39hb82d6ee_0 conda-forge xorg-libxau 1.0.9 hcd874cb_0 conda-forge xorg-libxdmcp 1.1.3 hcd874cb_0 conda-forge xz 5.2.5 h62dcd97_1 conda-forge yaml 0.2.5 h8ffe710_2 conda-forge zarpaint 0.1.1.dev17+gc582d5b dev_0 zarr 2.11.3 pyhd8ed1ab_0 conda-forge zeromq 4.3.4 h0e60522_1 conda-forge zfp 0.5.5 h0e60522_8 conda-forge zict 2.2.0 pyhd8ed1ab_0 conda-forge zipp 3.8.0 pyhd8ed1ab_0 conda-forge zlib 1.2.11 h8ffe710_1014 conda-forge zstd 1.5.2 h6255e5f_0 conda-forge ```
jni commented 2 years ago

Yeah, looks like the event "payload" has changed since that code was written. So we should figure out what the event value actually looks like and try to get the same info out of it.

jni commented 2 years ago

(thanks for the detailed error message @GenevieveBuckley!)

GenevieveBuckley commented 2 years ago
    source_image = source_image_event.value
AttributeError: 'Image' object has no attribute 'value'

I poked around with the debugger, and found that source_image_event is a napari Image layer object. It looks like instead of receiving an event where the event value is the object we want to grab, instead we are getting the event value returned directly. That sounds familiar, I think there was some change relatively recently that did this.

Details: ``` In [6]: %debug > /Users/genevieb/mambaforge/envs/zarpaint/lib/python3.9/site-packages/zarpaint/_zarpaint.py(20)_set_default_labels_path() 18 @tz.curry 19 def _set_default_labels_path(widget, source_image_event): ---> 20 source_image = source_image_event.value 21 if (hasattr(source_image, 'source') # napari <0.4.8 22 and source_image.source.path is not None): ipdb> source_image_event ipdb> source_image_event.value *** AttributeError: 'Image' object has no attribute 'value' ipdb> dir(source_image_event) ['_SliceDataClass', '__abstractmethods__', '__annotations__', '__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__slots__', '__str__', '__subclasshook__', '__weakref__', '_abc_impl', '_array_like', '_attenuation', '_auto_contrast_source', '_basename', '_blending', '_calc_data_range', '_colormap', '_colormap_name', '_colormaps', '_contrast_limits', '_contrast_limits_msg', '_contrast_limits_range', '_corner_pixels_displayed', '_cursor', '_cursor_modes', '_cursor_size', '_data', '_data_level', '_data_raw', '_data_to_world', '_data_view', '_depiction', '_dims_displayed', '_dims_displayed_order', '_dims_not_displayed', '_dims_order', '_dims_point', '_display_bounding_box', '_displayed_axes', '_drag_modes', '_editable', '_empty', '_experimental_clipping_planes', '_extent_data', '_extent_world', '_freeze', '_gamma', '_get_base_state', '_get_empty_image', '_get_ndim', '_get_offset_data_position', '_get_order', '_get_ray_intersections', '_get_state', '_get_tooltip_text', '_get_value', '_get_value_3d', '_help', '_interactive', '_interpolation', '_is_moving', '_iso_threshold', '_keep_auto_contrast', '_load_slice', '_metadata', '_mode', '_mode_setter_helper', '_mouse_drag_gen', '_mouse_wheel_gen', '_move_modes', '_name', '_ndim', '_ndisplay', '_new_empty_slice', '_on_data_loaded', '_on_selection', '_opacity', '_persisted_mouse_event', '_plane', '_position', '_raw_to_displayed', '_rendering', '_reset_plane_parameters', '_set_colormap', '_set_editable', '_set_highlight', '_set_view_slice', '_should_calc_clims', '_slice', '_slice_dims', '_slice_indices', '_source', '_status', '_thumbnail', '_thumbnail_level', '_thumbnail_shape', '_transforms', '_translate_grid', '_type_string', '_update_dims', '_update_draw', '_update_plane_callbacks', '_update_properties', '_update_thumbnail', '_value', '_visible', '_world_to_data_dims_displayed', '_world_to_data_ray', '_world_to_displayed_data', '_world_to_displayed_data_ray', 'affine', 'as_layer_data_tuple', 'attenuation', 'bind_key', 'blending', 'block_update_properties', 'class_keymap', 'click_plane_from_click_data', 'colormap', 'colormaps', 'contrast_limits', 'contrast_limits_range', 'corner_pixels', 'create', 'cursor', 'cursor_size', 'dask_optimized_slicing', 'data', 'data_level', 'data_raw', 'data_to_world', 'depiction', 'downsample_factors', 'dtype', 'editable', 'events', 'experimental_clipping_planes', 'extent', 'gamma', 'get_ray_intersections', 'get_status', 'get_value', 'help', 'interactive', 'interpolation', 'iso_threshold', 'keymap', 'level_shapes', 'loaded', 'metadata', 'mode', 'mouse_double_click_callbacks', 'mouse_drag_callbacks', 'mouse_move_callbacks', 'mouse_wheel_callbacks', 'multiscale', 'name', 'ndim', 'opacity', 'plane', 'position', 'projected_distance_from_mouse_drag', 'refresh', 'rendering', 'reset_contrast_limits', 'reset_contrast_limits_range', 'rgb', 'rotate', 'save', 'scale', 'scale_factor', 'set_view_slice', 'shear', 'source', 'thumbnail', 'translate', 'translate_grid', 'visible', 'world_to_data'] ```