【问题标题】:Execute IPyWidgets in Google Cloud Datalab在 Google Cloud Datalab 中执行 IPyWidgets
【发布时间】:2016-04-04 14:00:36
【问题描述】:

对于一个项目,我们尝试使用 IPyWidgets 扩展 Google Cloud Datalab。当我们在本地的 jupyter notebook(而不是 google-cloud-datalab)中尝试 IPyWidgets 时,一切都按预期运行(即我们试图显示一个 Text 字段,它有效)。当我们尝试在 Google Cloud Datalab 中执行相同的代码时,它会失败。在 Web 控制台中,我们看到以下错误:

错误 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"

错误 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"

奇怪的是,当 google-cloud-datalab 运行时,我们转到 jupyter notebook(在端口 9000 上),我们在那里执行代码,它可以工作。

我们是否需要对 nb.html 和/或 static.ts 进行更改才能使其正常工作?

问题:有没有办法在 Google Cloud Datalab 上执行 IPyWidgets?

你好,布莱希特

编辑:我现在可以从 google-cloud-datalab 中的 IPyWidgets 加载 js 和 css 文件(对于那些想知道的人,您需要更改 static.ts)。唯一剩下的问题(希望如此)是我们收到以下错误:

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

这是因为

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

为空(ipywidgets/widgets/js/manager.js 的第 556 行)。我认为改变 static.ts 是不够的?

【问题讨论】:

  • 我相信在 Google Cloud Datalab 上执行 IPyWidgets 是不可能的。请参阅以下链接,其中提到:“Jupyter 小部件依赖于 Datalab 中不存在的通信渠道。”:github.com/GoogleCloudPlatform/datalab/pull/726 如果您可以在 github 上的分支中分享您的一些更改,那就太好了。我也有兴趣让 IPyWidgets 工作。
  • 我建议在github.com/GoogleCloudPlatform/datalab/issues打开一个功能请求。
  • @AnthoniosPartheniou 因为它是 uni 的项目,所以我还不能分享代码。但是我接受了针对 IPyWidgets 的更改,并将其放入 Datalab 的一个分支中 (github.com/brecht-d-m/datalab/tree/feature/test-ipywidgets)。必要的更改位于 static.ts、server.ts 和 datalab.ts。您可能还想更改 Dockerfile 以安装 IPyWidgets。
  • 注意:我用的是IPyWidgets 4.1.1
  • 这还有效吗? This issue 看起来很有希望,但我在我的 Datalab 实例上仍然遇到了同样的问题。

标签: jupyter-notebook google-cloud-datalab ipywidgets


【解决方案1】:

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

可以通过更改 datalab.js 中的这一行来解决问题:

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

到:

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

【讨论】:

  • 啊,确实解决了问题
猜你喜欢
  • 2018-09-19
  • 2018-08-31
  • 1970-01-01
  • 1970-01-01
  • 2018-09-12
  • 2016-11-12
  • 1970-01-01
  • 2023-03-29
  • 1970-01-01
相关资源
最近更新 更多