itkwidgets icon indicating copy to clipboard operation
itkwidgets copied to clipboard

Notebook Testing Issues

Open bnmajor opened this issue 2 years ago • 1 comments

We will need to add testing for the example notebooks, but there are a few issues that need to be resolved in order to do so:

  • [ ] When running a test (for example: pytest --nbmake examples/NumPyArrayPointSet.ipynb) we get the following error (full error below):
    ========================================= short test summary info =========================================
    FAILED examples/NumPyArrayPointSet.ipynb:: - AttributeError: 'NoneType' object has no attribute 'group'
    
    
  • [ ] Due to the asynchronous nature of loading the viewer, sequential cells that rely on the viewer are called before the viewer has completely loaded, which will cause them to fail.

bnmajor avatar Aug 01 '22 18:08 bnmajor

Full error output:

================================================================================================= FAILURES ==================================================================================================
________________________________________________________________ /home/local/KHQ/brianna.major/itkwidgets/examples/NumPyArrayPointSet.ipynb _________________________________________________________________
---------------------------------------------------------------------------
import numpy as np
from itkwidgets import view
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Input In [2], in <cell line: 2>()
      1 import numpy as np
----> 2 from itkwidgets import view

File ~/itkwidgets/itkwidgets/__init__.py:6, in <module>
      3 __version__ = "1.0a6"
      5 from imjoy_rpc import register_default_codecs
----> 6 register_default_codecs()
      8 from .imjoy import register_itkwasm_imjoy_codecs
      9 register_itkwasm_imjoy_codecs()

File ~/.virtualenvs/test-itkwidgets/lib/python3.8/site-packages/imjoy_rpc/utils.py:347, in register_default_codecs(options)
    344 if options is None or "zarr-array" in options:
    345     import zarr
--> 347     api.registerCodec(
    348         {"name": "zarr-array", "type": zarr.Array, "encoder": encode_zarr_store}
    349     )
    351 if options is None or "zarr-group" in options:
    352     import zarr

File ~/.virtualenvs/test-itkwidgets/lib/python3.8/site-packages/imjoy_rpc/werkzeug/local.py:349, in LocalProxy.__getattr__(self, name)
    347 if name == "__members__":
    348     return dir(self._get_current_object())
--> 349 return getattr(self._get_current_object(), name)

File ~/.virtualenvs/test-itkwidgets/lib/python3.8/site-packages/imjoy_rpc/__init__.py:46, in ApiWrapper.__getattr__(self, attr)
     44 if not self.__initialized:
     45     connection_type = os.environ.get("IMJOY_RPC_CONNECTION") or type_of_script()
---> 46     setup_connection(_rpc_context, connection_type, logger)
     47     self.__initialized = True
     48 return _rpc_context.api[attr]

File ~/.virtualenvs/test-itkwidgets/lib/python3.8/site-packages/imjoy_rpc/utils.py:501, in setup_connection(_rpc_context, connection_type, logger, on_ready_callback, on_error_callback)
    498     logger.info("Using jupyter connection for imjoy-rpc")
    499 from .connection.jupyter_connection import JupyterCommManager
--> 501 manager = JupyterCommManager(_rpc_context)
    502 _rpc_context.api = dotdict(
    503     init=manager.init,
    504     export=manager.set_interface,
    505     registerCodec=manager.register_codec,
    506     register_codec=manager.register_codec,
    507 )
    508 manager.start(
    509     on_ready_callback=on_ready_callback, on_error_callback=on_error_callback
    510 )

File ~/.virtualenvs/test-itkwidgets/lib/python3.8/site-packages/imjoy_rpc/connection/jupyter_connection.py:32, in JupyterCommManager.__init__(self, rpc_context)
     30 self.rpc_context = rpc_context
     31 self._codecs = {}
---> 32 self.kernel_id = re.search(
     33     "kernel-(.*).json", ipykernel.connect.get_connection_file()
     34 ).group(1)
     35 # for loading plugin from source code,
     36 # we can benifit from the syntax highlighting for HTML()
     37 self.register_codec({"name": "HTML", "type": HTML, "encoder": lambda x: x.data})

AttributeError: 'NoneType' object has no attribute 'group'

It seems that the kernel is not being found, although it's not clear to me at this point why that would be.

bnmajor avatar Aug 01 '22 18:08 bnmajor