0
votes

For a project we try to expand the Google Cloud Datalab with IPyWidgets. When we try out IPyWidgets in jupyter notebook (not in google-cloud-datalab) locally, everything run as expected (i.e. we tried to show a Text field, which worked). When we try to execute the same code in Google Cloud Datalab, it fails. In the web console we see following error:

Error 1:

Error message: "Class ipython.widget not found in registry "
Error stack: "load_class/<@http://localhost:8081/static/notebook/js/main.min.js:12751:28load_class@http://localhost:8081/static/notebook/js/main.min.js:12736:1CommManager.prototype.comm_open@http://localhost:8081/static/notebook/js/main.min.js:21802:31.proxy/i@http://localhost:8081/static/notebook/js/main.min.js:89:5486Kernel.prototype._handle_iopub_message@http://localhost:8081/static/notebook/js/main.min.js:23101:20Kernel.prototype._finish_ws_message@http://localhost:8081/static/notebook/js/main.min.js:22936:1Kernel.prototype._handle_ws_message/this._msg_queue<@http://localhost:8081/static/notebook/js/main.min.js:22926:39"

Error 2:

Message: Could not open comm
Error message: "Couldn't process kernel message"
Error stack: "WrappedError@http://localhost:8081/static/notebook/js/main.min.js:12706:19reject/<@http://localhost:8081/static/notebook/js/main.min.js:12785:33"

The strange thing is, is when google-cloud-datalab is running and we go to the jupyter notebook (on port 9000), and we execute the code over there it works.

Do we need to make changes to nb.html, and/or static.ts to make this work?

Question: Is there a way to execute IPyWidgets on Google Cloud Datalab?

Greetings, Brecht

Edit: I can now load the js and the css files from IPyWidgets in google-cloud-datalab (you need to change static.ts, for those who wonder). The only remaining issue (hopefully), is that we get following error:

"Error: Could not determine where the display message was from. Widget will not be displayed".

This is because

var cell = this.get_msg_cell(msg.parent_header.msg_id);

is null (line 556, of ipywidgets/widgets/js/manager.js). I assume that changing static.ts is not enough?

1
I believe it is not possible to execute IPyWidgets on Google Cloud Datalab. Please see the following link which mentions: "Jupyter widgets rely on a communication channel that doesn't exist in Datalab. " : github.com/GoogleCloudPlatform/datalab/pull/726 It would be great if you can share some of your changes in a branch on github. I am also interested in getting IPyWidgets to work.Anthonios Partheniou
I suggest opening a feature request at github.com/GoogleCloudPlatform/datalab/issues.Graham Wheeler
@AnthoniosPartheniou Since it is a project for uni, I cannot yet share the code. But I took the changes that were for the IPyWidgets and put it in a fork of Datalab (github.com/brecht-d-m/datalab/tree/feature/test-ipywidgets). The changes that are necessary are located in static.ts, server.ts, and datalab.ts. You probably also want to change the Dockerfile to install IPyWidgets.brecht-d-m
Note: I used IPyWidgets 4.1.1brecht-d-m
Does this work yet? This issue seems promising, but I still ran into the same issue on my instance of Datalab.selwyth

1 Answers

0
votes

The:

"Error: Could not determine where the display message was from.  Widget will not be displayed".

issue can be fixed by changing this line in datalab.js:

originalExecute.apply(this, [ code, callbacks, options ]);

to:

return originalExecute.apply(this, [ code, callbacks, options ]);