applet,嵌入和bokeh-server

时间:2022-01-06 01:10:39

There seem to be at at least two or three major ways of building apps that communicate with bokeh-server in Bokeh. They correspond to the folders app, embed and plotting/glyphs under the examples directory in Bokeh.

似乎至少有两到三种主要的方式来构建与Bokeh -server通信的应用程序。它们对应于文件夹应用程序,在Bokeh的example目录下嵌入和绘制/符号。

On the differences between them, I read here the following:

关于它们之间的差异,我在这里读到以下内容:

On the stock_app.py (app folder) example you are using bokeh-server to embed an applet and serve it from the url you specify. That's why you crate a new StockApp class and create a function that creates a new instance of it and decorates it with @bokeh_app.route("/bokeh/stocks/") and @object_page("stocks"). You can follow the app examples (sliders, stock and crossfilter) and use bokeh @object_page and @bokeh_app.route decorators to create your custom url.

stock_app。py(应用程序文件夹)示例,您正在使用bokeh-server嵌入一个applet,并从您指定的url提供它。这就是为什么要创建一个新的StockApp类并创建一个新实例的函数,并使用@bokeh_app.route(“/bokeh/stocks/”)和@object_page(“stocks”)对其进行修饰。您可以遵循应用程序示例(滑块、股票和交叉过滤器),并使用bokeh @object_page和@bokeh_app。创建自定义url的路由decorator。

On the taylor_server.py example (glyphs folder) it is the session object that is taking care of creating everything on bokeh-server for you. From this interface is not possible to customize urls or create alias.

taylor_server。py示例(glyphs文件夹)会话对象负责为您在bokeh-server上创建所有内容。无法从这个接口定制url或创建别名。

But this confused me, what is meant by an "applet" & "embedding" in Bokeh terminology, and what is exactly he difference between applets (presumably app and embed) and plotting/glyphs?

但这让我困惑,在Bokeh术语中“applet”和“embed”是什么意思,以及applet(大概是app和embed)和plot /glyphs之间的确切区别是什么?

Also I thought that the notion of "embedding" only referred to the design pattern that we see in the embed folder as in the example animated.py, where we embed a tag in the body of an HTML file. I don't see that in the stock_app.py, so why is it an embedding example?

我还认为“嵌入”的概念只指我们在embed文件夹中看到的设计模式,如动画示例。py,我们在HTML文件的主体中嵌入一个标记。我在stock_app中没有看到。py,为什么它是一个嵌入的例子呢?

2 个解决方案

#1


4  

But this confused me, what is meant by an "applet" & "embedding" in Bokeh terminology

但这让我困惑,在Bokeh术语中“applet”和“embed”是什么意思

There is clearly a mistake in the answer you have pasted here (that probably doesn't help you on understanding, sorry). The stock app example stock_app.py is in examples\app\stock_applet\stock_app.py not embed folder. Also, the terminology used does not help either. On that example you create an applet that can be served in 2 different ways:

你粘贴在这里的答案显然是错误的(对不起,这可能对你的理解没有帮助)。股票应用程序示例stock_app。py \ app \ stock_applet \ stock_app例子。py不是嵌入文件夹。此外,使用的术语也没有帮助。在这个例子中,你创建了一个小应用程序,可以用两种不同的方式提供服务:

  1. running directly on a bokeh-server
  2. 直接在bokeh-server上运行
  3. embedded (or integrated if you prefer) into a separate application (a Flask application in that case)
  4. 将其嵌入(或集成到单独的应用程序中(在这种情况下是Flask应用程序)

You may find more information at the examples\app\stock_applet\README.md file.

您可以在示例app\stock_applet\README中找到更多信息。md文件。

Also, you can find info about applets and bokeh server examples documentation and userguide

此外,您还可以找到有关applet和bokeh服务器示例文档和用户指南的信息

Regarding what does embedding means, you can find more info at the user_guide/embedding section of bokeh docs. To summarize, you can generate code that you can insert on your own web application code to display bokeh components. Examples in examples\embed are also useful to understand this pattern.

关于嵌入意味着什么,您可以在bokeh文档的user_guide/embed部分找到更多的信息。总之,您可以生成可以在自己的web应用程序代码中插入的代码来显示bokeh组件。示例中的例子embed对于理解这个模式也很有用。

Finally, the usage of bokeh-server you see in taylor_server.py is just using bokeh server to serve you plot (instead of saving it to a static html file).

最后,您在taylor_server中看到的bokeh-server的使用。py只是使用bokeh服务器来为您绘图(而不是保存到静态html文件中)。

Hope this helps ;-)

希望这有助于;-)

#2


3  

Just to add a little bit... I will paste here a quote from Bryan in the mailing list (in another thread, so maybe you missed it):

再补充一点……我将在邮件列表中粘贴来自Bryan的一段话(在另一个线程中,所以您可能漏掉了):

Regarding app vs embed. The "apps" are all run inside the bokeh-server. So you start them, by doing something like:

关于应用程序和嵌入。“应用”都在bokeh-server中运行。你可以这样开始:

    bokeh-server --script sliders_app.py 

The main reason for this is because, otherwise, to make an "app" outside the server, the only real solutions is to have a long-running process that polls the server for updates. This is not ideal, and apps running directly in the server can utilize much better callbacks. Please note that the "app" concept is still fairly new, and things like how to start, easily spell, and deploy apps is very much open to improvement.

这样做的主要原因是,否则,要在服务器之外创建一个“应用程序”,唯一真正的解决方案是拥有一个长时间运行的进程来轮询服务器以获取更新。这并不理想,直接在服务器上运行的应用程序可以使用更好的回调。请注意,“应用”概念仍然是一个相当新的概念,像如何开始、如何轻松拼写和部署应用程序之类的东西非常容易改进。

The "embed" examples simply show off how to embed a Bokeh plot in a standard web-app (i.e., you want to serve a plot from Flask that has a plot in it). This can be done with, or without the bokeh-server, but even if you use a bokeh-server, there is no code running in the bokeh-server that responds to widgets, or updates plots or data. To update plots you'd have to have a separate python process that connects to the bokeh-server and polls or pushes data to it.

“嵌入”示例只是展示了如何在标准的web应用程序中嵌入一个Bokeh情节。,你想要的是一个从烧瓶中有一个情节的情节。这可以用bokeh-server完成,也可以不使用bokeh-server,但是即使您使用bokeh-server,也没有运行在bokeh-server中响应小部件或更新图表或数据的代码。要更新图表,您必须有一个单独的python进程,该进程连接到bokeh-server并轮询或向其推送数据。

Cheers.

欢呼。

Damian

Damian

#1


4  

But this confused me, what is meant by an "applet" & "embedding" in Bokeh terminology

但这让我困惑,在Bokeh术语中“applet”和“embed”是什么意思

There is clearly a mistake in the answer you have pasted here (that probably doesn't help you on understanding, sorry). The stock app example stock_app.py is in examples\app\stock_applet\stock_app.py not embed folder. Also, the terminology used does not help either. On that example you create an applet that can be served in 2 different ways:

你粘贴在这里的答案显然是错误的(对不起,这可能对你的理解没有帮助)。股票应用程序示例stock_app。py \ app \ stock_applet \ stock_app例子。py不是嵌入文件夹。此外,使用的术语也没有帮助。在这个例子中,你创建了一个小应用程序,可以用两种不同的方式提供服务:

  1. running directly on a bokeh-server
  2. 直接在bokeh-server上运行
  3. embedded (or integrated if you prefer) into a separate application (a Flask application in that case)
  4. 将其嵌入(或集成到单独的应用程序中(在这种情况下是Flask应用程序)

You may find more information at the examples\app\stock_applet\README.md file.

您可以在示例app\stock_applet\README中找到更多信息。md文件。

Also, you can find info about applets and bokeh server examples documentation and userguide

此外,您还可以找到有关applet和bokeh服务器示例文档和用户指南的信息

Regarding what does embedding means, you can find more info at the user_guide/embedding section of bokeh docs. To summarize, you can generate code that you can insert on your own web application code to display bokeh components. Examples in examples\embed are also useful to understand this pattern.

关于嵌入意味着什么,您可以在bokeh文档的user_guide/embed部分找到更多的信息。总之,您可以生成可以在自己的web应用程序代码中插入的代码来显示bokeh组件。示例中的例子embed对于理解这个模式也很有用。

Finally, the usage of bokeh-server you see in taylor_server.py is just using bokeh server to serve you plot (instead of saving it to a static html file).

最后,您在taylor_server中看到的bokeh-server的使用。py只是使用bokeh服务器来为您绘图(而不是保存到静态html文件中)。

Hope this helps ;-)

希望这有助于;-)

#2


3  

Just to add a little bit... I will paste here a quote from Bryan in the mailing list (in another thread, so maybe you missed it):

再补充一点……我将在邮件列表中粘贴来自Bryan的一段话(在另一个线程中,所以您可能漏掉了):

Regarding app vs embed. The "apps" are all run inside the bokeh-server. So you start them, by doing something like:

关于应用程序和嵌入。“应用”都在bokeh-server中运行。你可以这样开始:

    bokeh-server --script sliders_app.py 

The main reason for this is because, otherwise, to make an "app" outside the server, the only real solutions is to have a long-running process that polls the server for updates. This is not ideal, and apps running directly in the server can utilize much better callbacks. Please note that the "app" concept is still fairly new, and things like how to start, easily spell, and deploy apps is very much open to improvement.

这样做的主要原因是,否则,要在服务器之外创建一个“应用程序”,唯一真正的解决方案是拥有一个长时间运行的进程来轮询服务器以获取更新。这并不理想,直接在服务器上运行的应用程序可以使用更好的回调。请注意,“应用”概念仍然是一个相当新的概念,像如何开始、如何轻松拼写和部署应用程序之类的东西非常容易改进。

The "embed" examples simply show off how to embed a Bokeh plot in a standard web-app (i.e., you want to serve a plot from Flask that has a plot in it). This can be done with, or without the bokeh-server, but even if you use a bokeh-server, there is no code running in the bokeh-server that responds to widgets, or updates plots or data. To update plots you'd have to have a separate python process that connects to the bokeh-server and polls or pushes data to it.

“嵌入”示例只是展示了如何在标准的web应用程序中嵌入一个Bokeh情节。,你想要的是一个从烧瓶中有一个情节的情节。这可以用bokeh-server完成,也可以不使用bokeh-server,但是即使您使用bokeh-server,也没有运行在bokeh-server中响应小部件或更新图表或数据的代码。要更新图表,您必须有一个单独的python进程,该进程连接到bokeh-server并轮询或向其推送数据。

Cheers.

欢呼。

Damian

Damian