Slider Applet and Flask with new Bokeh Server

Let me start with some background, in case my initial premises are totally wrong:

I have a Flask app which generates a large amount of data for the user. I’d like to serve up an interactive bokeh plot for that data (like a dashboard). The interactions alter the data based on user-generated functions. From what I’ve read, this talking between the plotting and a python function means serving this as an app (such as the stock_app example) is the best way to handle this.

Before jumping down the rabbit hole of the coding question, let me ask: I will need to serve different interactive dashboards for each user, on demand. I’m still learning about bokeh server, so is this type of thing possible without spinning up multiple servers? Or is another approach more appropriate?

If this isn’t a terrible idea to begin with, here is my question :slight_smile:

How do I serve up this applet? I’ve attempted to follow the stock_app example, but serving it up in Flask appears to not work with the new edition of the bokeh server (v. 0.11dev, which is awesome). So I’ve been stumbling on my own to recreate a similar case with the slider_app.

In short, I’ve wrapped the latest version of the slider_app into a class, SliderApp, with a method SliderApp.get_app() which returns the HBox layout of the app.

def get_app(self):
inputs = VBoxForm(children=[self.text, self.offset, self.amplitude, self.phase, self.freq])
hbox = HBox(childrend=[inputs, self.plot])
return hbox

``

This then gets called in the following, short Flask app:

from flask import render_template, Flask

from SliderApp import SliderApp
from pandas import DataFrame

from bokeh.embed import autoload_server
from bokeh.client import push_session
from bokeh.io import curdoc
from bokeh.resources import Resources

app = Flask(name)

@app.route(’/’)
def index():
applet = SliderApp()
layout = applet.get_app()
doc = curdoc().add(layout)
push_session(curdoc())

tag = autoload_server(layout, loglevel='debug')

return render_template('slider_app.html', tag=tag)

if name == ‘main’:
print(“STARTED”)
app.run(debug=True)

``

The html template is very simple:

{{ tag | safe }}

``

I then (attempt) to run by invoking:

bokeh serve

``

followed by

python flask_app.py

``

Navigating to 127.0.0.1:5000/ there is nothing represented, and an error is in the console similar to:

[Error] Bokeh: Failed to repull session Error: Module `VBoxForm’ does not exists. The problem may be two fold. Either a model was requested that’s available in an extra bundle, e.g. a widget, or a custom model was requested, but it wasn’t registered before first usage.

``

The particular module in the error changes when re-running (or re-accessing the route) to Slider, HBox, etc. so I’m not sure how to interpret it (likely not the root issue?). Otherwise, the HTML was in fact rendered with the tag inserted where expected.

Any advice, one way or the other, on this would be much appreciated!

Sorry, just noticed the
from pandas import DataFrame

``

that is still in the code above. That has no baring on the example I’m discussing here!

···

On Thursday, November 12, 2015 at 5:08:27 PM UTC-5, [email protected] wrote:

Let me start with some background, in case my initial premises are totally wrong:

I have a Flask app which generates a large amount of data for the user. I’d like to serve up an interactive bokeh plot for that data (like a dashboard). The interactions alter the data based on user-generated functions. From what I’ve read, this talking between the plotting and a python function means serving this as an app (such as the stock_app example) is the best way to handle this.

Before jumping down the rabbit hole of the coding question, let me ask: I will need to serve different interactive dashboards for each user, on demand. I’m still learning about bokeh server, so is this type of thing possible without spinning up multiple servers? Or is another approach more appropriate?

If this isn’t a terrible idea to begin with, here is my question :slight_smile:

How do I serve up this applet? I’ve attempted to follow the stock_app example, but serving it up in Flask appears to not work with the new edition of the bokeh server (v. 0.11dev, which is awesome). So I’ve been stumbling on my own to recreate a similar case with the slider_app.

In short, I’ve wrapped the latest version of the slider_app into a class, SliderApp, with a method SliderApp.get_app() which returns the HBox layout of the app.

def get_app(self):
inputs = VBoxForm(children=[self.text, self.offset, self.amplitude, self.phase, self.freq])
hbox = HBox(childrend=[inputs, self.plot])
return hbox

``

This then gets called in the following, short Flask app:

from flask import render_template, Flask

from SliderApp import SliderApp
from pandas import DataFrame

from bokeh.embed import autoload_server
from bokeh.client import push_session
from bokeh.io import curdoc
from bokeh.resources import Resources

app = Flask(name)

@app.route(‘/’)
def index():
applet = SliderApp()
layout = applet.get_app()
doc = curdoc().add(layout)
push_session(curdoc())

tag = autoload_server(layout, loglevel='debug')


return render_template('slider_app.html', tag=tag)

if name == ‘main’:
print(“STARTED”)
app.run(debug=True)

``

The html template is very simple:

{{ tag | safe }}

``

I then (attempt) to run by invoking:

bokeh serve

``

followed by

python flask_app.py

``

Navigating to 127.0.0.1:5000/ there is nothing represented, and an error is in the console similar to:

[Error] Bokeh: Failed to repull session Error: Module `VBoxForm’ does not exists. The problem may be two fold. Either a model was requested that’s available in an extra bundle, e.g. a widget, or a custom model was requested, but it wasn’t registered before first usage.

``

The particular module in the error changes when re-running (or re-accessing the route) to Slider, HBox, etc. so I’m not sure how to interpret it (likely not the root issue?). Otherwise, the HTML was in fact rendered with the tag inserted where expected.

Any advice, one way or the other, on this would be much appreciated!

Hi,

Just catching up on the mailing list, so maybe you solved this already. This error probably means your page has the base bokeh.js file but not the bokeh-widgets.js file. I do not know why that is, though. If you can put up your complete runnable code somewhere I could take a look (we’d like to have a public Flask example anyway).

Havoc

···

On Nov 12, 2015, at 5:08 PM, [email protected] wrote:

Let me start with some background, in case my initial premises are totally wrong:

I have a Flask app which generates a large amount of data for the user. I’d like to serve up an interactive bokeh plot for that data (like a dashboard). The interactions alter the data based on user-generated functions. From what I’ve read, this talking between the plotting and a python function means serving this as an app (such as the stock_app example) is the best way to handle this.

Before jumping down the rabbit hole of the coding question, let me ask: I will need to serve different interactive dashboards for each user, on demand. I’m still learning about bokeh server, so is this type of thing possible without spinning up multiple servers? Or is another approach more appropriate?

If this isn’t a terrible idea to begin with, here is my question :slight_smile:

How do I serve up this applet? I’ve attempted to follow the stock_app example, but serving it up in Flask appears to not work with the new edition of the bokeh server (v. 0.11dev, which is awesome). So I’ve been stumbling on my own to recreate a similar case with the slider_app.

In short, I’ve wrapped the latest version of the slider_app into a class, SliderApp, with a method SliderApp.get_app() which returns the HBox layout of the app.

def get_app(self):
inputs = VBoxForm(children=[self.text, self.offset, self.amplitude, self.phase, self.freq])
hbox = HBox(childrend=[inputs, self.plot])
return hbox

``

This then gets called in the following, short Flask app:

from flask import render_template, Flask

from SliderApp import SliderApp
from pandas import DataFrame

from bokeh.embed import autoload_server
from bokeh.client import push_session
from bokeh.io import curdoc
from bokeh.resources import Resources

app = Flask(name)

@app.route(‘/’)
def index():
applet = SliderApp()
layout = applet.get_app()
doc = curdoc().add(layout)
push_session(curdoc())

tag = autoload_server(layout, loglevel='debug')


return render_template('slider_app.html', tag=tag)

if name == ‘main’:
print(“STARTED”)
app.run(debug=True)

``

The html template is very simple:

{{ tag | safe }}

``

I then (attempt) to run by invoking:

bokeh serve

``

followed by

python flask_app.py

``

Navigating to 127.0.0.1:5000/ there is nothing represented, and an error is in the console similar to:

[Error] Bokeh: Failed to repull session Error: Module `VBoxForm’ does not exists. The problem may be two fold. Either a model was requested that’s available in an extra bundle, e.g. a widget, or a custom model was requested, but it wasn’t registered before first usage.

``

The particular module in the error changes when re-running (or re-accessing the route) to Slider, HBox, etc. so I’m not sure how to interpret it (likely not the root issue?). Otherwise, the HTML was in fact rendered with the tag inserted where expected.

Any advice, one way or the other, on this would be much appreciated!

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/25b874bb-523b-473f-abd8-7bdb2f9b421f%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

I’m also trying to combine bokeh slider app with flask. Would be great to have an example of this.

Fredrik

onsdag 18. november 2015 18.19.20 UTC+1 skrev [email protected] følgende:

···

Sorry, just noticed the
from pandas import DataFrame

``

that is still in the code above. That has no baring on the example I’m discussing here!

On Thursday, November 12, 2015 at 5:08:27 PM UTC-5, [email protected] wrote:

Let me start with some background, in case my initial premises are totally wrong:

I have a Flask app which generates a large amount of data for the user. I’d like to serve up an interactive bokeh plot for that data (like a dashboard). The interactions alter the data based on user-generated functions. From what I’ve read, this talking between the plotting and a python function means serving this as an app (such as the stock_app example) is the best way to handle this.

Before jumping down the rabbit hole of the coding question, let me ask: I will need to serve different interactive dashboards for each user, on demand. I’m still learning about bokeh server, so is this type of thing possible without spinning up multiple servers? Or is another approach more appropriate?

If this isn’t a terrible idea to begin with, here is my question :slight_smile:

How do I serve up this applet? I’ve attempted to follow the stock_app example, but serving it up in Flask appears to not work with the new edition of the bokeh server (v. 0.11dev, which is awesome). So I’ve been stumbling on my own to recreate a similar case with the slider_app.

In short, I’ve wrapped the latest version of the slider_app into a class, SliderApp, with a method SliderApp.get_app() which returns the HBox layout of the app.

def get_app(self):
inputs = VBoxForm(children=[self.text, self.offset, self.amplitude, self.phase, self.freq])
hbox = HBox(childrend=[inputs, self.plot])
return hbox

``

This then gets called in the following, short Flask app:

from flask import render_template, Flask

from SliderApp import SliderApp
from pandas import DataFrame

from bokeh.embed import autoload_server
from bokeh.client import push_session
from bokeh.io import curdoc
from bokeh.resources import Resources

app = Flask(name)

@app.route(‘/’)
def index():
applet = SliderApp()
layout = applet.get_app()
doc = curdoc().add(layout)
push_session(curdoc())

tag = autoload_server(layout, loglevel='debug')


return render_template('slider_app.html', tag=tag)

if name == ‘main’:
print(“STARTED”)
app.run(debug=True)

``

The html template is very simple:

{{ tag | safe }}

``

I then (attempt) to run by invoking:

bokeh serve

``

followed by

python flask_app.py

``

Navigating to 127.0.0.1:5000/ there is nothing represented, and an error is in the console similar to:

[Error] Bokeh: Failed to repull session Error: Module `VBoxForm’ does not exists. The problem may be two fold. Either a model was requested that’s available in an extra bundle, e.g. a widget, or a custom model was requested, but it wasn’t registered before first usage.

``

The particular module in the error changes when re-running (or re-accessing the route) to Slider, HBox, etc. so I’m not sure how to interpret it (likely not the root issue?). Otherwise, the HTML was in fact rendered with the tag inserted where expected.

Any advice, one way or the other, on this would be much appreciated!

Hi Havoc,

Thanks for the response. I still have not solved it! Give me a bit and I’ll get the code up!

···

On Thursday, November 19, 2015 at 8:47:16 AM UTC-5, Havoc Pennington wrote:

Hi,

Just catching up on the mailing list, so maybe you solved this already. This error probably means your page has the base bokeh.js file but not the bokeh-widgets.js file. I do not know why that is, though. If you can put up your complete runnable code somewhere I could take a look (we’d like to have a public Flask example anyway).

Havoc

On Nov 12, 2015, at 5:08 PM, [email protected] wrote:

Let me start with some background, in case my initial premises are totally wrong:

I have a Flask app which generates a large amount of data for the user. I’d like to serve up an interactive bokeh plot for that data (like a dashboard). The interactions alter the data based on user-generated functions. From what I’ve read, this talking between the plotting and a python function means serving this as an app (such as the stock_app example) is the best way to handle this.

Before jumping down the rabbit hole of the coding question, let me ask: I will need to serve different interactive dashboards for each user, on demand. I’m still learning about bokeh server, so is this type of thing possible without spinning up multiple servers? Or is another approach more appropriate?

If this isn’t a terrible idea to begin with, here is my question :slight_smile:

How do I serve up this applet? I’ve attempted to follow the stock_app example, but serving it up in Flask appears to not work with the new edition of the bokeh server (v. 0.11dev, which is awesome). So I’ve been stumbling on my own to recreate a similar case with the slider_app.

In short, I’ve wrapped the latest version of the slider_app into a class, SliderApp, with a method SliderApp.get_app() which returns the HBox layout of the app.

def get_app(self):
inputs = VBoxForm(children=[self.text, self.offset, self.amplitude, self.phase, self.freq])
hbox = HBox(childrend=[inputs, self.plot])
return hbox

``

This then gets called in the following, short Flask app:

from flask import render_template, Flask

from SliderApp import SliderApp
from pandas import DataFrame

from bokeh.embed import autoload_server
from bokeh.client import push_session
from bokeh.io import curdoc
from bokeh.resources import Resources

app = Flask(name)

@app.route(‘/’)
def index():
applet = SliderApp()
layout = applet.get_app()
doc = curdoc().add(layout)
push_session(curdoc())

tag = autoload_server(layout, loglevel='debug')


return render_template('slider_app.html', tag=tag)

if name == ‘main’:
print(“STARTED”)
app.run(debug=True)

``

The html template is very simple:

{{ tag | safe }}

``

I then (attempt) to run by invoking:

bokeh serve

``

followed by

python flask_app.py

``

Navigating to 127.0.0.1:5000/ there is nothing represented, and an error is in the console similar to:

[Error] Bokeh: Failed to repull session Error: Module `VBoxForm’ does not exists. The problem may be two fold. Either a model was requested that’s available in an extra bundle, e.g. a widget, or a custom model was requested, but it wasn’t registered before first usage.

``

The particular module in the error changes when re-running (or re-accessing the route) to Slider, HBox, etc. so I’m not sure how to interpret it (likely not the root issue?). Otherwise, the HTML was in fact rendered with the tag inserted where expected.

Any advice, one way or the other, on this would be much appreciated!

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/25b874bb-523b-473f-abd8-7bdb2f9b421f%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Havoc,

You can find the code here: https://github.com/mbertoll/bokeh_examples/tree/master/sliders

Looking at the virtual environment I’m running this I find the following:

venv/lib/python3.4/site-packages/bokeh/server/static/js:
bokeh.js
bokeh.js.map
bokeh.min.js
bokeh.min.js.map
bokeh-widgets.js
bokeh-widgets.js.map
bokeh-widgets.min.js
bokeh-widgets.min.js.map

``

And none of these files is empty. So I interpreted that as having bokeh-widgets.js

Any help on this is much appreciated!

···

On Thursday, November 19, 2015 at 6:17:55 PM UTC-5, [email protected] wrote:

Hi Havoc,

Thanks for the response. I still have not solved it! Give me a bit and I’ll get the code up!

On Thursday, November 19, 2015 at 8:47:16 AM UTC-5, Havoc Pennington wrote:

Hi,

Just catching up on the mailing list, so maybe you solved this already. This error probably means your page has the base bokeh.js file but not the bokeh-widgets.js file. I do not know why that is, though. If you can put up your complete runnable code somewhere I could take a look (we’d like to have a public Flask example anyway).

Havoc

On Nov 12, 2015, at 5:08 PM, [email protected] wrote:

Let me start with some background, in case my initial premises are totally wrong:

I have a Flask app which generates a large amount of data for the user. I’d like to serve up an interactive bokeh plot for that data (like a dashboard). The interactions alter the data based on user-generated functions. From what I’ve read, this talking between the plotting and a python function means serving this as an app (such as the stock_app example) is the best way to handle this.

Before jumping down the rabbit hole of the coding question, let me ask: I will need to serve different interactive dashboards for each user, on demand. I’m still learning about bokeh server, so is this type of thing possible without spinning up multiple servers? Or is another approach more appropriate?

If this isn’t a terrible idea to begin with, here is my question :slight_smile:

How do I serve up this applet? I’ve attempted to follow the stock_app example, but serving it up in Flask appears to not work with the new edition of the bokeh server (v. 0.11dev, which is awesome). So I’ve been stumbling on my own to recreate a similar case with the slider_app.

In short, I’ve wrapped the latest version of the slider_app into a class, SliderApp, with a method SliderApp.get_app() which returns the HBox layout of the app.

def get_app(self):
inputs = VBoxForm(children=[self.text, self.offset, self.amplitude, self.phase, self.freq])
hbox = HBox(childrend=[inputs, self.plot])
return hbox

``

This then gets called in the following, short Flask app:

from flask import render_template, Flask

from SliderApp import SliderApp
from pandas import DataFrame

from bokeh.embed import autoload_server
from bokeh.client import push_session
from bokeh.io import curdoc
from bokeh.resources import Resources

app = Flask(name)

@app.route(‘/’)
def index():
applet = SliderApp()
layout = applet.get_app()
doc = curdoc().add(layout)
push_session(curdoc())

tag = autoload_server(layout, loglevel='debug')


return render_template('slider_app.html', tag=tag)

if name == ‘main’:
print(“STARTED”)
app.run(debug=True)

``

The html template is very simple:

{{ tag | safe }}

``

I then (attempt) to run by invoking:

bokeh serve

``

followed by

python flask_app.py

``

Navigating to 127.0.0.1:5000/ there is nothing represented, and an error is in the console similar to:

[Error] Bokeh: Failed to repull session Error: Module `VBoxForm’ does not exists. The problem may be two fold. Either a model was requested that’s available in an extra bundle, e.g. a widget, or a custom model was requested, but it wasn’t registered before first usage.

``

The particular module in the error changes when re-running (or re-accessing the route) to Slider, HBox, etc. so I’m not sure how to interpret it (likely not the root issue?). Otherwise, the HTML was in fact rendered with the tag inserted where expected.

Any advice, one way or the other, on this would be much appreciated!

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/25b874bb-523b-473f-abd8-7bdb2f9b421f%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

In addition to what I posted earlier, I tired to do a bit more debugging. Here’s the output of the server while it running:
INFO:tornado.access:200 GET /autoload.js?bokeh-autoload-element=8a7de592-291b-4aa6-8a89-80c9b668ccc6 (::1) 0.82ms

INFO:bokeh.server.views.ws:WebSocket connection opened

DEBUG:bokeh.server.views.ws:Receiver created created for Protocol(‘1.0’)

DEBUG:bokeh.server.views.ws:ServerHandler created created for Protocol(‘1.0’)

INFO:bokeh.server.views.ws:ServerConnection created

DEBUG:bokeh.server.session:Sending pull-doc-reply from session ‘default’

DEBUG:bokeh.server.tornado:[pid 33097] 2 clients connected

INFO:tornado.access:200 GET /bokehjs/static/css/bokeh-widgets.min.css.map (::1) 163.68ms

INFO:tornado.access:200 GET /bokehjs/static/css/bokeh.min.css.map (::1) 61.46ms

INFO:tornado.access:200 GET /bokehjs/static/js/bokeh.min.js.map (::1) 255.78ms

DEBUG:bokeh.server.tornado:[pid 33097] 2 clients connected

``

I don’t see any errors in pulling the js in, but it doesn’t appear to make a request for bokeh-widgets.js.

···

On Thursday, November 19, 2015 at 8:47:16 AM UTC-5, Havoc Pennington wrote:

Hi,

Just catching up on the mailing list, so maybe you solved this already. This error probably means your page has the base bokeh.js file but not the bokeh-widgets.js file. I do not know why that is, though. If you can put up your complete runnable code somewhere I could take a look (we’d like to have a public Flask example anyway).

Havoc

On Nov 12, 2015, at 5:08 PM, [email protected] wrote:

Let me start with some background, in case my initial premises are totally wrong:

I have a Flask app which generates a large amount of data for the user. I’d like to serve up an interactive bokeh plot for that data (like a dashboard). The interactions alter the data based on user-generated functions. From what I’ve read, this talking between the plotting and a python function means serving this as an app (such as the stock_app example) is the best way to handle this.

Before jumping down the rabbit hole of the coding question, let me ask: I will need to serve different interactive dashboards for each user, on demand. I’m still learning about bokeh server, so is this type of thing possible without spinning up multiple servers? Or is another approach more appropriate?

If this isn’t a terrible idea to begin with, here is my question :slight_smile:

How do I serve up this applet? I’ve attempted to follow the stock_app example, but serving it up in Flask appears to not work with the new edition of the bokeh server (v. 0.11dev, which is awesome). So I’ve been stumbling on my own to recreate a similar case with the slider_app.

In short, I’ve wrapped the latest version of the slider_app into a class, SliderApp, with a method SliderApp.get_app() which returns the HBox layout of the app.

def get_app(self):
inputs = VBoxForm(children=[self.text, self.offset, self.amplitude, self.phase, self.freq])
hbox = HBox(childrend=[inputs, self.plot])
return hbox

``

This then gets called in the following, short Flask app:

from flask import render_template, Flask

from SliderApp import SliderApp
from pandas import DataFrame

from bokeh.embed import autoload_server
from bokeh.client import push_session
from bokeh.io import curdoc
from bokeh.resources import Resources

app = Flask(name)

@app.route(‘/’)
def index():
applet = SliderApp()
layout = applet.get_app()
doc = curdoc().add(layout)
push_session(curdoc())

tag = autoload_server(layout, loglevel='debug')


return render_template('slider_app.html', tag=tag)

if name == ‘main’:
print(“STARTED”)
app.run(debug=True)

``

The html template is very simple:

{{ tag | safe }}

``

I then (attempt) to run by invoking:

bokeh serve

``

followed by

python flask_app.py

``

Navigating to 127.0.0.1:5000/ there is nothing represented, and an error is in the console similar to:

[Error] Bokeh: Failed to repull session Error: Module `VBoxForm’ does not exists. The problem may be two fold. Either a model was requested that’s available in an extra bundle, e.g. a widget, or a custom model was requested, but it wasn’t registered before first usage.

``

The particular module in the error changes when re-running (or re-accessing the route) to Slider, HBox, etc. so I’m not sure how to interpret it (likely not the root issue?). Otherwise, the HTML was in fact rendered with the tag inserted where expected.

Any advice, one way or the other, on this would be much appreciated!

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/25b874bb-523b-473f-abd8-7bdb2f9b421f%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Hi,

Thanks for the code!

One bug is this TODO:

https://github.com/bokeh/bokeh/blob/e97abdd3bbfa8922695edf4216bfab4fc4b496de/bokeh/server/views/autoload_js_handler.py#L38-L40

From the error you’re seeing, you may not have this commit which fixed things to include both bokeh.js and bokeh-widgets.js but broke autoload_server to not have any bokeh js at all:

https://github.com/bokeh/bokeh/commit/a0c305d588be85cde988c49c1026b294c3039fda

That commit fixed autoload_static to have bokeh-widgets, but it broke autoload_server entirely. For the server we need to change another spot. I opened this issue:

https://github.com/bokeh/bokeh/issues/3172

I also would recommend structuring things a bit differently, like the patch I’ll attach for your example. I’m running “python flask_app.py” and “bokeh serve slider_app.py”, then I pull rather than push the session from slider_app.py, so the flask app doesn’t need to do any Bokeh stuff. Also, each page load of the Flask app gets its own fresh session, so users aren’t stomping each other.

My patch will not work without the above-mentioned fix.

One thing that’s clear in the patch is that pull_session shouldn’t make you work out the websocket url, so I opened https://github.com/bokeh/bokeh/issues/3171 for that.

Another issue here is that in a real-world app you’ll run into cross-origin issues once we fix https://github.com/bokeh/bokeh/issues/3102 , but that should be fixable by adding some kind of command-line option like bokeh serve --allow-origin your.flask.host sliders_app.py or something like that (exactly how it will work depends on how that issue is closed).

Thanks for testing this out!

Havoc

sliders_flask.patch (1.12 KB)

···

On Thu, Nov 19, 2015 at 8:28 PM, [email protected] wrote:

Havoc,

You can find the code here: https://github.com/mbertoll/bokeh_examples/tree/master/sliders

Looking at the virtual environment I’m running this I find the following:

venv/lib/python3.4/site-packages/bokeh/server/static/js:
bokeh.js
bokeh.js.map
bokeh.min.js
bokeh.min.js.map
bokeh-widgets.js
bokeh-widgets.js.map
bokeh-widgets.min.js
bokeh-widgets.min.js.map

``

And none of these files is empty. So I interpreted that as having bokeh-widgets.js

Any help on this is much appreciated!

On Thursday, November 19, 2015 at 6:17:55 PM UTC-5, [email protected] wrote:

Hi Havoc,

Thanks for the response. I still have not solved it! Give me a bit and I’ll get the code up!

On Thursday, November 19, 2015 at 8:47:16 AM UTC-5, Havoc Pennington wrote:

Hi,

Just catching up on the mailing list, so maybe you solved this already. This error probably means your page has the base bokeh.js file but not the bokeh-widgets.js file. I do not know why that is, though. If you can put up your complete runnable code somewhere I could take a look (we’d like to have a public Flask example anyway).

Havoc

On Nov 12, 2015, at 5:08 PM, [email protected] wrote:

Let me start with some background, in case my initial premises are totally wrong:

I have a Flask app which generates a large amount of data for the user. I’d like to serve up an interactive bokeh plot for that data (like a dashboard). The interactions alter the data based on user-generated functions. From what I’ve read, this talking between the plotting and a python function means serving this as an app (such as the stock_app example) is the best way to handle this.

Before jumping down the rabbit hole of the coding question, let me ask: I will need to serve different interactive dashboards for each user, on demand. I’m still learning about bokeh server, so is this type of thing possible without spinning up multiple servers? Or is another approach more appropriate?

If this isn’t a terrible idea to begin with, here is my question :slight_smile:

How do I serve up this applet? I’ve attempted to follow the stock_app example, but serving it up in Flask appears to not work with the new edition of the bokeh server (v. 0.11dev, which is awesome). So I’ve been stumbling on my own to recreate a similar case with the slider_app.

In short, I’ve wrapped the latest version of the slider_app into a class, SliderApp, with a method SliderApp.get_app() which returns the HBox layout of the app.

def get_app(self):
inputs = VBoxForm(children=[self.text, self.offset, self.amplitude, self.phase, self.freq])
hbox = HBox(childrend=[inputs, self.plot])
return hbox

``

This then gets called in the following, short Flask app:

from flask import render_template, Flask

from SliderApp import SliderApp
from pandas import DataFrame

from bokeh.embed import autoload_server
from bokeh.client import push_session
from bokeh.io import curdoc
from bokeh.resources import Resources

app = Flask(name)

@app.route(‘/’)
def index():
applet = SliderApp()
layout = applet.get_app()
doc = curdoc().add(layout)
push_session(curdoc())

tag = autoload_server(layout, loglevel='debug')


return render_template('slider_app.html', tag=tag)

if name == ‘main’:
print(“STARTED”)
app.run(debug=True)

``

The html template is very simple:

{{ tag | safe }}

``

I then (attempt) to run by invoking:

bokeh serve

``

followed by

python flask_app.py

``

Navigating to 127.0.0.1:5000/ there is nothing represented, and an error is in the console similar to:

[Error] Bokeh: Failed to repull session Error: Module `VBoxForm’ does not exists. The problem may be two fold. Either a model was requested that’s available in an extra bundle, e.g. a widget, or a custom model was requested, but it wasn’t registered before first usage.

``

The particular module in the error changes when re-running (or re-accessing the route) to Slider, HBox, etc. so I’m not sure how to interpret it (likely not the root issue?). Otherwise, the HTML was in fact rendered with the tag inserted where expected.

Any advice, one way or the other, on this would be much appreciated!

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/25b874bb-523b-473f-abd8-7bdb2f9b421f%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/66da12b7-c57b-44cd-95c2-3a361fa118a6%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Havoc Pennington

Senior Software Architect

Hi Havoc,

Thanks for looking at this, and the patch! You mention using pull_session to avoid users stomping on each other, which makes complete sense. This is one concern I have in extending this app a bit, to allow different users to view different versions of the app.

I generated a SliderApp class that accepts user input: https://github.com/mbertoll/bokeh_examples/blob/master/sliders/slider_app_func.py

I figured that doing a push would allow me to render new versions of the template for each user, based on some input from them. Any thoughts on how structure the app for that?

Thanks again!

···

On Friday, November 20, 2015 at 9:20:11 PM UTC-5, Havoc Pennington wrote:

Hi,

Thanks for the code!

One bug is this TODO:

https://github.com/bokeh/bokeh/blob/e97abdd3bbfa8922695edf4216bfab4fc4b496de/bokeh/server/views/autoload_js_handler.py#L38-L40

From the error you’re seeing, you may not have this commit which fixed things to include both bokeh.js and bokeh-widgets.js but broke autoload_server to not have any bokeh js at all:

https://github.com/bokeh/bokeh/commit/a0c305d588be85cde988c49c1026b294c3039fda

That commit fixed autoload_static to have bokeh-widgets, but it broke autoload_server entirely. For the server we need to change another spot. I opened this issue:

https://github.com/bokeh/bokeh/issues/3172

I also would recommend structuring things a bit differently, like the patch I’ll attach for your example. I’m running “python flask_app.py” and “bokeh serve slider_app.py”, then I pull rather than push the session from slider_app.py, so the flask app doesn’t need to do any Bokeh stuff. Also, each page load of the Flask app gets its own fresh session, so users aren’t stomping each other.

My patch will not work without the above-mentioned fix.

One thing that’s clear in the patch is that pull_session shouldn’t make you work out the websocket url, so I opened https://github.com/bokeh/bokeh/issues/3171 for that.

Another issue here is that in a real-world app you’ll run into cross-origin issues once we fix https://github.com/bokeh/bokeh/issues/3102 , but that should be fixable by adding some kind of command-line option like bokeh serve --allow-origin your.flask.host sliders_app.py or something like that (exactly how it will work depends on how that issue is closed).

Thanks for testing this out!

Havoc

On Thu, Nov 19, 2015 at 8:28 PM, [email protected] wrote:

Havoc,

You can find the code here: https://github.com/mbertoll/bokeh_examples/tree/master/sliders

Looking at the virtual environment I’m running this I find the following:

venv/lib/python3.4/site-packages/bokeh/server/static/js:
bokeh.js
bokeh.js.map
bokeh.min.js
bokeh.min.js.map
bokeh-widgets.js
bokeh-widgets.js.map
bokeh-widgets.min.js
bokeh-widgets.min.js.map

``

And none of these files is empty. So I interpreted that as having bokeh-widgets.js

Any help on this is much appreciated!

On Thursday, November 19, 2015 at 6:17:55 PM UTC-5, [email protected] wrote:

Hi Havoc,

Thanks for the response. I still have not solved it! Give me a bit and I’ll get the code up!

On Thursday, November 19, 2015 at 8:47:16 AM UTC-5, Havoc Pennington wrote:

Hi,

Just catching up on the mailing list, so maybe you solved this already. This error probably means your page has the base bokeh.js file but not the bokeh-widgets.js file. I do not know why that is, though. If you can put up your complete runnable code somewhere I could take a look (we’d like to have a public Flask example anyway).

Havoc

On Nov 12, 2015, at 5:08 PM, [email protected] wrote:

Let me start with some background, in case my initial premises are totally wrong:

I have a Flask app which generates a large amount of data for the user. I’d like to serve up an interactive bokeh plot for that data (like a dashboard). The interactions alter the data based on user-generated functions. From what I’ve read, this talking between the plotting and a python function means serving this as an app (such as the stock_app example) is the best way to handle this.

Before jumping down the rabbit hole of the coding question, let me ask: I will need to serve different interactive dashboards for each user, on demand. I’m still learning about bokeh server, so is this type of thing possible without spinning up multiple servers? Or is another approach more appropriate?

If this isn’t a terrible idea to begin with, here is my question :slight_smile:

How do I serve up this applet? I’ve attempted to follow the stock_app example, but serving it up in Flask appears to not work with the new edition of the bokeh server (v. 0.11dev, which is awesome). So I’ve been stumbling on my own to recreate a similar case with the slider_app.

In short, I’ve wrapped the latest version of the slider_app into a class, SliderApp, with a method SliderApp.get_app() which returns the HBox layout of the app.

def get_app(self):
inputs = VBoxForm(children=[self.text, self.offset, self.amplitude, self.phase, self.freq])
hbox = HBox(childrend=[inputs, self.plot])
return hbox

``

This then gets called in the following, short Flask app:

from flask import render_template, Flask

from SliderApp import SliderApp
from pandas import DataFrame

from bokeh.embed import autoload_server
from bokeh.client import push_session
from bokeh.io import curdoc
from bokeh.resources import Resources

app = Flask(name)

@app.route(‘/’)
def index():
applet = SliderApp()
layout = applet.get_app()
doc = curdoc().add(layout)
push_session(curdoc())

tag = autoload_server(layout, loglevel='debug')


return render_template('slider_app.html', tag=tag)

if name == ‘main’:
print(“STARTED”)
app.run(debug=True)

``

The html template is very simple:

{{ tag | safe }}

``

I then (attempt) to run by invoking:

bokeh serve

``

followed by

python flask_app.py

``

Navigating to 127.0.0.1:5000/ there is nothing represented, and an error is in the console similar to:

[Error] Bokeh: Failed to repull session Error: Module `VBoxForm’ does not exists. The problem may be two fold. Either a model was requested that’s available in an extra bundle, e.g. a widget, or a custom model was requested, but it wasn’t registered before first usage.

``

The particular module in the error changes when re-running (or re-accessing the route) to Slider, HBox, etc. so I’m not sure how to interpret it (likely not the root issue?). Otherwise, the HTML was in fact rendered with the tag inserted where expected.

Any advice, one way or the other, on this would be much appreciated!

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/25b874bb-523b-473f-abd8-7bdb2f9b421f%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/66da12b7-c57b-44cd-95c2-3a361fa118a6%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.


Havoc Pennington

Senior Software Architect

Hi,

Sure, once you pull the session (but before you close it) any modifications to session.document would be sent to the bokeh server. So you should be able to build part of the app after you pull, or modify it, if you want.

push_session can also work, but you may want to use a random session id each time, and be sure to get the session back from push_session and close() it. You can also if you like simply create an empty Document() rather than worry about curdoc(), since curdoc() is a global var it would persist across requests which might result in weird stuff. Globals are always a little dangerous.

Another tip, on the master branch of bokeh there are methods to select() and get_model_by_name() on Document, so you would be able to easily find the right models to modify after you pull the session if you give those models names. This is probably less hacky than next(iter(document.roots)) or whatever I did :slight_smile:

Havoc

···

On Nov 20, 2015, at 9:28 PM, [email protected] wrote:

Hi Havoc,

Thanks for looking at this, and the patch! You mention using pull_session to avoid users stomping on each other, which makes complete sense. This is one concern I have in extending this app a bit, to allow different users to view different versions of the app.

I generated a SliderApp class that accepts user input: https://github.com/mbertoll/bokeh_examples/blob/master/sliders/slider_app_func.py

I figured that doing a push would allow me to render new versions of the template for each user, based on some input from them. Any thoughts on how structure the app for that?

Thanks again!

On Friday, November 20, 2015 at 9:20:11 PM UTC-5, Havoc Pennington wrote:

Hi,

Thanks for the code!

One bug is this TODO:

https://github.com/bokeh/bokeh/blob/e97abdd3bbfa8922695edf4216bfab4fc4b496de/bokeh/server/views/autoload_js_handler.py#L38-L40

From the error you’re seeing, you may not have this commit which fixed things to include both bokeh.js and bokeh-widgets.js but broke autoload_server to not have any bokeh js at all:

https://github.com/bokeh/bokeh/commit/a0c305d588be85cde988c49c1026b294c3039fda

That commit fixed autoload_static to have bokeh-widgets, but it broke autoload_server entirely. For the server we need to change another spot. I opened this issue:

https://github.com/bokeh/bokeh/issues/3172

I also would recommend structuring things a bit differently, like the patch I’ll attach for your example. I’m running “python flask_app.py” and “bokeh serve slider_app.py”, then I pull rather than push the session from slider_app.py, so the flask app doesn’t need to do any Bokeh stuff. Also, each page load of the Flask app gets its own fresh session, so users aren’t stomping each other.

My patch will not work without the above-mentioned fix.

One thing that’s clear in the patch is that pull_session shouldn’t make you work out the websocket url, so I opened https://github.com/bokeh/bokeh/issues/3171 for that.

Another issue here is that in a real-world app you’ll run into cross-origin issues once we fix https://github.com/bokeh/bokeh/issues/3102 , but that should be fixable by adding some kind of command-line option like bokeh serve --allow-origin your.flask.host sliders_app.py or something like that (exactly how it will work depends on how that issue is closed).

Thanks for testing this out!

Havoc

On Thu, Nov 19, 2015 at 8:28 PM, [email protected] wrote:

Havoc,

You can find the code here: https://github.com/mbertoll/bokeh_examples/tree/master/sliders

Looking at the virtual environment I’m running this I find the following:

venv/lib/python3.4/site-packages/bokeh/server/static/js:
bokeh.js
bokeh.js.map
bokeh.min.js
bokeh.min.js.map
bokeh-widgets.js
bokeh-widgets.js.map
bokeh-widgets.min.js
bokeh-widgets.min.js.map

``

And none of these files is empty. So I interpreted that as having bokeh-widgets.js

Any help on this is much appreciated!

On Thursday, November 19, 2015 at 6:17:55 PM UTC-5, [email protected] wrote:

Hi Havoc,

Thanks for the response. I still have not solved it! Give me a bit and I’ll get the code up!

On Thursday, November 19, 2015 at 8:47:16 AM UTC-5, Havoc Pennington wrote:

Hi,

Just catching up on the mailing list, so maybe you solved this already. This error probably means your page has the base bokeh.js file but not the bokeh-widgets.js file. I do not know why that is, though. If you can put up your complete runnable code somewhere I could take a look (we’d like to have a public Flask example anyway).

Havoc

On Nov 12, 2015, at 5:08 PM, [email protected] wrote:

Let me start with some background, in case my initial premises are totally wrong:

I have a Flask app which generates a large amount of data for the user. I’d like to serve up an interactive bokeh plot for that data (like a dashboard). The interactions alter the data based on user-generated functions. From what I’ve read, this talking between the plotting and a python function means serving this as an app (such as the stock_app example) is the best way to handle this.

Before jumping down the rabbit hole of the coding question, let me ask: I will need to serve different interactive dashboards for each user, on demand. I’m still learning about bokeh server, so is this type of thing possible without spinning up multiple servers? Or is another approach more appropriate?

If this isn’t a terrible idea to begin with, here is my question :slight_smile:

How do I serve up this applet? I’ve attempted to follow the stock_app example, but serving it up in Flask appears to not work with the new edition of the bokeh server (v. 0.11dev, which is awesome). So I’ve been stumbling on my own to recreate a similar case with the slider_app.

In short, I’ve wrapped the latest version of the slider_app into a class, SliderApp, with a method SliderApp.get_app() which returns the HBox layout of the app.

def get_app(self):
inputs = VBoxForm(children=[self.text, self.offset, self.amplitude, self.phase, self.freq])
hbox = HBox(childrend=[inputs, self.plot])
return hbox

``

This then gets called in the following, short Flask app:

from flask import render_template, Flask

from SliderApp import SliderApp
from pandas import DataFrame

from bokeh.embed import autoload_server
from bokeh.client import push_session
from bokeh.io import curdoc
from bokeh.resources import Resources

app = Flask(name)

@app.route(‘/’)
def index():
applet = SliderApp()
layout = applet.get_app()
doc = curdoc().add(layout)
push_session(curdoc())

tag = autoload_server(layout, loglevel='debug')


return render_template('slider_app.html', tag=tag)

if name == ‘main’:
print(“STARTED”)
app.run(debug=True)

``

The html template is very simple:

{{ tag | safe }}

``

I then (attempt) to run by invoking:

bokeh serve

``

followed by

python flask_app.py

``

Navigating to 127.0.0.1:5000/ there is nothing represented, and an error is in the console similar to:

[Error] Bokeh: Failed to repull session Error: Module `VBoxForm’ does not exists. The problem may be two fold. Either a model was requested that’s available in an extra bundle, e.g. a widget, or a custom model was requested, but it wasn’t registered before first usage.

``

The particular module in the error changes when re-running (or re-accessing the route) to Slider, HBox, etc. so I’m not sure how to interpret it (likely not the root issue?). Otherwise, the HTML was in fact rendered with the tag inserted where expected.

Any advice, one way or the other, on this would be much appreciated!

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/25b874bb-523b-473f-abd8-7bdb2f9b421f%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/66da12b7-c57b-44cd-95c2-3a361fa118a6%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.


Havoc Pennington

Senior Software Architect

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/1a50203f-695e-42c9-87cc-f3c1f7965fc5%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Thanks for the tips and explanation of how to use this for multiple users. Bokeh is an incredible tool!

Any projection on when 0.11 will be released? It looks like some major upgrades from 0.10 on the server side :slight_smile:

···

On Friday, November 20, 2015 at 10:27:38 PM UTC-5, Havoc Pennington wrote:

Hi,

Sure, once you pull the session (but before you close it) any modifications to session.document would be sent to the bokeh server. So you should be able to build part of the app after you pull, or modify it, if you want.

push_session can also work, but you may want to use a random session id each time, and be sure to get the session back from push_session and close() it. You can also if you like simply create an empty Document() rather than worry about curdoc(), since curdoc() is a global var it would persist across requests which might result in weird stuff. Globals are always a little dangerous.

Another tip, on the master branch of bokeh there are methods to select() and get_model_by_name() on Document, so you would be able to easily find the right models to modify after you pull the session if you give those models names. This is probably less hacky than next(iter(document.roots)) or whatever I did :slight_smile:

Havoc

On Nov 20, 2015, at 9:28 PM, [email protected] wrote:

Hi Havoc,

Thanks for looking at this, and the patch! You mention using pull_session to avoid users stomping on each other, which makes complete sense. This is one concern I have in extending this app a bit, to allow different users to view different versions of the app.

I generated a SliderApp class that accepts user input: https://github.com/mbertoll/bokeh_examples/blob/master/sliders/slider_app_func.py

I figured that doing a push would allow me to render new versions of the template for each user, based on some input from them. Any thoughts on how structure the app for that?

Thanks again!

On Friday, November 20, 2015 at 9:20:11 PM UTC-5, Havoc Pennington wrote:

Hi,

Thanks for the code!

One bug is this TODO:

https://github.com/bokeh/bokeh/blob/e97abdd3bbfa8922695edf4216bfab4fc4b496de/bokeh/server/views/autoload_js_handler.py#L38-L40

From the error you’re seeing, you may not have this commit which fixed things to include both bokeh.js and bokeh-widgets.js but broke autoload_server to not have any bokeh js at all:

https://github.com/bokeh/bokeh/commit/a0c305d588be85cde988c49c1026b294c3039fda

That commit fixed autoload_static to have bokeh-widgets, but it broke autoload_server entirely. For the server we need to change another spot. I opened this issue:

https://github.com/bokeh/bokeh/issues/3172

I also would recommend structuring things a bit differently, like the patch I’ll attach for your example. I’m running “python flask_app.py” and “bokeh serve slider_app.py”, then I pull rather than push the session from slider_app.py, so the flask app doesn’t need to do any Bokeh stuff. Also, each page load of the Flask app gets its own fresh session, so users aren’t stomping each other.

My patch will not work without the above-mentioned fix.

One thing that’s clear in the patch is that pull_session shouldn’t make you work out the websocket url, so I opened https://github.com/bokeh/bokeh/issues/3171 for that.

Another issue here is that in a real-world app you’ll run into cross-origin issues once we fix https://github.com/bokeh/bokeh/issues/3102 , but that should be fixable by adding some kind of command-line option like bokeh serve --allow-origin your.flask.host sliders_app.py or something like that (exactly how it will work depends on how that issue is closed).

Thanks for testing this out!

Havoc

On Thu, Nov 19, 2015 at 8:28 PM, [email protected] wrote:

Havoc,

You can find the code here: https://github.com/mbertoll/bokeh_examples/tree/master/sliders

Looking at the virtual environment I’m running this I find the following:

venv/lib/python3.4/site-packages/bokeh/server/static/js:
bokeh.js
bokeh.js.map
bokeh.min.js
bokeh.min.js.map
bokeh-widgets.js
bokeh-widgets.js.map
bokeh-widgets.min.js
bokeh-widgets.min.js.map

``

And none of these files is empty. So I interpreted that as having bokeh-widgets.js

Any help on this is much appreciated!

On Thursday, November 19, 2015 at 6:17:55 PM UTC-5, [email protected] wrote:

Hi Havoc,

Thanks for the response. I still have not solved it! Give me a bit and I’ll get the code up!

On Thursday, November 19, 2015 at 8:47:16 AM UTC-5, Havoc Pennington wrote:

Hi,

Just catching up on the mailing list, so maybe you solved this already. This error probably means your page has the base bokeh.js file but not the bokeh-widgets.js file. I do not know why that is, though. If you can put up your complete runnable code somewhere I could take a look (we’d like to have a public Flask example anyway).

Havoc

On Nov 12, 2015, at 5:08 PM, [email protected] wrote:

Let me start with some background, in case my initial premises are totally wrong:

I have a Flask app which generates a large amount of data for the user. I’d like to serve up an interactive bokeh plot for that data (like a dashboard). The interactions alter the data based on user-generated functions. From what I’ve read, this talking between the plotting and a python function means serving this as an app (such as the stock_app example) is the best way to handle this.

Before jumping down the rabbit hole of the coding question, let me ask: I will need to serve different interactive dashboards for each user, on demand. I’m still learning about bokeh server, so is this type of thing possible without spinning up multiple servers? Or is another approach more appropriate?

If this isn’t a terrible idea to begin with, here is my question :slight_smile:

How do I serve up this applet? I’ve attempted to follow the stock_app example, but serving it up in Flask appears to not work with the new edition of the bokeh server (v. 0.11dev, which is awesome). So I’ve been stumbling on my own to recreate a similar case with the slider_app.

In short, I’ve wrapped the latest version of the slider_app into a class, SliderApp, with a method SliderApp.get_app() which returns the HBox layout of the app.

def get_app(self):
inputs = VBoxForm(children=[self.text, self.offset, self.amplitude, self.phase, self.freq])
hbox = HBox(childrend=[inputs, self.plot])
return hbox

``

This then gets called in the following, short Flask app:

from flask import render_template, Flask

from SliderApp import SliderApp
from pandas import DataFrame

from bokeh.embed import autoload_server
from bokeh.client import push_session
from bokeh.io import curdoc
from bokeh.resources import Resources

app = Flask(name)

@app.route(‘/’)
def index():
applet = SliderApp()
layout = applet.get_app()
doc = curdoc().add(layout)
push_session(curdoc())

tag = autoload_server(layout, loglevel='debug')


return render_template('slider_app.html', tag=tag)

if name == ‘main’:
print(“STARTED”)
app.run(debug=True)

``

The html template is very simple:

{{ tag | safe }}

``

I then (attempt) to run by invoking:

bokeh serve

``

followed by

python flask_app.py

``

Navigating to 127.0.0.1:5000/ there is nothing represented, and an error is in the console similar to:

[Error] Bokeh: Failed to repull session Error: Module `VBoxForm’ does not exists. The problem may be two fold. Either a model was requested that’s available in an extra bundle, e.g. a widget, or a custom model was requested, but it wasn’t registered before first usage.

``

The particular module in the error changes when re-running (or re-accessing the route) to Slider, HBox, etc. so I’m not sure how to interpret it (likely not the root issue?). Otherwise, the HTML was in fact rendered with the tag inserted where expected.

Any advice, one way or the other, on this would be much appreciated!

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/25b874bb-523b-473f-abd8-7bdb2f9b421f%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/66da12b7-c57b-44cd-95c2-3a361fa118a6%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.


Havoc Pennington

Senior Software Architect

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/1a50203f-695e-42c9-87cc-f3c1f7965fc5%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.