RequireJS bug in JupyterLab

Dear Binder community,
When I run my Jupyter notebook in the JupyterLab environment https://mybinder.org/v2/gh/BioDynaMo/binder-demo/master?urlpath=lab/tree/cell_division.ipynb this bug happens and the visualisation of cells doesn’t show up:

Activating jupyter-offlinenotebook JupyterLab extension
offlinenotebook.js:14 offline-notebook repoid: https://github.com/BioDynaMo/binder-demo
offlinenotebook.js:20 offline-notebook repoLabel: GitHub
offlinenotebook.js:22 offline-notebook binderRefUrl: https://github.com/BioDynaMo/binder-demo/tree/86d29d5bbc9910389695f204d2ea419618db97be
offlinenotebook.js:24 offline-notebook binderPersistentUrl: https://gesis.mybinder.org/binder/v2/gh/BioDynaMo/binder-demo/86d29d5bbc9910389695f204d2ea419618db97be
2VM129:2 Uncaught ReferenceError: requirejs is not defined
    at <anonymous>:2:2
    at t.attachWidget (index.es6.js:2758)
    at t.insertWidget (index.es6.js:2661)
    at y._insertOutput (widget.js:396)
    at y.onModelChanged (widget.js:216)
    at m (index.es6.js:459)
    at Object.c [as emit] (index.es6.js:416)
    at e.emit (index.es6.js:99)
    at c._onListChanged (model.js:231)
    at m (index.es6.js:459)
VM131:2 Uncaught ReferenceError: requirejs is not defined
    at <anonymous>:2:2
    at t.attachWidget (index.es6.js:2758)
    at t.insertWidget (index.es6.js:2661)
    at j._insertCell (widget.js:371)
    at widget.js:312
    at c (index.es6.js:1561)
    at j._onCellsChanged (widget.js:311)
    at m (index.es6.js:459)
    at Object.c [as emit] (index.es6.js:416)
    at e.emit (index.es6.js:99)
3default.js:997 Exception opening new comm
_handleCommOpen @ default.js:997
VM132:2 Uncaught ReferenceError: requirejs is not defined
    at <anonymous>:2:2
    at t.attachWidget (index.es6.js:2758)
    at t.insertWidget (index.es6.js:2661)
    at t.addWidget (index.es6.js:2630)
    at n.t.addWidget (index.es6.js:3426)
    at index.js:1964

But when I run it in a regular Jupyter notebook https://mybinder.org/v2/gh/BioDynaMo/binder-demo/master?filepath=cell_division.ipynb it works properly so I’m not sure why is it different.

I would be very thankful if someone could help me out with this

1 Like

Welcome to the forum!

It looks like the error occurs when you run the last cell,

VisualizeInNotebook();

Do you know how VisualizeInNotebook() works? It might be an extension that needs to be updated for the latest JupyterLab, or perhaps JupyterLab isn’t supported. Did it used to work, or is this the first time you’ve tried it with JupyterLab?

2 Likes

A lot of graphics and plotting things don’t work in both the classic interface and JupyterLab. Usually the classic interface is more reliable for those types of visual output. Most strikingly are the animated plots, see here.

It is sort of something you have to learn to live with for now with as JupyterLab is relatively new and rapidly evolving. I often have to remind myself to try it in the classic notebook interface if I am in JupyterLab encounter a visual output not working. The good thing is you are working on MyBinder and can easily switch between interfaces at any time, see here, or alternatively when you are already in JupyterLab, select Help > Launch Classic Notebook from the main JupyterLab menu.

1 Like

It only works in a classic interface, I’ve also tried running it via repo2docker in JupyterLab to try to debug it as well as locally but I think that, because the bugs are the same, the issue may also be related to this ROOT C++ kernel, so I’ll ask them on their forum and see. Thank you for your fast response!

1 Like

Hi @manics,

I am working with @banberina on this issue, and I implemented the VisualizeInNotebook() function. It basically calls an external library (ROOTJS) to create a Javascipt-based interactive visual output. Apparently this library should’ve worked with Jupyterlab as mentioned in this report: https://cds.cern.ch/record/2687923

I have also raised this issue today on their forum.

@fomightez, yeah we are aware of the classic notebook, and it works perfectly fine there. We are just trying to make a switch to Jupyterlab for it’s more awesome interface :slight_smile: The visualization seems to be the only bug at the moment.

2 Likes

According to the report it sounds like it was tested on JupyterLab 1. JupyterLab 2 has been out for a while (though repo2docker was only updated recently to use it). Version 2 contained breaking changes, though from what I’ve seen it’s not too hard to update extensions.

3 Likes

Thanks for pointing that out. I will point the JSROOT devs to this nice guide on how to port JupyterLab 1.x extensions to 2.x: https://jupyterlab.readthedocs.io/en/stable/developer/extension_migration.html

2 Likes