AaronWatters / jp_proxy_widget

Generic Jupyter/IPython widget implementation that will support many types of javascript libraries and interactions.
BSD 2-Clause "Simplified" License
61 stars 12 forks source link

Binderised demo of jp_proxy_widget working in JupyterLab #7

Closed psychemedia closed 4 years ago

psychemedia commented 4 years ago

I've been trying, and failing, to get jp_proxy_widget working in JupyterLab on my home install (base ipywidgets seem to work fine) and can't seem to get the helloworld notebook to render widgets directly from the repo in MyBinder.

Is there a working demo of jp_proxy_widget in JupyterLab via MyBinder anyway? If so, I can try and use that as a basis for fixing my own local install...

AaronWatters commented 4 years ago

This must have something to do with another backwards incompatible enhancement to the widget framework. I will look into it. I think it was working a couple weeks ago.

AaronWatters commented 4 years ago

This is probably the fix.

https://github.com/jupyter-widgets/ipyleaflet/pull/509/files

psychemedia commented 4 years ago

Okay, thanks, will have a a look...

By the by, I have a new jp_proxy_widget experiment going on here: https://github.com/innovationOUtside/nbev3devsim

psychemedia commented 4 years ago

Trying this on a local machine install with a bump to "@jupyter-widgets/base": "^2 || ^3" gives me Plugin 'jp_proxy_widget' failed to activate. in the console, so I guess I have broken dependencies somewhere across my setup.

AaronWatters commented 4 years ago

Sorry for the delayed response. I've been avoiding this in favor of more fun activities. I really hate chasing down dependency problems I didn't create. I'm going to test the hypothesis that the "@jupyter-widgets/base": "^2 || ^3" change in a completely clean environment will fix the problem sometime soon.

psychemedia commented 4 years ago

No probs - my debugging skills definitely need some work... I'll try to see if I can get things working in a roll backed version of JuptyerLab to make sure I haven't done something silly elsewhere. I do get confused tho' as to what works with what in Jupyterverse: a) as things move quickly; b) major version changes sometimes introduce breaking changes; c) I tend to assemble quite eclectic extension combinations that sometimes interfere with each other.

AaronWatters commented 4 years ago

Ok. I changed the dependency version and bumped all the package versions and re-released everything (to pip and npm). I also changed the install instructions in the README. I managed to get this working in a clean environment with both "classic" and "lab".

In the process I found some internal version numbers that didn't match up (some said 1.0.1 and others said 1.0.0). -- this may have been part of the issue.

Sadly I'm not sure the installation instructions are right because I tried a lot of things in testing/debugging and I'm not sure what made things work. I really need to get to the point where I can test this (semi)automatically with known versions of everything, but I'm stopping for now. Please let me know if these changes help for you.

psychemedia commented 4 years ago

Ok - so:

pip3 install --upgrade jp_proxy_widget
jupyter labextension install jp_proxy_widget

seems to work for me, but yesterday I did also various steps to my original setup including:

jupyter lab clean
jupyter lab build
jupyter labextension install @jupyter-widgets/jupyterlab-manager

as well as upgrading ipycanvas (that was causing an error but it maybe was a dependency of something else in my environment...)

One thing I notice is that whilst the default output works, if I try to Create new view of output the new output window displays "Uninitialized Proxy Widget". (My widget has explicitly created HTML block id values that I need to refer to, so part of me wonders if that's going to be problematic trying to tear a window off because the whole JupyterLab environment runs from a single DOM, I think? (I don't really use JupyterLab much.)

For context, what I wanted to explore is extent to which I can use JupyterLab to display a notebook in one panel and a jp_proxy_widget wrapped app referenceable from it in another panel (eg as a torn off output window) but that might not be possible? In which case I guess I need to learn more about JupyterLab :-(

PS Ah, this may help... https://github.com/jupyter-widgets/jupyterlab-sidecar

PPS Boo... installed sidecar, JupyterLab did its rebuild thing, and now I'm getting Error displaying widget: model not found for the jp_proxy_widget again, even without trying to load it into a sidecar window. Bah... :-( If I uninstall jupyterlab-sidecar, and reinstall jp_proxy_widget it works again, so I guess there is a dependency conflict between those two. TBH, I really struggle trying to do anything in JupyterLab; everything I try seems so brittle...)

AaronWatters commented 4 years ago

Thanks.

I don't know about sidecar.

Unfortunately jp_proxy_widgets explicitly doesn't support multiple views. This is because there is no way in general to capture the Javascript state for an arbitrary Javascript component -- and jp_proxy_widgets are designed to load arbitrary components.

FWIW, I've always suspected that the multiple view thing doesn't work (well) in other complex widgets for the same reason (there is internal javascript state that the widget wrapper does not know about).

psychemedia commented 4 years ago

The sidecar things looks like it might work, to me - there is only a single view displayed, so I would have hoped that the JupyterLab UI machinery would be treating things in the sidecar panel just as they would things in a cell output area.

I will ask a general question to the sidecar folks about whether they've seen it working with any jp_proxy_widget wrapped js app...