mljar / mercury

Convert Jupyter Notebooks to Web Apps
https://RunMercury.com
GNU Affero General Public License v3.0
4.06k stars 255 forks source link

Error while displaying a widget: `AttributeError: 'CaptureShell' object has no attribute 'kernel'` #413

Open rraadd88 opened 10 months ago

rraadd88 commented 10 months ago

Hi, When I tried to show a widget,

(1) it is displayed initially when the app is loading,

image

(2) but then this error is shown:

image

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[1], line 2
      1 import igv_notebook
----> 2 igv_notebook.init()
      3 igv_browser= igv_notebook.Browser(
      4     {
      5         "genome": "hg19",
   (...)
     22     }
     23 )

File ~/path/to/lib/python3.9/site-packages/igv_notebook/browser.py:14, in init(version)
     12 def init(version = None):
     13     global _igv_version
---> 14     register_filecomm()
     15     register_svgcomm()
     17     if version is None:

File ~/path/to/lib/python3.9/site-packages/igv_notebook/file_reader.py:61, in register_filecomm()
     58             binary_file_data = read_file(path)
     59         comm.send({'id': id, 'data': binary_file_data})
---> 61 get_ipython().kernel.comm_manager.register_target('file_request', target_func)

AttributeError: 'CaptureShell' object has no attribute 'kernel'

Please let me know suggestions to solve this issue. Thanks.

Code to reproduce the error:

# installation of the widget-package 
# !pip install igv-notebook #0.5.2

# app
import mercury as mr
app = mr.App(
    title="igv",
    show_code = False,
    show_prompt=False,
)

# widget
import igv_notebook
igv_notebook.init()
igv_browser= igv_notebook.Browser(
    {
        "genome": "hg19",
        "locus": "chr22:24,376,166-24,376,456",
        "tracks": [{
            "name": "BAM",
            "url": "https://s3.amazonaws.com/igv.org.demo/gstt1_sample.bam",
            "indexURL": "https://s3.amazonaws.com/igv.org.demo/gstt1_sample.bam.bai",
            "format": "bam",
            "type": "alignment"
        }],
        "roi": [
            {
                "name": "ROI set 1",
                "url": "https://s3.amazonaws.com/igv.org.test/data/roi/roi_bed_1.bed",
                "indexed": False,
                "color": "rgba(94,255,1,0.25)"
            }
        ]
    }
)
pplonski commented 10 months ago

Hi @rraadd88,

We are working on support for all custom widgets that is working in Jupyter. Work is in progress. It has very high priority for us. I will let you know when ready.

Right now it is not possible to make it works.