-
Notifications
You must be signed in to change notification settings - Fork 48
Support ipywidget based interactive elements #2
Comments
A shim for using jupyter-js-services is now in the ipywidgets master branch and will appear in the 5.0 release which should coincide with the notebook 4.1 release. @lbustelo has been figuring out how to get declarative widgets working standalone in the associated issue above. That work is pretty much what has to get implemented here. |
@jdfreder We're trying to get jupyter-js-widgets working in our dashboard app, but running into problems with the WidgetManager. We adapted the web3 example. Our understanding is that there should be just one WidgetManager instance for the page, managing all of the widgets. We have a layout similar to the notebook, with individual "cells". Now we need to have WidgetManager properly update the view in the correct cell. However, by the time we get to WidgetManager.display_view(), the incoming message has had most of its information stripped out (see https://github.com/jupyter/jupyter-js-services/blob/2df63c8316a061ea441d81641e5fe6a51d2f16cc/src/kernel.ts#L896). In the notebook, we would have tried to find the relevant cell by the message's parent_header, but we don't have access to that. Can you advise? Is this an issue with jupyter-js-services or do we now have to do something different outside of the notebook? How can jupyter-js-widgets work with multiple widgets living in different DOM nodes? |
I think that's something that should be brought to @blink1073 's attention. @blink1073 the widgets, in the context that @jhpedemonte is describing, and in the context of the live notebook, use the full message to look-up the cell via the message header original message id. IIRC one piece of this is already available to us, via KernelFuture, and that is the sent message ID. However the piece that is missing is the original message ID (a way to look-up if the message is in response to another message and if so, what that message's ID was). Maybe you've already thought of this, and there's another way to do it with the new API. @jhpedemonte if you're notebook-like app is written completely using jupyter-js-services, you may be able to set something up with the KernelFuture .reply callback, in the area of the code that sends the execution request for a cell. You could maintain a map of replies -> cells. |
@jdfreder, my understanding that whenever the kernel sends a message to the client, it uses the most recent received msgid as the outgoing parent id. We are using the parent msgid as the msgid in the KernelFuture. We could put the current msgid and the parent msgid as two separate fields if that would help. |
/cc @lbustelo |
@jdfreder, I would say the mapping of msgId -> cell should reside in the notebook itself, not in the Kernel. |
Yes, I think we need that additional info. We may be able to do something hacky with KernelFuture, but I think it would be cleaner to have the relevant info passed in to us (from _Kernel.handleCommMsg()).
Agreed. In our case, we would handle that mapping in our app, making use of the message IDs from the Kernel messages. |
Definitely, that's how it's done now.
I think that would be great! Basically it needs to be accessible by this callback https://github.com/jupyter/jupyter-js-services/blob/2df63c8316a061ea441d81641e5fe6a51d2f16cc/src/kernel.ts#L896 , in some form or another. |
Ah, it may be that we just need a better docstring for this attribute: it is the msgId of the message from the client. Each message passed to the |
@blink1073 I'm still confused. How can we sync the message coming in to WidgetManager.display_view (which contains only data and no message IDs -- as passed from kernel.ts) with the |
Ah, I see, so, if we passed the full message to the |
Yes, I think that would work for us (it's how it is done in the older Notebook code). |
Discussion in jupyter/services#64. |
Full-message passing merged here jupyter/services#66 |
Ref #2 (c) Copyright IBM Corp. 2016
Trying to get latest
Trying to load some code and don't see any more errors on the client side. But I also don't see a widget.
Looks like the server-side code for ipywidgets is expecting some version info in a comm message. And that should be sent from the client by ManagerBase.validateVersion. But that never gets called. Only call I see is in the (Notebook-dependent) manager.js. So looks like we need to update our @jdfreder @blink1073: Does this make sense? Are there any other calls I'll need to get |
@jhpedemonte, I'm not going to be much help on this one, I haven't followed too closely what @jdfreder has been doing on this front. |
No problem. Enhancing our |
Yup
The widget should handle it's own state updates, as it does in web3. IOW you shouldn't need to do anything to get this to work if the comm shim is working properly. |
Currently pulling from fork, since widgets haven't been updated to latest jupyter-js-services. Creating a single WidgetManager, instead of one per cell. Validating widgets version with backend. Refs #2 (c) Copyright IBM Corp. 2016
Pushed code to use latest With this code we can display a widget, but not get updates.
@jdfreder: We followed We see the WS messages coming in, for |
We've been testing with the |
Related to jupyter-widgets/ipywidgets#328 |
ipywidgets are running. web3 demo is initial "proof". Of course, we'll find more problems with ipywidget, declarative widgets, etc. over time as we build out bigger demos. Those are separate tasks. Styling problem with output area is tracked in #10. (ipywidgets display outside of the gridstack layout). |
The impl in #1 will not be able to support ipywidgets or declarative widgets yet:
From jupyter/dashboards#105 (comment)
Once the ipywidgets support for jupyter-js-services lands, the app here can start to take advantage of it.
The text was updated successfully, but these errors were encountered: