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

getting exception with default demo #30

Open
satra opened this issue Feb 2, 2023 · 7 comments
Open

getting exception with default demo #30

satra opened this issue Feb 2, 2023 · 7 comments

Comments

@satra
Copy link

satra commented Feb 2, 2023

running on hub.dandiarchive.org (our download the docker container: dandi/dandihub:latest and start it up):

  • install with pip install ccfwidget in a terminal
  • open a notebook with the default kernel
  • run the code from the README

label_image_weights shape expected to have 1 components, but got () components

@oruebel
Copy link

oruebel commented Feb 2, 2023

@bendichter can you respond to this issue?

@bendichter
Copy link
Contributor

bendichter commented Feb 2, 2023

I'm trying but when I pip install on my M1 pip installs 0.1.0. I haven't pinned down why. This is on a fresh conda env

$ pip install ccfwidget
Collecting ccfwidget
  Using cached ccfwidget-0.5.3-py3-none-any.whl (9.7 kB)
Collecting requests
  Downloading requests-2.28.2-py3-none-any.whl (62 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 62.8/62.8 kB 459.6 kB/s eta 0:00:00
Collecting toolz
  Using cached toolz-0.12.0-py3-none-any.whl (55 kB)
Collecting dask
  Using cached dask-2023.1.1-py3-none-any.whl (1.1 MB)
Collecting zarr
  Downloading zarr-2.13.6-py3-none-any.whl (193 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 193.0/193.0 kB 542.2 kB/s eta 0:00:00
Collecting ipytree
  Using cached ipytree-0.2.2-py2.py3-none-any.whl (1.3 MB)
Collecting fsspec
  Using cached fsspec-2023.1.0-py3-none-any.whl (143 kB)
Collecting itkwidgets>=0.30.1
  Using cached itkwidgets-0.32.5-py2.py3-none-any.whl (3.4 MB)
Collecting xarray
  Using cached xarray-2023.1.0-py3-none-any.whl (973 kB)
Collecting zstandard
  Downloading zstandard-0.19.0-cp310-cp310-macosx_11_0_arm64.whl (348 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 348.9/348.9 kB 539.8 kB/s eta 0:00:00
Collecting colorcet
  Using cached colorcet-3.0.1-py2.py3-none-any.whl (1.7 MB)
Collecting ipydatawidgets>=4.0.1
  Using cached ipydatawidgets-4.3.2-py2.py3-none-any.whl (271 kB)
Collecting traitlets<5.7.0
  Downloading traitlets-5.6.0-py3-none-any.whl (107 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 107.5/107.5 kB 624.4 kB/s eta 0:00:00
Collecting matplotlib
  Using cached matplotlib-3.6.3-cp310-cp310-macosx_11_0_arm64.whl (7.2 MB)
Collecting six
  Using cached six-1.16.0-py2.py3-none-any.whl (11 kB)
Collecting notebook<6.5.0
  Using cached notebook-6.4.12-py3-none-any.whl (9.9 MB)
Collecting itk-core>=5.3.0
  Downloading itk_core-5.3.0-cp310-cp310-macosx_11_0_arm64.whl (57.6 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 57.6/57.6 MB 229.2 kB/s eta 0:00:00
Collecting ipywidgets>=7.5.1
  Downloading ipywidgets-8.0.4-py3-none-any.whl (137 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 137.8/137.8 kB 682.2 kB/s eta 0:00:00
Collecting itkwidgets>=0.30.1
  Using cached itkwidgets-0.32.4-py2.py3-none-any.whl (3.4 MB)
  Using cached itkwidgets-0.32.3-py2.py3-none-any.whl (3.4 MB)
  Using cached itkwidgets-0.32.2-py2.py3-none-any.whl (3.4 MB)
  Using cached itkwidgets-0.32.1-py2.py3-none-any.whl (3.4 MB)
Collecting itk-filtering>=5.2.0.post2
  Downloading itk_filtering-5.3.0-cp310-cp310-macosx_11_0_arm64.whl (47.3 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 47.3/47.3 MB 341.0 kB/s eta 0:00:00
Collecting itkwidgets>=0.30.1
  Using cached itkwidgets-0.32.0-py2.py3-none-any.whl (3.4 MB)
  Using cached itkwidgets-0.31.4-py2.py3-none-any.whl (3.4 MB)
  Using cached itkwidgets-0.31.3-py2.py3-none-any.whl (3.3 MB)
  Using cached itkwidgets-0.31.2-py2.py3-none-any.whl (3.4 MB)
  Using cached itkwidgets-0.30.1-py2.py3-none-any.whl (3.4 MB)
INFO: pip is looking at multiple versions of <Python from Requires-Python> to determine which version is compatible with other requirements. This could take a while.
INFO: pip is looking at multiple versions of ccfwidget to determine which version is compatible with other requirements. This could take a while.
Collecting ccfwidget
  Using cached ccfwidget-0.5.2-py3-none-any.whl (9.7 kB)
  Using cached ccfwidget-0.5.1-py3-none-any.whl (9.7 kB)
  Using cached ccfwidget-0.5.0-py3-none-any.whl (9.7 kB)
  Using cached ccfwidget-0.4.0-py3-none-any.whl (6.5 kB)
Collecting itkwidgets>=0.29.0
  Using cached itkwidgets-0.30.0-py2.py3-none-any.whl (3.4 MB)
  Using cached itkwidgets-0.29.0-py2.py3-none-any.whl (3.3 MB)
Collecting ccfwidget
  Using cached ccfwidget-0.3.0-py3-none-any.whl (4.8 kB)
  Using cached ccfwidget-0.2.0-py3-none-any.whl (4.3 kB)
  Using cached ccfwidget-0.1.0-py2.py3-none-any.whl (2.0 kB)
Installing collected packages: ccfwidget
Successfully installed ccfwidget-0.1.0

@rly
Copy link

rly commented Feb 2, 2023

@bendichter the issue seems to stem from the latest version of itkwidgets 0.32.5 requiring itk-meshtopolydata which has no wheels for Mac M1

@rly
Copy link

rly commented Feb 2, 2023

I can reproduce the error and made a minimum working example:

import numpy as np
from traitlets import validate, HasTraits

from ipydatawidgets import NDArray, array_serialization, shape_constraints

class A(HasTraits):
    label_image_weights = NDArray(dtype=np.float32, default_value=None, allow_none=True,
        help="Weights, from 0.0 to 1.0, for every label in the label map.")\
        .valid(shape_constraints(None,))
    
    def __init__(self):
        super().__init__(label_image_weights=None)
        
    @validate('label_image_weights')
    def _validate_label_image_weights(self, proposal):
        """Check the number of weights equals the number of labels."""
        value = proposal['value']
        # if value is None:
        #     return value
        value = np.array(value, dtype=np.float32)
        return value

A()

The problem is that traitlets tries to validate label_image_weights which has shape constraints to be 1D (I think), and the value being set for label_image_weights is np.array(None) which is scalar (has shape ()).

Uncommenting the commented lines of code above, which I added, would fix the error. You could apply that fix to itkwidgets here https://github.com/InsightSoftwareConsortium/itkwidgets/blob/v0.32.5/itkwidgets/widget_viewer.py#L557

But I am not sure why this is coming up all of a sudden. Their code was last changed two years ago. Is it possible that some upstream behavior changed in ipydatawidgets or traitlets or numpy a while ago and we are seeing it only now?

@satra
Copy link
Author

satra commented Feb 2, 2023

@thewtex - do you have any insight?

@rcpeene
Copy link

rcpeene commented Feb 7, 2023

Any updates here? At the moment this prevents me fully utilizing ccf-widgets with dandihub.

@thewtex
Copy link
Collaborator

thewtex commented Feb 14, 2023

@bendichter the issue seems to stem from the latest version of itkwidgets 0.32.5 requiring itk-meshtopolydata which has no wheels for Mac M1

Python packages have been uploaded for mac arm64 for 3.9, 3.10, 3.11. Please give them a try.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants