Bokeh app with real time update

I am new to Bokeh and want to run a Bokeh server which real time update graphs with new data. Specifically I want users to be able to go to a webpage and get a plot which updates with new data as it comes in.

I have copied the following example at bottom of message and I can run it the local machine per the directions here, http://bokeh.pydata.org/en/latest/docs/user_guide/server.html#userguide-server-output-server

However when I try to set up the server and access remotely it does not work. Note I have the ports and networking setup correct as I can use other static examples remotely but not this one.

I start the server with:

bokeh serve main.py --host 10.127.0.101:5006

Where main.py is code below and the 10.127.0.101 is the IP address of the machine I am hosting on.

If in the server window I hit “Ctrl-C” I can get the graph but no updates, I think it is locking up on the push_session() but not sure.

Does anyone have an example of how to run a similar example remotely?

Thanks

import numpy as np
from numpy import pi

from bokeh.client import push_session
from bokeh.driving import cosine
from bokeh.plotting import figure, curdoc

x = np.linspace(0, 4*pi, 80)
y = np.sin(x)

p = figure()
r1 = p.line([0, 4*pi], [-1, 1], color="firebrick")
r2 = p.line(x, y, color="navy", line_width=4)

# open a session to keep our local document in sync with server
session = push_session(curdoc())

@cosine(w=0.03)
def update(step):
    r2.data_source.data["y"] = y * step
    r2.glyph.line_alpha = 1 - 0.8 * abs(step)

curdoc().add_periodic_callback(update, 50)

session.show() # open the document in a browser

session.loop_until_closed() # run forever

I ended up remove the line:
sessions=push_session(curdoc())

and then replaced in the last two lines session with session().

The example then worked on a remote machine through server.

···

On Tue, Jun 14, 2016 at 9:19 AM, Trampas Stern [email protected] wrote:

I am new to Bokeh and want to run a Bokeh server which real time update graphs with new data. Specifically I want users to be able to go to a webpage and get a plot which updates with new data as it comes in.

I have copied the following example at bottom of message and I can run it the local machine per the directions here, http://bokeh.pydata.org/en/latest/docs/user_guide/server.html#userguide-server-output-server

However when I try to set up the server and access remotely it does not work. Note I have the ports and networking setup correct as I can use other static examples remotely but not this one.

I start the server with:

bokeh serve main.py --host 10.127.0.101:5006

Where main.py is code below and the 10.127.0.101 is the IP address of the machine I am hosting on.

If in the server window I hit “Ctrl-C” I can get the graph but no updates, I think it is locking up on the push_session() but not sure.

Does anyone have an example of how to run a similar example remotely?

Thanks

import numpy as np
from numpy import pi

from bokeh.client import push_session
from bokeh.driving import cosine
from bokeh.plotting import figure, curdoc

x = np.linspace(0, 4*pi, 80)
y = np.sin(x)

p = figure()
r1 = p.line([0, 4*pi], [-1, 1], color="firebrick")
r2 = p.line(x, y, color="navy", line_width=4)

# open a session to keep our local document in sync with server
session = push_session(curdoc())

@cosine(w=0.03)
def update(step):
    r2.data_source.data["y"] = y * step
    r2.glyph.line_alpha = 1 - 0.8 * abs(step)

curdoc().add_periodic_callback(update, 50)

session.show() # open the document in a browser

session.loop_until_closed() # run forever

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/20160f97-a5eb-4a28-b3d1-d0e10e981aa3%40continuum.io.

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

Hi,

You can drop the last two lines too, they are useless / irrelevant if you are running your script with "bokeh serve foo.py". There are two different ways of using this server that are getting mixed up here:

  http://bokeh.pydata.org/en/0.11.1/docs/user_guide/server.html#connecting-with-bokeh-client

and

  http://bokeh.pydata.org/en/0.11.1/docs/user_guide/server.html#building-bokeh-applications

What it boils down to is this:

You'd only every use bokeh.client (e.g., the "session" things) if you want to run the python code in a *separate python process*. Something like this:

  $ bokeh serve # note: no script provided

in one terminal, and

  $ python foo.py

in a different process. This mode of operation has intrinsic drawbacks, so I always recommend the "bokeh serve app.py" approach, but in that case you don't use any of the bokeh.client session calls at all.

Thanks,

Bryan

···

On Jun 16, 2016, at 5:54 AM, Trampas Stern <[email protected]> wrote:

I ended up remove the line:
sessions=push_session(curdoc())

and then replaced in the last two lines session with session().

The example then worked on a remote machine through server.

On Tue, Jun 14, 2016 at 9:19 AM, Trampas Stern <[email protected]> wrote:
I am new to Bokeh and want to run a Bokeh server which real time update graphs with new data. Specifically I want users to be able to go to a webpage and get a plot which updates with new data as it comes in.

I have copied the following example at bottom of message and I can run it the local machine per the directions here, http://bokeh.pydata.org/en/latest/docs/user_guide/server.html#userguide-server-output-server

However when I try to set up the server and access remotely it does not work. Note I have the ports and networking setup correct as I can use other static examples remotely but not this one.

I start the server with:
bokeh serve main.py --host 10.127.0.101:5006

Where main.py is code below and the 10.127.0.101 is the IP address of the machine I am hosting on.

If in the server window I hit "Ctrl-C" I can get the graph but no updates, I think it is locking up on the push_session() but not sure.

Does anyone have an example of how to run a similar example remotely?

Thanks

import numpy as np
from numpy import pi

from bokeh.client import push_session
from bokeh.driving import cosine
from bokeh.plotting import figure, curdoc

x = np.linspace(0, 4*pi, 80)
y = np.sin(x)

p = figure()
r1 = p.line([0, 4*pi], [-1, 1], color="firebrick")
r2 = p.line(x, y, color="navy", line_width=4)

# open a session to keep our local document in sync with server
session = push_session(curdoc())

@cosine(w=0.03)
def update(step):

r2.data_source.data["y"] = y * step

r2.glyph.line_alpha = 1 - 0.8 * abs(step)

curdoc().add_periodic_callback(update, 50)

session.show() # open the document in a browser

session.loop_until_closed() # run forever

--
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/20160f97-a5eb-4a28-b3d1-d0e10e981aa3%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/CADqjcygmr8pbsSyk0h3VYhLJ4n6wMARvL5i8NKJF0Ryha1fXow%40mail.gmail.com.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.