Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flask implementation of datashaded bokeh app #2929

Open
benvddriessche opened this issue Aug 6, 2018 · 3 comments
Open

Flask implementation of datashaded bokeh app #2929

benvddriessche opened this issue Aug 6, 2018 · 3 comments

Comments

@benvddriessche
Copy link

I am working on a dashboard for visualization of large time series. The combination of Jupyter + Bokeh + Holoviews/Datashader is perfect for prototyping and data exploration. However, I would like to embed some graphs on more user-friendly web pages using Flask.

  • Deploying bokeh apps without datashading using script, div = components(bokeh_figure) in Flask works perfectly fine.
  • Visualizing bokeh apps with datashading in Jupyter or using bokeh serve also works fine, e.g. with doc = hv.renderer('bokeh').server_doc(datashaded_hvObject).
  • Where I'm running into issues is combining these two steps. I can render a datashaded bokeh app in Flask like so:
    renderer = hv.renderer('bokeh').instance(mode='server')
    hvplot = renderer.get_plot(datashaded_hvObject)
    script_data, div_data = components(hvplot.state)

... but this of course only shows a single rasterized frame and is missing the callback to update the plot when someone is interacting with it.

Based on some tutorials, I'm running a bokeh server from my Flask script as follows:

bokeh_process = subprocess.Popen(['bokeh', 'serve', '--allow-websocket-origin=localhost:5000','test.py'], stdout=subprocess.PIPE)

With the main Flask @app.route set as follows:
session = pull_session(session_id=None)
bokeh_script = server_session(None, session_id=session.id)
return render_template('test.html', script_data=bokeh_script)

This is not working though as it doesn't appear to connect to the correct session ID: Cannot pull session document because we failed to connect to the server (to start the server, try the 'bokeh serve' command). I'm also not sure this would actually get me a working interactive session.

I realize this is not a strict Holoviews question but I figured it may be useful to other Datashader users. Let me know if it's out of scope!

@jlstevens
Copy link
Contributor

I don't know offhand how to resolve the issue you have pulling the session document but I can say that a docs PR explaining how to use holoviews/datashader together with flask would be very welcome!

@philippjfr
Copy link
Member

There is already a PR for a flask app here #2907, which could maybe be adapted.

@benvddriessche
Copy link
Author

Thank you @philippjfr, the PR put me on the right track!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants