我想在 jupyterhub(又名身份验证代理)后面运行的 jupyter notebook 实例上开发散景应用程序。我想让交互式散景应用程序回调笔记本内核。我不想使用笔记本小部件等,因为我希望能够将笔记本导出为 python 文件并拥有可以与散景服务器一起使用的东西。
我笔记本中的以下代码给出了一个没有错误的空输出:
from bokeh.layouts import row
from bokeh.models.widgets import Button
from bokeh.io import show, output_notebook
from bokeh.application.handlers import FunctionHandler
from bokeh.application import Application
output_notebook()
# Create the Document Application
def modify_doc(doc):
layout = row(Button(label="Hello,"),Button(label="world!"))
doc.add_root(layout)
handler = FunctionHandler(modify_doc)
app = Application(handler)
# Output = BokehJS 0.12.10 successfully loaded.
# New cell
show(app, notebook_url="my-jupyterhub-url.com:80")
# Output = "empty" cell
检查已添加脚本标记的单元格:
<script src="http://my-jupyterhub-url.com:46249/autoload.js?bokeh-autoload-element=f8fa3bd0-9caf-473d-87a5-6c7b9680648b&bokeh-absolute-url=http://my-jupyterhub-url.com:46249" id="f8fa3bd0-9caf-473d-87a5-6c7b9680648b" data-bokeh-model-id="" data-bokeh-doc-id=""></script>
这不起作用,因为端口46249
未在 jupyterhub 代理上打开。此外,路由到我的jupyter 实例的路径也不会路由到任何my-jupyterhub-url.com/user/my-username/
地方my-jupyterhub-url.com/autoload.js
。
感觉这可能是一个常见的要求,但搜索还没有找到解决方案。
有任何想法吗?