Starting Point for building a Bokeh-based web application

Hi All!

I’m kicking off development for a Django web application that hosts a dashboard driven by Bokeh server. Any advice is greatly appreciated . . . blogs/templates/repositories/etc.

But right now I’m pouring over the Bokeh server documentation and found a dead link in the documentation at**:**

http://bokeh.pydata.org/en/latest/docs/user_guide/server.html

The dead link is located where it says: "See a complete example at https://github.com/bokeh/bokeh-demos/tree/master/happiness "

Does this still exist somewhere else, or is there another template I can use as a baseline to host a bokeh server that’s called by a Django web application?

Thanks in advance . . . looking forward to becoming a Bokeh expert.

Cheers,

Jonathan

https://groups.google.com/a/continuum.io/d/msg/bokeh/TtCyyKTiOIo/6UzhU0RlAwAJ

:[

···

On Tuesday, September 12, 2017 at 12:12:39 PM UTC-4, Jonathan Bennett wrote:

Hi All!

I’m kicking off development for a Django web application that hosts a dashboard driven by Bokeh server. Any advice is greatly appreciated . . . blogs/templates/repositories/etc.

But right now I’m pouring over the Bokeh server documentation and found a dead link in the documentation at**:**

http://bokeh.pydata.org/en/latest/docs/user_guide/server.html

The dead link is located where it says: "See a complete example at https://github.com/bokeh/bokeh-demos/tree/master/happiness "

Does this still exist somewhere else, or is there another template I can use as a baseline to host a bokeh server that’s called by a Django web application?

Thanks in advance . . . looking forward to becoming a Bokeh expert.

Cheers,

Jonathan

Hi,

Unfortunately I don't know DJango and it is simply outside my ability to scale another learning curve right now. The core, most important gist of what the old happiness example did was simply to use "bokeh.client" to create an customize sessions on a per user basis. I've attached a simple Flask example below that hopefully is useful to adapt. The example uses an "embedded" server but it would work nearly identically if your ran the app in a separate "bokeh serve app.py" process.

Note also that since making HTML request args available to apps, this use of bokeh.client is not even necessary to customize. If using HTML request args is acceptable, you can just put any customization data there (obviously not OK for private or sensitive things).

Code:

  from flask import Flask, render_template
  from bokeh.client import pull_session
  from bokeh.embed import server_session

  app = Flask(__name__)

  @app.route('/', methods=['GET'])
  def bkapp_page():
      session = pull_session(url="http://localhost:5006/sliders")

      # Customize the session here
         session.document.roots[0].children[1].title.text = "Special Sliders For Jean-Luc"

          session.push()

      # Serve the specific customized session to viewer here
      script = server_session(None, session.id, url='http://localhost:5006/sliders')
    
      return render_template("embed.html", script=script, template="Flask")

  if __name__ == '__main__':
      app.run(port=8080)

With this template:

  <!doctype html>
  <html lang="en">
  <head>
    <meta charset="utf-8">
    <title>Embedding a Bokeh Server With {{ framework }}</title>
  </head>

  <body>
  {{ script|safe }}
  </body>
  </html>

Thanks,

Bryan

···

On Sep 12, 2017, at 12:28, [email protected] wrote:

https://groups.google.com/a/continuum.io/d/msg/bokeh/TtCyyKTiOIo/6UzhU0RlAwAJ

:[

On Tuesday, September 12, 2017 at 12:12:39 PM UTC-4, Jonathan Bennett wrote:
Hi All!

I'm kicking off development for a Django web application that hosts a dashboard driven by Bokeh server. Any advice is greatly appreciated . . . blogs/templates/repositories/etc.
But right now I'm pouring over the Bokeh server documentation and found a dead link in the documentation at:

http://bokeh.pydata.org/en/latest/docs/user_guide/server.html
The dead link is located where it says: "See a complete example at https://github.com/bokeh/bokeh-demos/tree/master/happiness "

Does this still exist somewhere else, or is there another template I can use as a baseline to host a bokeh server that's called by a Django web application?

Thanks in advance . . . looking forward to becoming a Bokeh expert.

Cheers,
Jonathan

--
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/847c3365-b9df-496f-bcf5-ec67263bd1a0%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Sorry, stated that backwards: the example code assumes you've run "bokeh serve sliders.py" but it could also be done embedded with a FunctionHander as described in the docs an examples/howto/server_embed

Bryan

···

On Sep 12, 2017, at 12:47, Bryan Van de ven <[email protected]> wrote:

Hi,

Unfortunately I don't know DJango and it is simply outside my ability to scale another learning curve right now. The core, most important gist of what the old happiness example did was simply to use "bokeh.client" to create an customize sessions on a per user basis. I've attached a simple Flask example below that hopefully is useful to adapt. The example uses an "embedded" server but it would work nearly identically if your ran the app in a separate "bokeh serve app.py" process.

Note also that since making HTML request args available to apps, this use of bokeh.client is not even necessary to customize. If using HTML request args is acceptable, you can just put any customization data there (obviously not OK for private or sensitive things).

Code:

  from flask import Flask, render_template
  from bokeh.client import pull_session
  from bokeh.embed import server_session

  app = Flask(__name__)

  @app.route('/', methods=['GET'])
  def bkapp_page():
      session = pull_session(url="http://localhost:5006/sliders")

      # Customize the session here
        session.document.roots[0].children[1].title.text = "Special Sliders For Jean-Luc"

         session.push()

      # Serve the specific customized session to viewer here
      script = server_session(None, session.id, url='http://localhost:5006/sliders')

      return render_template("embed.html", script=script, template="Flask")

  if __name__ == '__main__':
      app.run(port=8080)

With this template:

  <!doctype html>
  <html lang="en">
  <head>
    <meta charset="utf-8">
    <title>Embedding a Bokeh Server With {{ framework }}</title>
  </head>

  <body>
  {{ script|safe }}
  </body>
  </html>

Thanks,

Bryan

On Sep 12, 2017, at 12:28, [email protected] wrote:

https://groups.google.com/a/continuum.io/d/msg/bokeh/TtCyyKTiOIo/6UzhU0RlAwAJ

:[

On Tuesday, September 12, 2017 at 12:12:39 PM UTC-4, Jonathan Bennett wrote:
Hi All!

I'm kicking off development for a Django web application that hosts a dashboard driven by Bokeh server. Any advice is greatly appreciated . . . blogs/templates/repositories/etc.
But right now I'm pouring over the Bokeh server documentation and found a dead link in the documentation at:

http://bokeh.pydata.org/en/latest/docs/user_guide/server.html
The dead link is located where it says: "See a complete example at https://github.com/bokeh/bokeh-demos/tree/master/happiness "

Does this still exist somewhere else, or is there another template I can use as a baseline to host a bokeh server that's called by a Django web application?

Thanks in advance . . . looking forward to becoming a Bokeh expert.

Cheers,
Jonathan

--
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/847c3365-b9df-496f-bcf5-ec67263bd1a0%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Thanks Bryan and Kevin!! I really appreciate the responses.

I don’t really need help with Django right now (that could change, ha! And if so I’ll seek an alternative location for that help.)

What I really want to understand at the moment is the right architecture approach.

This is what I’m thinking:

  1. Use Docker to containerize my bokeh apps and serve them on AWS elastic beanstalk. expose an external port.

a) something like this: bokeh serve --allow-websocket-origin=127.0.0.1:5000 app1.py app2.py app3.py app4.py

  1. Also Launch a Django application on separate AWS elastic beanstalk instance that calls each of the apps hosted by the bokeh server

  2. Use firewalls rules in AWS so only the machines running Django can see the machines running bokeh server.

Reasoning: elastic beanstalk can scale up the bokeh server and/or the django server as needed, while keeping the bokeh server aspect relatively uncomplicated (since that’s what I know least about).

Any idea whether this a terrible idea and/or a dead end?

Cheers,

Jonathan

···

On Tue, Sep 12, 2017 at 12:50 PM, Bryan Van de ven [email protected] wrote:

Sorry, stated that backwards: the example code assumes you’ve run “bokeh serve sliders.py” but it could also be done embedded with a FunctionHander as described in the docs an examples/howto/server_embed

Bryan

On Sep 12, 2017, at 12:47, Bryan Van de ven [email protected] wrote:

Hi,

Unfortunately I don’t know DJango and it is simply outside my ability to scale another learning curve right now. The core, most important gist of what the old happiness example did was simply to use “bokeh.client” to create an customize sessions on a per user basis. I’ve attached a simple Flask example below that hopefully is useful to adapt. The example uses an “embedded” server but it would work nearly identically if your ran the app in a separate “bokeh serve app.py” process.

Note also that since making HTML request args available to apps, this use of bokeh.client is not even necessary to customize. If using HTML request args is acceptable, you can just put any customization data there (obviously not OK for private or sensitive things).

Code:

  from flask import Flask, render_template
  from bokeh.client import pull_session
  from bokeh.embed import server_session
  app = Flask(__name__)
  @app.route('/', methods=['GET'])
  def bkapp_page():
      session = pull_session(url="[http://localhost:5006/sliders](http://localhost:5006/sliders)")
      # Customize the session here
      session.document.roots[0].children[1].title.text = "Special Sliders For Jean-Luc"
      session.push()
      # Serve the specific customized session to viewer here
      script = server_session(None, [session.id](http://session.id), url='[http://localhost:5006/sliders](http://localhost:5006/sliders)')
      return render_template("embed.html", script=script, template="Flask")
  if __name__ == '__main__':
      app.run(port=8080)

With this template:

  <!doctype html>
  <html lang="en">
  <head>
    <meta charset="utf-8">
    <title>Embedding a Bokeh Server With {{ framework }}</title>
  </head>
  <body>
  {{ script|safe }}
  </body>
  </html>

Thanks,

Bryan

On Sep 12, 2017, at 12:28, [email protected] wrote:

https://groups.google.com/a/continuum.io/d/msg/bokeh/TtCyyKTiOIo/6UzhU0RlAwAJ

:[

On Tuesday, September 12, 2017 at 12:12:39 PM UTC-4, Jonathan Bennett wrote:

Hi All!

I’m kicking off development for a Django web application that hosts a dashboard driven by Bokeh server. Any advice is greatly appreciated . . . blogs/templates/repositories/etc.

But right now I’m pouring over the Bokeh server documentation and found a dead link in the documentation at:

http://bokeh.pydata.org/en/latest/docs/user_guide/server.html

The dead link is located where it says: "See a complete example at https://github.com/bokeh/bokeh-demos/tree/master/happiness "

Does this still exist somewhere else, or is there another template I can use as a baseline to host a bokeh server that’s called by a Django web application?

Thanks in advance . . . looking forward to becoming a Bokeh expert.

Cheers,

Jonathan

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/847c3365-b9df-496f-bcf5-ec67263bd1a0%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/AA8D758A-2F16-4A50-BC24-3BAF68255BE8%40anaconda.com.

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

Jonathan Bennett
Kono Analytics
p:
713.489.4338
w:
konoanalytics.com

I’m currently struggling to get my AWS EB application configured for facing a bokeh server + app (embedded in a larger Django app) to the internet. I’m not much help, but I’m all ears.

···

On Tuesday, September 12, 2017 at 2:11:33 PM UTC-4, Jonathan Bennett wrote:

Thanks Bryan and Kevin!! I really appreciate the responses.

I don’t really need help with Django right now (that could change, ha! And if so I’ll seek an alternative location for that help.)

What I really want to understand at the moment is the right architecture approach.

This is what I’m thinking:

  1. Use Docker to containerize my bokeh apps and serve them on AWS elastic beanstalk. expose an external port.

a) something like this: bokeh serve --allow-websocket-origin=127.0.0.1:5000 app1.py app2.py app3.py app4.py

  1. Also Launch a Django application on separate AWS elastic beanstalk instance that calls each of the apps hosted by the bokeh server
  1. Use firewalls rules in AWS so only the machines running Django can see the machines running bokeh server.

Reasoning: elastic beanstalk can scale up the bokeh server and/or the django server as needed, while keeping the bokeh server aspect relatively uncomplicated (since that’s what I know least about).

Any idea whether this a terrible idea and/or a dead end?

Cheers,

Jonathan

On Tue, Sep 12, 2017 at 12:50 PM, Bryan Van de ven [email protected] wrote:

Sorry, stated that backwards: the example code assumes you’ve run “bokeh serve sliders.py” but it could also be done embedded with a FunctionHander as described in the docs an examples/howto/server_embed

Bryan

On Sep 12, 2017, at 12:47, Bryan Van de ven [email protected] wrote:

Hi,

Unfortunately I don’t know DJango and it is simply outside my ability to scale another learning curve right now. The core, most important gist of what the old happiness example did was simply to use “bokeh.client” to create an customize sessions on a per user basis. I’ve attached a simple Flask example below that hopefully is useful to adapt. The example uses an “embedded” server but it would work nearly identically if your ran the app in a separate “bokeh serve app.py” process.

Note also that since making HTML request args available to apps, this use of bokeh.client is not even necessary to customize. If using HTML request args is acceptable, you can just put any customization data there (obviously not OK for private or sensitive things).

Code:

  from flask import Flask, render_template
  from bokeh.client import pull_session
  from bokeh.embed import server_session
  app = Flask(__name__)
  @app.route('/', methods=['GET'])
  def bkapp_page():
      session = pull_session(url="[http://localhost:5006/sliders](http://localhost:5006/sliders)")
      # Customize the session here
      session.document.roots[0].children[1].title.text = "Special Sliders For Jean-Luc"
      session.push()
      # Serve the specific customized session to viewer here
      script = server_session(None, [session.id](http://session.id), url='[http://localhost:5006/sliders](http://localhost:5006/sliders)')
      return render_template("embed.html", script=script, template="Flask")
  if __name__ == '__main__':
      app.run(port=8080)

With this template:

  <!doctype html>
  <html lang="en">
  <head>
    <meta charset="utf-8">
    <title>Embedding a Bokeh Server With {{ framework }}</title>
  </head>
  <body>
  {{ script|safe }}
  </body>
  </html>

Thanks,

Bryan

On Sep 12, 2017, at 12:28, [email protected] wrote:

https://groups.google.com/a/continuum.io/d/msg/bokeh/TtCyyKTiOIo/6UzhU0RlAwAJ

:[

On Tuesday, September 12, 2017 at 12:12:39 PM UTC-4, Jonathan Bennett wrote:

Hi All!

I’m kicking off development for a Django web application that hosts a dashboard driven by Bokeh server. Any advice is greatly appreciated . . . blogs/templates/repositories/etc.

But right now I’m pouring over the Bokeh server documentation and found a dead link in the documentation at:

http://bokeh.pydata.org/en/latest/docs/user_guide/server.html

The dead link is located where it says: "See a complete example at https://github.com/bokeh/bokeh-demos/tree/master/happiness "

Does this still exist somewhere else, or is there another template I can use as a baseline to host a bokeh server that’s called by a Django web application?

Thanks in advance . . . looking forward to becoming a Bokeh expert.

Cheers,

Jonathan

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/847c3365-b9df-496f-bcf5-ec67263bd1a0%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/AA8D758A-2F16-4A50-BC24-3BAF68255BE8%40anaconda.com.

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

Jonathan Bennett
Kono Analytics
p:
713.489.4338
w:
konoanalytics.com

That seems reasonable to start. Note that the browsers do ultimately need to make a web socket connection to the Bokeh server, so if you truly want to isolate things you might want to run behind a reverse proxy like Nginx (or maybe AWS has its own, I'm not for sure). There's docs about that in the user's guide.

Other notes:

--allow-websocket-origin tells the Bokeh server what connections to accept, specifically it states that connections with certain origins are allowed. The origin is what is in the *user's URL navigation bar*. i.e., this should be set to whatever the public address of the page that embeds the app is, not (necessarily) the address of the django server that's doing the embedding (in case they are different).

Or TLDR: if users navigate to "foo.com" to see the embedded app, then "foo.com" needs to be explicitly made an allowed origin.

Also worth mentioning that Bokeh server can be run behind a load balancer, but it's unclear to me that this kind of session customization will work without some kind of session affinity i.e. your django app pulls session "XYZ123" and makes medications, then uses "server_session" to embed that session for a user. When their browser tries to connect to that URL, the load balancer might send them to the wrong Bokeh server (the session only exists on one specific one, that the Django app happened to talk to)

That's another reason to consider HTML request args, they do not suffer from this issue. If you really need both a load balancer and bokeh.client customization, then we will probably have to look into what it will take to solve this issue. (And I will probably need help)

Thanks,

Bryan

···

On Sep 12, 2017, at 13:10, Jonathan Bennett <[email protected]> wrote:

Thanks Bryan and Kevin!! I really appreciate the responses.

I don't really need help with Django right now (that could change, ha! And if so I'll seek an alternative location for that help.)
What I really want to understand at the moment is the right architecture approach.
This is what I'm thinking:

1) Use Docker to containerize my bokeh apps and serve them on AWS elastic beanstalk. expose an external port.
    a) something like this: bokeh serve --allow-websocket-origin=127.0.0.1:5000 app1.py app2.py app3.py app4.py
2) Also Launch a Django application on separate AWS elastic beanstalk instance that calls each of the apps hosted by the bokeh server
3) Use firewalls rules in AWS so only the machines running Django can see the machines running bokeh server.

Reasoning: elastic beanstalk can scale up the bokeh server and/or the django server as needed, while keeping the bokeh server aspect relatively uncomplicated (since that's what I know least about).

Any idea whether this a terrible idea and/or a dead end?

Cheers,
Jonathan

On Tue, Sep 12, 2017 at 12:50 PM, Bryan Van de ven <[email protected]> wrote:
Sorry, stated that backwards: the example code assumes you've run "bokeh serve sliders.py" but it could also be done embedded with a FunctionHander as described in the docs an examples/howto/server_embed

Bryan

> On Sep 12, 2017, at 12:47, Bryan Van de ven <[email protected]> wrote:
>
> Hi,
>
> Unfortunately I don't know DJango and it is simply outside my ability to scale another learning curve right now. The core, most important gist of what the old happiness example did was simply to use "bokeh.client" to create an customize sessions on a per user basis. I've attached a simple Flask example below that hopefully is useful to adapt. The example uses an "embedded" server but it would work nearly identically if your ran the app in a separate "bokeh serve app.py" process.
>
> Note also that since making HTML request args available to apps, this use of bokeh.client is not even necessary to customize. If using HTML request args is acceptable, you can just put any customization data there (obviously not OK for private or sensitive things).
>
> Code:
>
> from flask import Flask, render_template
> from bokeh.client import pull_session
> from bokeh.embed import server_session
>
> app = Flask(__name__)
>
> @app.route('/', methods=['GET'])
> def bkapp_page():
> session = pull_session(url="http://localhost:5006/sliders")
>
> # Customize the session here
> session.document.roots[0].children[1].title.text = "Special Sliders For Jean-Luc"
>
> session.push()
>
> # Serve the specific customized session to viewer here
> script = server_session(None, session.id, url='http://localhost:5006/sliders')
>
> return render_template("embed.html", script=script, template="Flask")
>
> if __name__ == '__main__':
> app.run(port=8080)
>
> With this template:
>
> <!doctype html>
> <html lang="en">
> <head>
> <meta charset="utf-8">
> <title>Embedding a Bokeh Server With {{ framework }}</title>
> </head>
>
> <body>
> {{ script|safe }}
> </body>
> </html>
>
> Thanks,
>
> Bryan
>
>
>> On Sep 12, 2017, at 12:28, [email protected] wrote:
>>
>> https://groups.google.com/a/continuum.io/d/msg/bokeh/TtCyyKTiOIo/6UzhU0RlAwAJ
>>
>> :[
>>
>> On Tuesday, September 12, 2017 at 12:12:39 PM UTC-4, Jonathan Bennett wrote:
>> Hi All!
>>
>> I'm kicking off development for a Django web application that hosts a dashboard driven by Bokeh server. Any advice is greatly appreciated . . . blogs/templates/repositories/etc.
>> But right now I'm pouring over the Bokeh server documentation and found a dead link in the documentation at:
>>
>> http://bokeh.pydata.org/en/latest/docs/user_guide/server.html
>> The dead link is located where it says: "See a complete example at https://github.com/bokeh/bokeh-demos/tree/master/happiness "
>>
>> Does this still exist somewhere else, or is there another template I can use as a baseline to host a bokeh server that's called by a Django web application?
>>
>> Thanks in advance . . . looking forward to becoming a Bokeh expert.
>>
>> Cheers,
>> Jonathan
>>
>>
>> --
>> 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/847c3365-b9df-496f-bcf5-ec67263bd1a0%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/AA8D758A-2F16-4A50-BC24-3BAF68255BE8%40anaconda.com.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

--

Jonathan Bennett
Kono Analytics
p: 713.489.4338
w: konoanalytics.com
    
--
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/CA%2BF%3D8g8ZAnAcWmHJV6n-KeU3NLcopxtD2KdZNy5-32_WxLpbpw%40mail.gmail.com.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.