Urgent help with running bokeh sessions

How can I change the database bokeh is getting data from while bokeh serve is running? In case my Django app allows a user to select data from a different database.

I am using Django framework, MongoDB, tweeter streaming API and bokeh, I can stream the data just fine using “ColumnDataSource.patch()”, it works exactly how I want it. But for now, I have to start bokeh server on a different terminal, Django on a different terminal, and streaming script on a different terminal for them to work correctly.

The bigger issue is Users can select a topic and I have to visualize it with Bokeh using a database with a topic of interest, currently, I use “bokeh serve --allow-websocket-origin=127.0.0.1:8000 Severe.py” to run the server and I use pull_session and autoload_server to redirect to that Bokeh app.

How can I do that dynamically? my code below.

I will really appreciate your help.

#views.py
def line_chart(request):

session = pull_session(url = "http://localhost:5006/Servere")
bokeh_script=autoload_server(None,url = "http://localhost:5006/Servere", session_id= session.id)
return render(request, u'line_charts.html', {u'the_script': bokeh_script})

``

Also, I can parse the name of database like

#bokeh serve --allow-websocket-origin=127.0.0.1:8000 Severe.py args --name_of_db

``

but the new connection will be denied because there is bokeh server running already

Remember, multiple users can select two topics and I have to stream them all.

Hi

If this could be done it would also help me. But as far as i know you cannot…multiple users on the same session will share the same Bokeh state.

You will likely have to use a reverse proxy for multiple Bokeh users with different topics.

···

On Sep 26, 2017 12:36 PM, “kiluvya” [email protected] wrote:

How can I change the database bokeh is getting data from while bokeh serve is running? In case my Django app allows a user to select data from a different database.

I am using Django framework, MongoDB, tweeter streaming API and bokeh, I can stream the data just fine using “ColumnDataSource.patch()”, it works exactly how I want it. But for now, I have to start bokeh server on a different terminal, Django on a different terminal, and streaming script on a different terminal for them to work correctly.

The bigger issue is Users can select a topic and I have to visualize it with Bokeh using a database with a topic of interest, currently, I use “bokeh serve --allow-websocket-origin=127.0.0.1:8000 Severe.py” to run the server and I use pull_session and autoload_server to redirect to that Bokeh app.

How can I do that dynamically? my code below.

I will really appreciate your help.

#views.py
def line_chart(request):

session = pull_session(url = "[http://localhost:5006/Servere](http://localhost:5006/Servere)")
bokeh_script=autoload_server(None,url = "[http://localhost:5006/Servere](http://localhost:5006/Servere)", session_id= session.id)
return render(request, u'line_charts.html', {u'the_script': bokeh_script})

``

Also, I can parse the name of database like

bokeh serve --allow-websocket-origin=127.0.0.1:8000 Severe.py args --name_of_db

``

but the new connection will be denied because there is bokeh server running already

Remember, multiple users can select two topics and I have to stream them all.

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/3f88e42a-4f7a-4541-8083-520e37c0d2d0%40continuum.io.

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

I think you either have to have a single Bokeh instance and speak with it via some kind of RPC (e.g. a queue in a Redis instance) or to provide different ports for different instances.
I guess the second approach makes more sense since it’s easier to implement and you don’t show Bokeh port to your users.

Eugene

···

On Tuesday, September 26, 2017 at 11:36:48 PM UTC+7, kiluvya wrote:

How can I change the database bokeh is getting data from while bokeh serve is running? In case my Django app allows a user to select data from a different database.

I am using Django framework, MongoDB, tweeter streaming API and bokeh, I can stream the data just fine using “ColumnDataSource.patch()”, it works exactly how I want it. But for now, I have to start bokeh server on a different terminal, Django on a different terminal, and streaming script on a different terminal for them to work correctly.

The bigger issue is Users can select a topic and I have to visualize it with Bokeh using a database with a topic of interest, currently, I use “bokeh serve --allow-websocket-origin=127.0.0.1:8000 Severe.py” to run the server and I use pull_session and autoload_server to redirect to that Bokeh app.

How can I do that dynamically? my code below.

I will really appreciate your help.

#views.py
def line_chart(request):

session = pull_session(url = "[http://localhost:5006/Servere](http://localhost:5006/Servere)")
bokeh_script=autoload_server(None,url = "[http://localhost:5006/Servere](http://localhost:5006/Servere)", session_id= session.id)
return render(request, u'line_charts.html', {u'the_script': bokeh_script})

``

Also, I can parse the name of database like

bokeh serve --allow-websocket-origin=127.0.0.1:8000 Severe.py args --name_of_db

``

but the new connection will be denied because there is bokeh server running already

Remember, multiple users can select two topics and I have to stream them all.

What prevents you from creating different sessions from the same Bokeh instance? If you don’t use global state, everything should be fine.

Eugene

···

On Tuesday, September 26, 2017 at 11:44:26 PM UTC+7, Sebastian Maurice wrote:

Hi

If this could be done it would also help me. But as far as i know you cannot…multiple users on the same session will share the same Bokeh state.

You will likely have to use a reverse proxy for multiple Bokeh users with different topics.

On Sep 26, 2017 12:36 PM, “kiluvya” [email protected] wrote:

How can I change the database bokeh is getting data from while bokeh serve is running? In case my Django app allows a user to select data from a different database.

I am using Django framework, MongoDB, tweeter streaming API and bokeh, I can stream the data just fine using “ColumnDataSource.patch()”, it works exactly how I want it. But for now, I have to start bokeh server on a different terminal, Django on a different terminal, and streaming script on a different terminal for them to work correctly.

The bigger issue is Users can select a topic and I have to visualize it with Bokeh using a database with a topic of interest, currently, I use “bokeh serve --allow-websocket-origin=127.0.0.1:8000 Severe.py” to run the server and I use pull_session and autoload_server to redirect to that Bokeh app.

How can I do that dynamically? my code below.

I will really appreciate your help.

#views.py
def line_chart(request):

session = pull_session(url = "[http://localhost:5006/Servere](http://localhost:5006/Servere)")
bokeh_script=autoload_server(None,url = "[http://localhost:5006/Servere](http://localhost:5006/Servere)", session_id= session.id)
return render(request, u'line_charts.html', {u'the_script': bokeh_script})

``

Also, I can parse the name of database like

bokeh serve --allow-websocket-origin=127.0.0.1:8000 Severe.py args --name_of_db

``

but the new connection will be denied because there is bokeh server running already

Remember, multiple users can select two topics and I have to stream them all.

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/3f88e42a-4f7a-4541-8083-520e37c0d2d0%40continuum.io.

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

Eugene:

How can I do that? I have this code in my app after trying to use client sessions. By the way, I am using patch because it is a map
from bokeh.client import pull_session, push_session

session = push_session(curdoc())
def get_patch():
#getting new patches

def update():
new_data = get_patch()
source.patch(new_data)
#print(source.data)

curdoc().add_root(p)
curdoc().add_periodic_callback(update, 10000)
session.loop_until_closed()

``

I started my server with “bokeh serve”, and now when I try to access the “http://localhost:5006/Servere” from my browser, I get error 404. from Django nothing shows.

My knowledge of sessions is not adequate, what am I doing wrong?

···

On Tuesday, September 26, 2017 at 11:48:53 AM UTC-5, Eugene Pakhomov wrote:

What prevents you from creating different sessions from the same Bokeh instance? If you don’t use global state, everything should be fine.

Eugene

On Tuesday, September 26, 2017 at 11:44:26 PM UTC+7, Sebastian Maurice wrote:

Hi

If this could be done it would also help me. But as far as i know you cannot…multiple users on the same session will share the same Bokeh state.

You will likely have to use a reverse proxy for multiple Bokeh users with different topics.

On Sep 26, 2017 12:36 PM, “kiluvya” [email protected] wrote:

How can I change the database bokeh is getting data from while bokeh serve is running? In case my Django app allows a user to select data from a different database.

I am using Django framework, MongoDB, tweeter streaming API and bokeh, I can stream the data just fine using “ColumnDataSource.patch()”, it works exactly how I want it. But for now, I have to start bokeh server on a different terminal, Django on a different terminal, and streaming script on a different terminal for them to work correctly.

The bigger issue is Users can select a topic and I have to visualize it with Bokeh using a database with a topic of interest, currently, I use “bokeh serve --allow-websocket-origin=127.0.0.1:8000 Severe.py” to run the server and I use pull_session and autoload_server to redirect to that Bokeh app.

How can I do that dynamically? my code below.

I will really appreciate your help.

#views.py
def line_chart(request):

session = pull_session(url = "[http://localhost:5006/Servere](http://localhost:5006/Servere)")
bokeh_script=autoload_server(None,url = "[http://localhost:5006/Servere](http://localhost:5006/Servere)", session_id= session.id)
return render(request, u'line_charts.html', {u'the_script': bokeh_script})

``

Also, I can parse the name of database like

bokeh serve --allow-websocket-origin=127.0.0.1:8000 Severe.py args --name_of_db

``

but the new connection will be denied because there is bokeh server running already

Remember, multiple users can select two topics and I have to stream them all.

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/3f88e42a-4f7a-4541-8083-520e37c0d2d0%40continuum.io.

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

My response regarding sessions was to Sebastian. :slight_smile:

As far as I understood your problem in the initial post, you have multiple MongoDB databases where each DB is used by a different Django instance.

Since you use Bokeh inside Django, you’ll have to provide a different port to Bokeh each time you start Django process. You already should be doing so for Django since two applications can’t both be listening to the same port. So just use the same mechanism for Bokeh, where you provide port 5006.

Or did I misunderstood your problem?

Eugene

···

On Wednesday, September 27, 2017 at 12:45:36 AM UTC+7, kiluvya wrote:

Eugene:

How can I do that? I have this code in my app after trying to use client sessions. By the way, I am using patch because it is a map
from bokeh.client import pull_session, push_session

session = push_session(curdoc())
def get_patch():
#getting new patches

def update():
new_data = get_patch()
source.patch(new_data)
#print(source.data)

curdoc().add_root(p)
curdoc().add_periodic_callback(update, 10000)
session.loop_until_closed()

``

I started my server with “bokeh serve”, and now when I try to access the “http://localhost:5006/Servere” from my browser, I get error 404. from Django nothing shows.

My knowledge of sessions is not adequate, what am I doing wrong?

On Tuesday, September 26, 2017 at 11:48:53 AM UTC-5, Eugene Pakhomov wrote:

What prevents you from creating different sessions from the same Bokeh instance? If you don’t use global state, everything should be fine.

Eugene

On Tuesday, September 26, 2017 at 11:44:26 PM UTC+7, Sebastian Maurice wrote:

Hi

If this could be done it would also help me. But as far as i know you cannot…multiple users on the same session will share the same Bokeh state.

You will likely have to use a reverse proxy for multiple Bokeh users with different topics.

On Sep 26, 2017 12:36 PM, “kiluvya” [email protected] wrote:

How can I change the database bokeh is getting data from while bokeh serve is running? In case my Django app allows a user to select data from a different database.

I am using Django framework, MongoDB, tweeter streaming API and bokeh, I can stream the data just fine using “ColumnDataSource.patch()”, it works exactly how I want it. But for now, I have to start bokeh server on a different terminal, Django on a different terminal, and streaming script on a different terminal for them to work correctly.

The bigger issue is Users can select a topic and I have to visualize it with Bokeh using a database with a topic of interest, currently, I use “bokeh serve --allow-websocket-origin=127.0.0.1:8000 Severe.py” to run the server and I use pull_session and autoload_server to redirect to that Bokeh app.

How can I do that dynamically? my code below.

I will really appreciate your help.

#views.py
def line_chart(request):

session = pull_session(url = "[http://localhost:5006/Servere](http://localhost:5006/Servere)")
bokeh_script=autoload_server(None,url = "[http://localhost:5006/Servere](http://localhost:5006/Servere)", session_id= session.id)
return render(request, u'line_charts.html', {u'the_script': bokeh_script})

``

Also, I can parse the name of database like

bokeh serve --allow-websocket-origin=127.0.0.1:8000 Severe.py args --name_of_db

``

but the new connection will be denied because there is bokeh server running already

Remember, multiple users can select two topics and I have to stream them all.

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/3f88e42a-4f7a-4541-8083-520e37c0d2d0%40continuum.io.

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

Hi,

I can't really comment at length because I am at a conference all week on a demo account and have limited use of my normal laptop. But I wanted to make a few comments.

* using "push_session" to create sessions on a Bokeh server that you then run "outside" the bokeh server by updating with with "session.loop_until_closed()" is a very bad anti-pattern. Recent versions of Bokeh will warn with 10 foot high letters that this is 100% not advised for any "real" usage.

* Instead, you should create a real app that runs inside the Bokeh server, i.e. "bokeh serve app.py" or "bokeh serve app_dir/"

* If you need to, you can use pull_session to create a new session, and customize it before sending it to your users. Here is a small but complete example:

    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"\)
        session.document.roots[0].children[1].title.text = "Special Sliders For Jean-Luc"
        session.push()
        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)

* However, even this is often not necessary. You can pass HTML request arguments to "server_session", and this is often an even easier way to customize sessions. E.g. you might pass some HTML args that specify what database to connect to on an per-request basis.

* please note autoload_server is deprecated, it has been split into two simpler functions, server_document and server_session

Thanks,

Bryan

···

On Sep 26, 2017, at 13:50, Eugene Pakhomov <[email protected]> wrote:

My response regarding sessions was to Sebastian. :slight_smile:

As far as I understood your problem in the initial post, you have multiple MongoDB databases where each DB is used by a different Django instance.
Since you use Bokeh inside Django, you'll have to provide a different port to Bokeh each time you start Django process. You already should be doing so for Django since two applications can't both be listening to the same port. So just use the same mechanism for Bokeh, where you provide port 5006.
Or did I misunderstood your problem?

Eugene

On Wednesday, September 27, 2017 at 12:45:36 AM UTC+7, kiluvya wrote:
Eugene:
How can I do that? I have this code in my app after trying to use client sessions. By the way, I am using patch because it is a map
from bokeh.client import pull_session, push_session

session = push_session(curdoc())
def get_patch():
    #getting new patches

def update():
    new_data = get_patch()
    source.patch(new_data)
    #print(source.data)

curdoc().add_root(p)
curdoc().add_periodic_callback(update, 10000)
session.loop_until_closed()

I started my server with "bokeh serve", and now when I try to access the "http://localhost:5006/Servere&quot; from my browser, I get error 404. from Django nothing shows.

My knowledge of sessions is not adequate, what am I doing wrong?

On Tuesday, September 26, 2017 at 11:48:53 AM UTC-5, Eugene Pakhomov wrote:
What prevents you from creating different sessions from the same Bokeh instance? If you don't use global state, everything should be fine.

Eugene

On Tuesday, September 26, 2017 at 11:44:26 PM UTC+7, Sebastian Maurice wrote:
Hi

If this could be done it would also help me. But as far as i know you cannot...multiple users on the same session will share the same Bokeh state.
You will likely have to use a reverse proxy for multiple Bokeh users with different topics.

On Sep 26, 2017 12:36 PM, "kiluvya" <[email protected]> wrote:
How can I change the database bokeh is getting data from while bokeh serve is running? In case my Django app allows a user to select data from a different database.

I am using Django framework, MongoDB, tweeter streaming API and bokeh, I can stream the data just fine using "ColumnDataSource.patch()", it works exactly how I want it. But for now, I have to start bokeh server on a different terminal, Django on a different terminal, and streaming script on a different terminal for them to work correctly.

The bigger issue is Users can select a topic and I have to visualize it with Bokeh using a database with a topic of interest, currently, I use "bokeh serve --allow-websocket-origin=127.0.0.1:8000 Severe.py" to run the server and I use pull_session and autoload_server to redirect to that Bokeh app.

How can I do that dynamically? my code below.

I will really appreciate your help.

#views.py
def line_chart(request):
    
    session = pull_session(url = "http://localhost:5006/Servere&quot;\)
    bokeh_script=autoload_server(None,url = "http://localhost:5006/Servere&quot;, session_id=session.id)
    return render(request, u'line_charts.html', {u'the_script': bokeh_script})

Also, I can parse the name of database like
bokeh serve --allow-websocket-origin=127.0.0.1:8000 Severe.py args --name_of_db
but the new connection will be denied because there is bokeh server running already

Remember, multiple users can select two topics and I have to stream them all.

--
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 bokeh+un...@continuum.io.
To post to this group, send email to bo...@continuum.io.
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/3f88e42a-4f7a-4541-8083-520e37c0d2d0%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/4a9490c7-3e42-46ef-9ae3-dc88abaf9373%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

I have tried this example https://github.com/bokeh/bokeh/blob/master/examples/embed/animated.py, and I think it is what you are referring to, it is from bokeh.embed.

def home(request):
if request.method == ‘POST’:
form = NameForm(request.POST) # A form bound to the POST data
if form.is_valid():
search_value = form.cleaned_data[‘search’]
#cleaning code
search_value = search_value[0].upper() + search_value[1:] #mongoDB collection name. "db[search_value].find()
#???
file_request = file_html(models, resources)
return(request, file_request)

else:
    form = NameForm()
    return render(request, u'home.html', {'form': form})

``

But I am having trouble understanding how to pass the “model”.

Here is my bokeh app so far which can run by its own perfectly

from future import unicode_literals, print_function

``
import io

import os

import sys

import numpy

from bokeh.resources import CDN

from bokeh.embed import components, autoload_server, server_session

from bokeh.io import curdoc, show

from bokeh.models import ColumnDataSource, HoverTool, LogColorMapper

from bokeh.plotting import figure, show, output_file

from bokeh.layouts import column, widgetbox

from bokeh.models.widgets import Button

from bokeh.plotting import figure, curdoc

from bokeh.client import pull_session, push_session

from bokeh.sampledata.us_states import data as states

from operator import itemgetter

from bokeh.palettes import Viridis6 as palette

from pymongo import MongoClient

client = MongoClient()

db = client.tweeter

collection = db.Trump_map_data

palette.reverse()

EXCLUDED = (“ak”, “hi”, “pr”, “gu”, “vi”, “mp”, “as”)

state_ys =

state_xs =

state_names =

for k,v in states.items():

state_xs.append(numpy.array(v["lons"]))

state_ys.append(numpy.array(v["lats"]))

state_names.append(numpy.array(v["name"]))

state_ys = numpy.array(state_ys)

state_xs = numpy.array(state_xs)

state_names = numpy.array(state_names)

states_rates =

perc1 =

print(“it is running”)

result = collection.find()

for each in result:

#states_rates.append(float(each["total_sentiment"]) / each["total"] *100)

states_rates.append(76.1)

states_rates = numpy.array(states_rates)

color_mapper = LogColorMapper(palette=palette)

source = ColumnDataSource(data=

dict(x=state_xs, y=state_ys, name=state_names, rate=states_rates))

TOOLS = u’pan,wheel_zoom,reset,hover,save,box_zoom’

p = figure(title=u’ Sample Map with dummy data’, tools=TOOLS, x_range=[-180, -60], y_range=[15, 70], width=1300, height=850)

p.grid.grid_line_color = None

p.background_fill_color = “beige”

p.patches(u’x’, u’y’, source=source,

fill_color={u'field': u'rate',

u’transform’: color_mapper},

fill_alpha=0.7, line_color=u’white’, line_width=2,)

hover = p.select_one(HoverTool)

hover.point_policy = u’follow_mouse’

hover.tooltips = [(u’Name’, u’@name’), (u’Positive’, u’@rate’), (u’(Long, Lat)‘, u’($x, $y)')]

curdoc().add_root(p)

open a session which will keep our local doc in sync with server

session = push_session(curdoc())

html = “”"

%s

“”" % server_session(p, session_id=session.id, relative_urls=False)

with io.open(“animated.html”, mode=‘w+’, encoding=‘utf-8’) as f:

f.write(html)

def get_patch():

global states_rates

global state_xs

global state_ys

global state_names

result = collection.find()

temp = []

index_to_patch = []

for each in result:

	temp.append(float(each["total_sentiment"]) / each["total"] *100) 



for i in range(len(state_names)):

	if states_rates[i] != temp[i]:

		index_to_patch.append(i)

xs_ = []

ys_ = []

name_ = []

rate_ = []

for each in index_to_patch:

	xs_.append((each,state_xs[each]))

	ys_.append((each,state_ys[each]))

	name_.append((each,state_names[each]))

	rate_.append((each,states_rates[each]))

data = { "x" : xs_, 

        "y" : ys_,

        "name" : name_,

        "rate" : rate_

}

states_rates = temp

return data

def update():

print("whataaaaP")

new_data = get_patch()

source.patch(new_data)

#print(source.data)

curdoc().add_periodic_callback(update, 10000)

session.loop_until_closed() # run forever

How can I accomplish what you said using HTML request? Or a link to an example

···

On Tuesday, September 26, 2017 at 1:32:57 PM UTC-5, Bryan Van de ven wrote:

Hi,

I can’t really comment at length because I am at a conference all week on a demo account and have limited use of my normal laptop. But I wanted to make a few comments.

  • using “push_session” to create sessions on a Bokeh server that you then run “outside” the bokeh server by updating with with “session.loop_until_closed()” is a very bad anti-pattern. Recent versions of Bokeh will warn with 10 foot high letters that this is 100% not advised for any “real” usage.

  • Instead, you should create a real app that runs inside the Bokeh server, i.e. “bokeh serve app.py” or “bokeh serve app_dir/”

  • If you need to, you can use pull_session to create a new session, and customize it before sending it to your users. Here is a small but complete example:

    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)")
    
      session.document.roots[0].children[1].title.text = "Special Sliders For Jean-Luc"
    
      session.push()
    
      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)
    
  • However, even this is often not necessary. You can pass HTML request arguments to “server_session”, and this is often an even easier way to customize sessions. E.g. you might pass some HTML args that specify what database to connect to on an per-request basis.

  • please note autoload_server is deprecated, it has been split into two simpler functions, server_document and server_session

Thanks,

Bryan

On Sep 26, 2017, at 13:50, Eugene Pakhomov [email protected] wrote:

My response regarding sessions was to Sebastian. :slight_smile:

As far as I understood your problem in the initial post, you have multiple MongoDB databases where each DB is used by a different Django instance.

Since you use Bokeh inside Django, you’ll have to provide a different port to Bokeh each time you start Django process. You already should be doing so for Django since two applications can’t both be listening to the same port. So just use the same mechanism for Bokeh, where you provide port 5006.

Or did I misunderstood your problem?

Eugene

On Wednesday, September 27, 2017 at 12:45:36 AM UTC+7, kiluvya wrote:

Eugene:
How can I do that? I have this code in my app after trying to use client sessions. By the way, I am using patch because it is a map
from bokeh.client import pull_session, push_session

session = push_session(curdoc())

def get_patch():

#getting new patches

def update():

new_data = get_patch()
source.patch(new_data)
#print(source.data)

curdoc().add_root(p)

curdoc().add_periodic_callback(update, 10000)

session.loop_until_closed()

I started my server with “bokeh serve”, and now when I try to access the “http://localhost:5006/Servere” from my browser, I get error 404. from Django nothing shows.

My knowledge of sessions is not adequate, what am I doing wrong?

On Tuesday, September 26, 2017 at 11:48:53 AM UTC-5, Eugene Pakhomov wrote:

What prevents you from creating different sessions from the same Bokeh instance? If you don’t use global state, everything should be fine.

Eugene

On Tuesday, September 26, 2017 at 11:44:26 PM UTC+7, Sebastian Maurice wrote:

Hi

If this could be done it would also help me. But as far as i know you cannot…multiple users on the same session will share the same Bokeh state.

You will likely have to use a reverse proxy for multiple Bokeh users with different topics.

On Sep 26, 2017 12:36 PM, “kiluvya” [email protected] wrote:

How can I change the database bokeh is getting data from while bokeh serve is running? In case my Django app allows a user to select data from a different database.

I am using Django framework, MongoDB, tweeter streaming API and bokeh, I can stream the data just fine using “ColumnDataSource.patch()”, it works exactly how I want it. But for now, I have to start bokeh server on a different terminal, Django on a different terminal, and streaming script on a different terminal for them to work correctly.

The bigger issue is Users can select a topic and I have to visualize it with Bokeh using a database with a topic of interest, currently, I use “bokeh serve --allow-websocket-origin=127.0.0.1:8000 Severe.py” to run the server and I use pull_session and autoload_server to redirect to that Bokeh app.

How can I do that dynamically? my code below.

I will really appreciate your help.

#views.py

def line_chart(request):

session = pull_session(url = "[http://localhost:5006/Servere](http://localhost:5006/Servere)")
bokeh_script=autoload_server(None,url = "[http://localhost:5006/Servere](http://localhost:5006/Servere)", session_id=[session.id](http://session.id))
return render(request, u'line_charts.html', {u'the_script': bokeh_script})

Also, I can parse the name of database like

bokeh serve --allow-websocket-origin=127.0.0.1:8000 Severe.py args --name_of_db

but the new connection will be denied because there is bokeh server running already

Remember, multiple users can select two topics and I have to stream them all.


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/3f88e42a-4f7a-4541-8083-520e37c0d2d0%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/4a9490c7-3e42-46ef-9ae3-dc88abaf9373%40continuum.io.

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