Plot on different documents at the same time

Hi,

I am trying to publish on the same webpage multiple documents that I want to be able to update as new data arrive.

I have multiple object that receive and parse data, and each one should be able to create new charts in its own document.

I am able to create new documents, create charts in them and push them on the website, but then I cannot interact with the documents anymore.

What I do to create them is to start a new session each time:

self.session = Session(
name=self.doc_name, root_url=self.server_url,
load_from_config=False)

output_server(self.doc_name, session=self.session, clear=False)

then I can create figures and push them online:

fig = figure(title=key, plot_width=1000)
fig.quad(top=std_hist_top, bottom=std_hist_bottom,
left=[el + 0.47 for el in range(nhid)],
right=[el + 0.53 for el in range(nhid)],
fill_color=‘black’, line_color=“black”)
push()

But once another object creates a second session for a second document, the first object cannot modify (add new charts or add new data to existing charts) the first document anymore.

As far as I understood the session represents only the connection to the server, which in my case could be shared among the data parsing objects.

I tried to share the same session among the objects, but in this case I don’t know how to create a new document anymore.

This is what I did:

self.session = cursession()
bokeh.plotting._default_document = Document()
self.document = curdoc()
fig = figure(title=key, plot_width=1000)
fig.quad(top=std_hist_top, bottom=std_hist_bottom,
left=[el + 0.47 for el in range(nhid)],
right=[el + 0.53 for el in range(nhid)],
fill_color=‘black’, line_color=“black”)
push(session=self.session, document=self.document)

With this code I am not able anymore to create new documents online (it seems like the Document I am writing in is an object not linked to any session/server) and somewhere in the execution I get JSON errors (No JSON object could be decoded).

Any help would be much appreciated.

Thank you

…anybody? :slight_smile:

I will try to rephrase and summarize my questions.

Is it possible to push different plots to different documents?

Say I have 2 documents, Doc_a and Doc_b. What I would like to do is to push a Figure containing some Lines to Doc_a, then push an Histogram to Doc_b, then add some lines to the Figure in Doc_a.

Is it possible? If so, how should I do it?

Thank you in advance for your help.

Hi fvisin,

I think you want to use Session.use_doc:

  http://bokeh.pydata.org/en/latest/docs/reference/plot_objects.html#bokeh.session.Session.use_doc

to configure the Session with the correct document (on the server) before each push. Please let me know if that does not work I will ping some other folks to chime in.

Thanks,

Bryan

···

On Mar 23, 2015, at 11:55 AM, [email protected] wrote:

....anybody? :slight_smile:

I will try to rephrase and summarize my questions.
Is it possible to push different plots to different documents?
Say I have 2 documents, Doc_a and Doc_b. What I would like to do is to push a Figure containing some Lines to Doc_a, then push an Histogram to Doc_b, then add some lines to the Figure in Doc_a.
Is it possible? If so, how should I do it?

Thank you in advance for your help.

--
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/856558a1-ed60-433c-9880-95ca757c8686%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

Hi Bryan,

thank you for your answer.

I tried what you suggest, but I can’t get it to publish.

What I am doing is:

Session(root_url=self.server_url, load_from_config=False)
self.session.use_doc(‘A doc name’)

fig = figure(title=key)
fig.quad(top=data, bottom=0, left=left, right=right, fill_color=‘#66E066’, line_color=“black”)
self.session.store_objects(fig)
self.session.publish()

I also tried push(session=self.session) without any effect.

···

Il giorno martedì 24 marzo 2015 09:04:41 UTC-4, Bryan Van de ven ha scritto:

Hi fvisin,

I think you want to use Session.use_doc:

    [http://bokeh.pydata.org/en/latest/docs/reference/plot_objects.html#bokeh.session.Session.use_doc](http://bokeh.pydata.org/en/latest/docs/reference/plot_objects.html#bokeh.session.Session.use_doc)

to configure the Session with the correct document (on the server) before each push. Please let me know if that does not work I will ping some other folks to chime in.

Thanks,

Bryan

On Mar 23, 2015, at 11:55 AM, [email protected] wrote:

…anybody? :slight_smile:

I will try to rephrase and summarize my questions.

Is it possible to push different plots to different documents?

Say I have 2 documents, Doc_a and Doc_b. What I would like to do is to push a Figure containing some Lines to Doc_a, then push an Histogram to Doc_b, then add some lines to the Figure in Doc_a.

Is it possible? If so, how should I do it?

Thank you in advance for your help.


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/856558a1-ed60-433c-9880-95ca757c8686%40continuum.io.

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

I’m sorry I don’t have more time to reply today, and I haven’t looked into your issue carefully, so apologies in advance if this is garbage,

but in this rough area I found looking at https://github.com/bokeh/bokeh/blob/master/bokeh/pluginutils.py

useful in the past. I’m wondering whether you need something like:

document.add(obj)
session.store_document(document)

bird

···

On Tue, Mar 24, 2015 at 9:27 AM, [email protected] wrote:

Hi Bryan,

thank you for your answer.

I tried what you suggest, but I can’t get it to publish.

What I am doing is:

Session(root_url=self.server_url, load_from_config=False)
self.session.use_doc(‘A doc name’)

fig = figure(title=key)
fig.quad(top=data, bottom=0, left=left, right=right, fill_color=‘#66E066’, line_color=“black”)
self.session.store_objects(fig)
self.session.publish()

I also tried push(session=self.session) without any effect.

Il giorno martedì 24 marzo 2015 09:04:41 UTC-4, Bryan Van de ven ha scritto:

Hi fvisin,

I think you want to use Session.use_doc:

    [http://bokeh.pydata.org/en/latest/docs/reference/plot_objects.html#bokeh.session.Session.use_doc](http://bokeh.pydata.org/en/latest/docs/reference/plot_objects.html#bokeh.session.Session.use_doc)

to configure the Session with the correct document (on the server) before each push. Please let me know if that does not work I will ping some other folks to chime in.

Thanks,

Bryan

On Mar 23, 2015, at 11:55 AM, [email protected] wrote:

…anybody? :slight_smile:

I will try to rephrase and summarize my questions.

Is it possible to push different plots to different documents?

Say I have 2 documents, Doc_a and Doc_b. What I would like to do is to push a Figure containing some Lines to Doc_a, then push an Histogram to Doc_b, then add some lines to the Figure in Doc_a.

Is it possible? If so, how should I do it?

Thank you in advance for your help.


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/856558a1-ed60-433c-9880-95ca757c8686%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/4ee1fcea-ad6f-4218-a0e6-f3ec3faae8c8%40continuum.io.

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

Hi Sarah,

thank you for your help!

I followed your suggestion, but I am still not able to plot anything.

I then tried to use output_server in conjunction with document.add(). At the first iteration I can plot both graphs, but at the second iteration I get this error on the bokeh-server:

DataIntegrityException: too many plot contexts found

and this error on the script:

ValueError: No JSON object could be decoded

I am afraid I am lost on many points here, and the documentation and the code examples are not helping:

  • is the Session related to a specific Document or not?

  • is output_server() the only way to push data to the server?

  • if not, which other ways to do it exist? can you provide a minimal code snippet to explain how to use them?

  • do push() and show() only work in case output_server() is being used?

  • when does session.publish() work?

  • when should session.store_objects() be used?

Thank you for any insight.

Francesco

···

Il giorno martedì 24 marzo 2015 13:06:56 UTC-4, Sarah Bird ha scritto:

I’m sorry I don’t have more time to reply today, and I haven’t looked into your issue carefully, so apologies in advance if this is garbage,

but in this rough area I found looking at https://github.com/bokeh/bokeh/blob/master/bokeh/pluginutils.py

useful in the past. I’m wondering whether you need something like:

document.add(obj)
session.store_document(document)

bird

On Tue, Mar 24, 2015 at 9:27 AM, [email protected] wrote:

Hi Bryan,

thank you for your answer.

I tried what you suggest, but I can’t get it to publish.

What I am doing is:

Session(root_url=self.server_url, load_from_config=False)
self.session.use_doc(‘A doc name’)

fig = figure(title=key)
fig.quad(top=data, bottom=0, left=left, right=right, fill_color=‘#66E066’, line_color=“black”)
self.session.store_objects(fig)
self.session.publish()

I also tried push(session=self.session) without any effect.

Il giorno martedì 24 marzo 2015 09:04:41 UTC-4, Bryan Van de ven ha scritto:

Hi fvisin,

I think you want to use Session.use_doc:

    [http://bokeh.pydata.org/en/latest/docs/reference/plot_objects.html#bokeh.session.Session.use_doc](http://bokeh.pydata.org/en/latest/docs/reference/plot_objects.html#bokeh.session.Session.use_doc)

to configure the Session with the correct document (on the server) before each push. Please let me know if that does not work I will ping some other folks to chime in.

Thanks,

Bryan

On Mar 23, 2015, at 11:55 AM, [email protected] wrote:

…anybody? :slight_smile:

I will try to rephrase and summarize my questions.

Is it possible to push different plots to different documents?

Say I have 2 documents, Doc_a and Doc_b. What I would like to do is to push a Figure containing some Lines to Doc_a, then push an Histogram to Doc_b, then add some lines to the Figure in Doc_a.

Is it possible? If so, how should I do it?

Thank you in advance for your help.


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/856558a1-ed60-433c-9880-95ca757c8686%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/4ee1fcea-ad6f-4218-a0e6-f3ec3faae8c8%40continuum.io.

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

Hi Francesco,

Hi Sarah,

thank you for your help!

I followed your suggestion, but I am still not able to plot anything.

I then tried to use output_server in conjunction with document.add(). At the first iteration I can plot both graphs, but at the second iteration I get this error on the bokeh-server:

DataIntegrityException: too many plot contexts found

and this error on the script:

ValueError: No JSON object could be decoded

Could you provide the full code (or something similar) that we can try to work around and simulate the errors you are getting?

Is it the same error of this https://github.com/bokeh/bokeh/issues/1992?

I am afraid I am lost on many points here, and the documentation and the code examples are not helping:

  • is the Session related to a specific Document or not?

No. Session provides a live connection to bokeh server. You can use this session to access (create/load, etc…) any document stored on the server.

  • is output_server() the only way to push data to the server?

No. You can use the Session and document objects directly. You can check one of the glyphs server examples (for instance this one)

  • if not, which other ways to do it exist? can you provide a minimal code snippet to explain how to use them?

Again, if you can provide the code that is failing for you it’s easier to start…

  • do push() and show() only work in case output_server() is being used?

No. You can use push explicitly with a session and a document… As for show, it depends on which of the output methods (output_notebook, output_file, output_server) you are calling first…

  • when does session.publish() work?

Sorry. I can’t understand you question… can you elaborate?

  • when should session.store_objects() be used?

When you want to store specific objects to the server :slight_smile:

For instance… let’s say you have just stored a document with all it’s related objects (plot, ranges, sources, etc…)… after some computation you want to just update the source as that’s the only part of the plot that actually has changed (so let’s say you want thus animate your plot)… You do it by just calling session.store_objects(your_source). See the line_animate.py example for instance…

Thanks.

···

On Tuesday, March 24, 2015 at 9:37:42 PM UTC+1, [email protected] wrote:

Thank you for any insight.

Francesco

Il giorno martedì 24 marzo 2015 13:06:56 UTC-4, Sarah Bird ha scritto:

I’m sorry I don’t have more time to reply today, and I haven’t looked into your issue carefully, so apologies in advance if this is garbage,

but in this rough area I found looking at https://github.com/bokeh/bokeh/blob/master/bokeh/pluginutils.py

useful in the past. I’m wondering whether you need something like:

document.add(obj)
session.store_document(document)

bird

On Tue, Mar 24, 2015 at 9:27 AM, [email protected] wrote:

Hi Bryan,

thank you for your answer.

I tried what you suggest, but I can’t get it to publish.

What I am doing is:

Session(root_url=self.server_url, load_from_config=False)
self.session.use_doc(‘A doc name’)

fig = figure(title=key)
fig.quad(top=data, bottom=0, left=left, right=right, fill_color=‘#66E066’, line_color=“black”)
self.session.store_objects(fig)
self.session.publish()

I also tried push(session=self.session) without any effect.

Il giorno martedì 24 marzo 2015 09:04:41 UTC-4, Bryan Van de ven ha scritto:

Hi fvisin,

I think you want to use Session.use_doc:

    [http://bokeh.pydata.org/en/latest/docs/reference/plot_objects.html#bokeh.session.Session.use_doc](http://bokeh.pydata.org/en/latest/docs/reference/plot_objects.html#bokeh.session.Session.use_doc)

to configure the Session with the correct document (on the server) before each push. Please let me know if that does not work I will ping some other folks to chime in.

Thanks,

Bryan

On Mar 23, 2015, at 11:55 AM, [email protected] wrote:

…anybody? :slight_smile:

I will try to rephrase and summarize my questions.

Is it possible to push different plots to different documents?

Say I have 2 documents, Doc_a and Doc_b. What I would like to do is to push a Figure containing some Lines to Doc_a, then push an Histogram to Doc_b, then add some lines to the Figure in Doc_a.

Is it possible? If so, how should I do it?

Thank you in advance for your help.


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/856558a1-ed60-433c-9880-95ca757c8686%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/4ee1fcea-ad6f-4218-a0e6-f3ec3faae8c8%40continuum.io.

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

Hi Fabio,

thank you for your answers, I am beginning to have a clearer picture!

Is it the same error of this Issues with curdoc() on a slow redis connection ?? · Issue #1992 · bokeh/bokeh · GitHub?

It doesn't seem related to the rate I push data (which is low), so I don't
think it's the same issue. Anyway, I tried implementing his solution but
that didn't solve the problem.

As you suggested I attach my code so that we can have on a common ground.
*plot.py* is the code I was using before your post and *plot_updated.py *is
the one I just modified to try to mimic the glyphs server example (which is
not publishing anything).

In both cases I am using a Plot object and a PlotHistogram object together
in a main script. Unfortunately the attached code cannot be executed
standalone, but it should be enough to understand what I am doing.

Thank you very much for your help!

Francesco

plot.py (8.91 KB)

plot_updated.py (9.39 KB)

Hi again,

When I was digging deep into specifying how I wanted to work with sessions and documents i got a DataIntegrityException too!

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

It was ( I swear!! ) totally reproduceable, and when I came back to it the other day, I just couldn’t reproduce it any more!

On that issue you can see my version of the decorator that I use for my own needs - I have no idea if this will help you. I wish I could reproduce my old DataIntegrity issue.

I can maybe tell you one useful thing though.

My experience with “ValueError: No JSON object could be decoded” - it’s probably not what you think. My experience tracing back is that it’s a 500 error from the server and the No JSON … is just because there’s no JSON in the 500. My usual source of 500’s with the server is when I’ve customized an app and haven’t given the server the correct set of instructions.

In case it’s useful, I’m going to be giving a talk at PyCon (which will also be online shortly after) - https://us.pycon.org/2015/schedule/presentation/369/ - where I’m going to try and explain how I’ve ended up tackling these things.

I’m sorry I don’t have more answers right now.

Bird

···

On Tue, Mar 24, 2015 at 2:51 PM, Francesco Visin [email protected] wrote:

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/CACu_wROYDstvyF2fT5npFNyGoQF7bd39evszpTWvxsa%3D2Dk9sg%40mail.gmail.com.

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

Hi Fabio,

thank you for your answers, I am beginning to have a clearer picture!

Is it the same error of this https://github.com/bokeh/bokeh/issues/1992?

It doesn’t seem related to the rate I push data (which is low), so I don’t think it’s the same issue. Anyway, I tried implementing his solution but that didn’t solve the problem.

As you suggested I attach my code so that we can have on a common ground.

plot.py is the code I was using before your post and plot_updated.py is the one I just modified to try to mimic the glyphs server example (which is not publishing anything).

In both cases I am using a Plot object and a PlotHistogram object together in a main script. Unfortunately the attached code cannot be executed standalone, but it should be enough to understand what I am doing.

Thank you very much for your help!

Francesco

Hi Francesco,

Thanks. I’ll try to take a better look later today and let you know (sorry, quite busy day).

Regarding the “ValueError” you mentioned, @sarah is right (thanks once again Sarah :slight_smile: ). It’s not useful and is quite generic error on the server side as consequence of something happening elsewhere.

One quick question in the meanwhile. Do you scripts work ok with static html files (without using bokeh-server)?

thanks

Fabio

···

On Tuesday, March 24, 2015 at 10:51:33 PM UTC+1, Francesco Visin wrote:

Hi Fabio,

thank you for your answers, I am beginning to have a clearer picture!

Is it the same error of this https://github.com/bokeh/bokeh/issues/1992?

It doesn’t seem related to the rate I push data (which is low), so I don’t think it’s the same issue. Anyway, I tried implementing his solution but that didn’t solve the problem.

As you suggested I attach my code so that we can have on a common ground.

plot.py is the code I was using before your post and plot_updated.py is the one I just modified to try to mimic the glyphs server example (which is not publishing anything).

In both cases I am using a Plot object and a PlotHistogram object together in a main script. Unfortunately the attached code cannot be executed standalone, but it should be enough to understand what I am doing.

Thank you very much for your help!

Francesco

Ok - this is unfortunately quite confusing at the moment, I’ve thought about how we should fix the API but we havne’t done anything around it.

A session starts out unassociated with a document, but after calling use_doc, it becomes associated with a specific document. I’m not sure if it can be used with other documents or not after that point - it’s not tested, and I would not be that suprised if it was broken (though we should be able to make it work better)

session.publish is used for setting permissions on the bokeh server to put the document in public mode (so everyone can view it) If you’re running in single user mode (which you probably are) Then this isn’t important

···

On Tue, Mar 24, 2015 at 5:25 PM, Fabio Pliger [email protected] wrote:

Hi Francesco,

On Tuesday, March 24, 2015 at 9:37:42 PM UTC+1, [email protected] wrote:

Hi Sarah,

thank you for your help!

I followed your suggestion, but I am still not able to plot anything.

I then tried to use output_server in conjunction with document.add(). At the first iteration I can plot both graphs, but at the second iteration I get this error on the bokeh-server:

DataIntegrityException: too many plot contexts found

and this error on the script:

ValueError: No JSON object could be decoded

Could you provide the full code (or something similar) that we can try to work around and simulate the errors you are getting?

Is it the same error of this https://github.com/bokeh/bokeh/issues/1992?

I am afraid I am lost on many points here, and the documentation and the code examples are not helping:

  • is the Session related to a specific Document or not?

No. Session provides a live connection to bokeh server. You can use this session to access (create/load, etc…) any document stored on the server.

  • is output_server() the only way to push data to the server?

No. You can use the Session and document objects directly. You can check one of the glyphs server examples (for instance this one)

  • if not, which other ways to do it exist? can you provide a minimal code snippet to explain how to use them?

Again, if you can provide the code that is failing for you it’s easier to start…

  • do push() and show() only work in case output_server() is being used?

No. You can use push explicitly with a session and a document… As for show, it depends on which of the output methods (output_notebook, output_file, output_server) you are calling first…

  • when does session.publish() work?

Sorry. I can’t understand you question… can you elaborate?

  • when should session.store_objects() be used?

When you want to store specific objects to the server :slight_smile:

For instance… let’s say you have just stored a document with all it’s related objects (plot, ranges, sources, etc…)… after some computation you want to just update the source as that’s the only part of the plot that actually has changed (so let’s say you want thus animate your plot)… You do it by just calling session.store_objects(your_source). See the line_animate.py example for instance…

Thanks.

Thank you for any insight.

Francesco

Il giorno martedì 24 marzo 2015 13:06:56 UTC-4, Sarah Bird ha scritto:

I’m sorry I don’t have more time to reply today, and I haven’t looked into your issue carefully, so apologies in advance if this is garbage,

but in this rough area I found looking at https://github.com/bokeh/bokeh/blob/master/bokeh/pluginutils.py

useful in the past. I’m wondering whether you need something like:

document.add(obj)
session.store_document(document)

bird

On Tue, Mar 24, 2015 at 9:27 AM, [email protected] wrote:

Hi Bryan,

thank you for your answer.

I tried what you suggest, but I can’t get it to publish.

What I am doing is:

Session(root_url=self.server_url, load_from_config=False)
self.session.use_doc(‘A doc name’)

fig = figure(title=key)
fig.quad(top=data, bottom=0, left=left, right=right, fill_color=‘#66E066’, line_color=“black”)
self.session.store_objects(fig)
self.session.publish()

I also tried push(session=self.session) without any effect.

Il giorno martedì 24 marzo 2015 09:04:41 UTC-4, Bryan Van de ven ha scritto:

Hi fvisin,

I think you want to use Session.use_doc:

    [http://bokeh.pydata.org/en/latest/docs/reference/plot_objects.html#bokeh.session.Session.use_doc](http://bokeh.pydata.org/en/latest/docs/reference/plot_objects.html#bokeh.session.Session.use_doc)

to configure the Session with the correct document (on the server) before each push. Please let me know if that does not work I will ping some other folks to chime in.

Thanks,

Bryan

On Mar 23, 2015, at 11:55 AM, [email protected] wrote:

…anybody? :slight_smile:

I will try to rephrase and summarize my questions.

Is it possible to push different plots to different documents?

Say I have 2 documents, Doc_a and Doc_b. What I would like to do is to push a Figure containing some Lines to Doc_a, then push an Histogram to Doc_b, then add some lines to the Figure in Doc_a.

Is it possible? If so, how should I do it?

Thank you in advance for your help.


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/856558a1-ed60-433c-9880-95ca757c8686%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/4ee1fcea-ad6f-4218-a0e6-f3ec3faae8c8%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/48053590-182e-46b9-bcf4-80abf428ded9%40continuum.io.

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

Hi Francesco,

I’ve taken a quick look at your code. As Hugo already mentioned the single session seems to not be very happy when you call it with other documents. So you actually should create a separate sessions per document. Also, I’ve seen that you seem to be re-storing the entire document when you update just one value (inside the do method). That is not convenient and you can just store the plot source.

One thing that I didn’t ask before was if the code fails when you create the plot or when it updates the plot with new data. If it’s when you create the plot, have you actually tried to check if you code generate static plots correctly?

Anyway, I’m posting a code here with 2 plots being live updated at the same time on bokeh-server.

import time

import numpy as np

from bokeh.plotting import *

N = 80

x = np.linspace(0, 4*np.pi, N)

y = np.sin(x)

yy = np.cos(x)

session1 = Session()

session2 = Session()

output_server(‘sindoc’, session=session1)

p = figure()

p.line(x, y, color=“#3333ee”, name=“sin”)

p.line([0,4*np.pi], [-1, 1], color=“#ee3333”)

renderer = p.select(dict(name=“sin”))

ds = renderer[0].data_source

show(p)

output_server(‘cosdoc’, session=session2)

pp = figure()

pp.line(x, yy, color=“#3333ee”, name=“cos”)

renderer = pp.select(dict(name=“cos”))

dds = renderer[0].data_source

show(pp)

while True:

for i in np.hstack((np.linspace(1, -1, 100), np.linspace(-1, 1, 100))):

ds.data[“y”] = y * i

dds.data[“y”] = y * i
# just update the data source on the server

session1.store_objects(ds)

session2.store_objects(dds)

time.sleep(0.05)

``

This is just a simple example but should give you an idea of the pattern. Please let me know if it helps…

Cheers

Fabio

···

On Wednesday, March 25, 2015 at 2:40:15 PM UTC+1, Hugo Shi wrote:

Ok - this is unfortunately quite confusing at the moment, I’ve thought about how we should fix the API but we havne’t done anything around it.

A session starts out unassociated with a document, but after calling use_doc, it becomes associated with a specific document. I’m not sure if it can be used with other documents or not after that point - it’s not tested, and I would not be that suprised if it was broken (though we should be able to make it work better)

session.publish is used for setting permissions on the bokeh server to put the document in public mode (so everyone can view it) If you’re running in single user mode (which you probably are) Then this isn’t important

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/48053590-182e-46b9-bcf4-80abf428ded9%40continuum.io.

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

Thank you all for your answers!

**@Sarah: **

Good to know, thank you. Right now I am working on a local network, but still there might be some problem accessing the server especially when the request rate is high. This doesn’t seem my case right now, but as Fabio suggested I can try with a static html page to exclude a variable.

**@Fabio: **

  • I didn’t try without the bokeh-server, I will and let you know.
  • I tried running your script instead and I have problems with that too: the graphs are displayed but they are almost never updated. What I mean is that in several minutes I have seen them move once, while looking at the log, the script was sending new data approximately at the expected rate (~0.5 sec) and the server, apparently, was receiving POST connections.
  • What do you mean by “you seem to be re-storing the entire document when you update just one value”? Do you refer to the push(session=self.session) in Plot.do()?

I have a couple of follow up questions:

  • Is using push(p) instead of show(p) the right way to avoid bokeh opening a browser window each time a session is created?
  • If I am correct, you only need to call push/show once, when you create the session. After that it suffices to callsession.store_objects() to update the plots. Can you confirm?
  • Is there a way to remove an object (plot, figure, chart, line, …) from a document once it has been pushed?

**@Hugo: **

Thank you for your explanation of session.publish, as you hypothesized I don’t need it. I agree with you that coupling a session and a document doesn’t seem to be the right way to go, but I can imagine that a project in rapid evolution such as Bokeh needs some refactoring from time to time as new things pop out. :slight_smile:

Thank you all again for your help!

···

Francesco

On Wed, Mar 25, 2015 at 12:23 PM, Fabio Pliger [email protected] wrote:

Hi Francesco,

I’ve taken a quick look at your code. As Hugo already mentioned the single session seems to not be very happy when you call it with other documents. So you actually should create a separate sessions per document. Also, I’ve seen that you seem to be re-storing the entire document when you update just one value (inside the do method). That is not convenient and you can just store the plot source.

One thing that I didn’t ask before was if the code fails when you create the plot or when it updates the plot with new data. If it’s when you create the plot, have you actually tried to check if you code generate static plots correctly?

Anyway, I’m posting a code here with 2 plots being live updated at the same time on bokeh-server.

import time

import numpy as np

from bokeh.plotting import *

N = 80

x = np.linspace(0, 4*np.pi, N)

y = np.sin(x)

yy = np.cos(x)

session1 = Session()

session2 = Session()

output_server(‘sindoc’, session=session1)

p = figure()

p.line(x, y, color=“#3333ee”, name=“sin”)

p.line([0,4*np.pi], [-1, 1], color=“#ee3333”)

renderer = p.select(dict(name=“sin”))

ds = renderer[0].data_source

show(p)

output_server(‘cosdoc’, session=session2)

pp = figure()

pp.line(x, yy, color=“#3333ee”, name=“cos”)

renderer = pp.select(dict(name=“cos”))

dds = renderer[0].data_source

show(pp)

while True:

for i in np.hstack((np.linspace(1, -1, 100), np.linspace(-1, 1, 100))):

ds.data[“y”] = y * i

dds.data[“y”] = y * i
# just update the data source on the server

session1.store_objects(ds)

session2.store_objects(dds)

time.sleep(0.05)

``

This is just a simple example but should give you an idea of the pattern. Please let me know if it helps…

Cheers

Fabio

On Wednesday, March 25, 2015 at 2:40:15 PM UTC+1, Hugo Shi wrote:

Ok - this is unfortunately quite confusing at the moment, I’ve thought about how we should fix the API but we havne’t done anything around it.

A session starts out unassociated with a document, but after calling use_doc, it becomes associated with a specific document. I’m not sure if it can be used with other documents or not after that point - it’s not tested, and I would not be that suprised if it was broken (though we should be able to make it work better)

session.publish is used for setting permissions on the bokeh server to put the document in public mode (so everyone can view it) If you’re running in single user mode (which you probably are) Then this isn’t important

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/48053590-182e-46b9-bcf4-80abf428ded9%40continuum.io.

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

On Wed, Mar 25, 2015 at 12:23 PM, Fabio Pliger [email protected] wrote:

Hi Francesco,

I’ve taken a quick look at your code. As Hugo already mentioned the single session seems to not be very happy when you call it with other documents. So you actually should create a separate sessions per document. Also, I’ve seen that you seem to be re-storing the entire document when you update just one value (inside the do method). That is not convenient and you can just store the plot source.

One thing that I didn’t ask before was if the code fails when you create the plot or when it updates the plot with new data. If it’s when you create the plot, have you actually tried to check if you code generate static plots correctly?

Anyway, I’m posting a code here with 2 plots being live updated at the same time on bokeh-server.

import time

import numpy as np

from bokeh.plotting import *

N = 80

x = np.linspace(0, 4*np.pi, N)

y = np.sin(x)

yy = np.cos(x)

session1 = Session()

session2 = Session()

output_server(‘sindoc’, session=session1)

p = figure()

p.line(x, y, color=“#3333ee”, name=“sin”)

p.line([0,4*np.pi], [-1, 1], color=“#ee3333”)

renderer = p.select(dict(name=“sin”))

ds = renderer[0].data_source

show(p)

output_server(‘cosdoc’, session=session2)

pp = figure()

pp.line(x, yy, color=“#3333ee”, name=“cos”)

renderer = pp.select(dict(name=“cos”))

dds = renderer[0].data_source

show(pp)

while True:

for i in np.hstack((np.linspace(1, -1, 100), np.linspace(-1, 1, 100))):

ds.data[“y”] = y * i

dds.data[“y”] = y * i
# just update the data source on the server

session1.store_objects(ds)

session2.store_objects(dds)

time.sleep(0.05)

``

This is just a simple example but should give you an idea of the pattern. Please let me know if it helps…

Cheers

Fabio

On Wednesday, March 25, 2015 at 2:40:15 PM UTC+1, Hugo Shi wrote:

Ok - this is unfortunately quite confusing at the moment, I’ve thought about how we should fix the API but we havne’t done anything around it.

A session starts out unassociated with a document, but after calling use_doc, it becomes associated with a specific document. I’m not sure if it can be used with other documents or not after that point - it’s not tested, and I would not be that suprised if it was broken (though we should be able to make it work better)

session.publish is used for setting permissions on the bokeh server to put the document in public mode (so everyone can view it) If you’re running in single user mode (which you probably are) Then this isn’t important

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/48053590-182e-46b9-bcf4-80abf428ded9%40continuum.io.

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

Francesco

Apparently I was able to solve the *very slow plot problem* by deleting a

bunch of bokeh.* files (specifically bokeh.{data, server, sets}.{bak, dat,
dir}) in the directory I run the server from. I will now try to change my
script according to the example by Fabio.

In the meanwhile, I have a couple of questions in addition to my previous
ones:

   - How is defined the relationship between *output_server* and *push() */
   *show(p)*? Can you please confirm what I understood so far:
      - show() and push() work almost in the same way. With *push()* one
      *can* (optionally) specify the session and the document, but not which
      specific object to push, while with *show() *one can specify which
      specific object you want to show, but not where (meaning in which
      session/document).
      - Whatever "*plottable object"*(only figure?) is defined in the
      middle between *output_server(session=my_session) *and* push() *will
      be pushed, along with all its subobjects to *my_session *when push()
      is called.
      - What happens if I call push(*session=my_other_session*)?

Finally, I noticed a typo in my previous email: in the first question,
*push(p)* should be* push()*.

I will let you know if I manage to modify my original script into something
working.
Thank you for your help and patience!

Francesco

show and push are mostly the same - except that show opens stuff in a browser (and push does not)

show and push should take as a parameter the things to push/show, however I believe currently for the server backend, this is broken, and we just push the document’s context

···

On Wed, Mar 25, 2015 at 5:13 PM, Francesco Visin [email protected] wrote:

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/CACu_wRN-1_kJu_Aks0%3DgfWQHAK-z7_Ba%3DAPPJW8_drKg8Xrm%3Dg%40mail.gmail.com.

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

Apparently I was able to solve the very slow plot problem by deleting a bunch of bokeh.* files (specifically bokeh.{data, server, sets}.{bak, dat, dir}) in the directory I run the server from. I will now try to change my script according to the example by Fabio.

In the meanwhile, I have a couple of questions in addition to my previous ones:

  • How is defined the relationship between output_server and *push() */ show(p)? Can you please confirm what I understood so far:
  • show() and push() work almost in the same way. With push() one can (optionally) specify the session and the document, but not which specific object to push, while with show() one can specify which specific object you want to show, but not where (meaning in which session/document).
  • Whatever "plottable object"(only figure?)**is defined in the middle between *output_server(session=my_session) *and push() will be pushed, along with all its subobjects to my_session when push() is called.
  • What happens if I call push(session=my_other_session)?
    Finally, I noticed a typo in my previous email: in the first question, push(p) should be push().

I will let you know if I manage to modify my original script into something working.

Thank you for your help and patience!

Francesco

Hi Francesco,

Thank you all for your answers!

**@Sarah: **

Good to know, thank you. Right now I am working on a local network, but still there might be some problem accessing the server especially when the request rate is high. This doesn’t seem my case right now, but as Fabio suggested I can try with a static html page to exclude a variable.

**@Fabio: **

  • I didn’t try without the bokeh-server, I will and let you know.

Great

  • I tried running your script instead and I have problems with that too: the graphs are displayed but they are almost never updated. What I mean is that in several minutes I have seen them move once, while looking at the log, the script was sending new data approximately at the expected rate (~0.5 sec) and the server, apparently, was receiving POST connections.

Mmm… it was was working for me locally with the latest release. What release are you using?

  • What do you mean by “you seem to be re-storing the entire document when you update just one value”? Do you refer to the push(session=self.session) in Plot.do()?

No I was referring to self.session.store_document(self.document) instead of just storing the datasource.

I hope this helps.

Fabio

···

On Wednesday, March 25, 2015 at 6:47:30 PM UTC+1, Francesco Visin wrote:

Hi all,

I fixed my script, thank you all for your help!!!

I attach the code for future reference, in case anybody has a similar problem in the future.

There are still some points that are not completely clear to me, if you can clarify them I would really appreciate:

  • How do output_server and push() interact? Can you please confirm what I understood so far:
  • Whatever "plottable object"(only figure?)**is defined in the middle between *output_server(session=my_session) andpush() *will be pushed, along with all its subobjects to *my_session *when push() is called.
  • What is the expected behaviour in this case:
    my_session = Session()
    my_other_session = Session()
    output_server(session=my_session)

    (create a figure and a line into it)

    push(session=my_other_session)
    ?
  • Is there a way to remove an object (plot, figure, chart, line, …) from a document once it has been pushed?
  • Is there a way to remove everything (every document and object) from the server? The typical scenario is when I first connect to the server and I don’t know which documents/plots are there, but I want to erase everything before I begin publishing what I want.
    Thank you all for your invaluable help!

plot.py (8.55 KB)

···

On Thu, Mar 26, 2015 at 1:49 PM, Fabio Pliger [email protected] wrote:

Hi Francesco,

On Wednesday, March 25, 2015 at 6:47:30 PM UTC+1, Francesco Visin wrote:

Thank you all for your answers!

**@Sarah: **

Good to know, thank you. Right now I am working on a local network, but still there might be some problem accessing the server especially when the request rate is high. This doesn’t seem my case right now, but as Fabio suggested I can try with a static html page to exclude a variable.

**@Fabio: **

  • I didn’t try without the bokeh-server, I will and let you know.

Great

  • I tried running your script instead and I have problems with that too: the graphs are displayed but they are almost never updated. What I mean is that in several minutes I have seen them move once, while looking at the log, the script was sending new data approximately at the expected rate (~0.5 sec) and the server, apparently, was receiving POST connections.

Mmm… it was was working for me locally with the latest release. What release are you using?

  • What do you mean by “you seem to be re-storing the entire document when you update just one value”? Do you refer to the push(session=self.session) in Plot.do()?

No I was referring to self.session.store_document(self.document) instead of just storing the datasource.

I hope this helps.

Fabio

Francesco