9

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.

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.

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.

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?

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?

2 Answers 2

4

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

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:

  1. running directly on a bokeh-server
  2. embedded (or integrated if you prefer) into a separate application (a Flask application in that case)

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

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

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.

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).

Hope this helps ;-)

1
  • Thanks a lot Fabio. This is very helpful and clear now. My mistake on the directory of the stock_app.py (I just updated that on the OP). Commented Dec 18, 2014 at 14:24
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):

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

    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.

Cheers.

Damian

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.