bokeh app in notebook

I was experimenting with showing a bokeh app (itself a work-in-progress) in the notebook.

following a blog post, I added a doc = app.create_document() before show(app) but I’m getting an error:

“RuntimeError: Models must be owned by only a single document, ColumnDataSource(id=‘63d3a2a0-5056-4d12-a25a-9b2bb150b0af’, …) is already in a doc”

To the difference of the post, my plot is built on ColumnDataSource(s) which are not re-instantiated in the function passed to FunctionHandler (the intent is to update the content of these sources on events).

So I’m left wondering whether that exception is expected due to the CDS not being recreated and I can’t just access the doc this way (and that’s fine I guess), or there’s some problem in my code (first experiments with Bokeh server, so that’s totally possible) that I should fix.

Thanks,

Alex

Well, I’m not sure to understand what you are trying to do but, it’s clear that you can’t reuse the same CDS instance in another document. Generally speaking, bokeh doesn’t allow to share models between documents (a limitation that makes sense).

the intent is to update the content of these sources on events

I don’t see what you mean here. Bokeh offers several ways to ‘stream’ new data and update the associated plots accordingly. But, once more, whatever is update mode you use, you will not be able to share you data sources between several documents.

Thanks for the answer.

What I’m trying to do: a graph which datas ource is modified (not streamed, data is replace, fully or only some columns) upon some widgets inputs. It’s working as I expect and I’m not trying explicitly to share CDS between docs.

My question was: taking that blog example & recommendation to get the doc via app.create_document before doing a show(app, notebook="") was not working for me. And I now understand from your comment this is normal and the only reason it works in the blog’s case is because it’s re-instantiating new CDS on each doc creation (thus not sharing them, the blog’s notebook has basically two documents loaded).

···

On Sunday, July 9, 2017 at 2:58:50 PM UTC+8, nicolas.fr wrote:

Well, I’m not sure to understand what you are trying to do but, it’s clear that you can’t reuse the same CDS instance in another document. Generally speaking, bokeh doesn’t allow to share models between documents (a limitation that makes sense).

the intent is to update the content of these sources on events

I don’t see what you mean here. Bokeh offers several ways to ‘stream’ new data and update the associated plots accordingly. But, once more, whatever is update mode you use, you will not be able to share you data sources between several documents.

Hi,

This section of the User's Guide has some useful context:

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

A Bokeh app is really a factory for Documents. Every new browser session on the server gets its own unique copy of the Document to service the session, and it's not possible to share Bokeh models (plots, layouts, data sources) between different Documents for different sessions. You can certainly share non-Bokeh objects and data sources (e.g. arrays or data frames) between documents. See the "spectrogram" example in the GitHub repo, for example.

Thanks,

Bryan

···

On Jul 9, 2017, at 20:46, Alexandre Avanian <[email protected]> wrote:

Thanks for the answer.

What I'm trying to do: a graph which datas ource is modified (not streamed, data is replace, fully or only some columns) upon some widgets inputs. It's working as I expect and I'm not trying explicitly to share CDS between docs.

My question was: taking that blog example & recommendation to get the doc via app.create_document before doing a show(app, notebook="") was not working for me. And I now understand from your comment this is normal and the only reason it works in the blog's case is because it's re-instantiating new CDS on each doc creation (thus not sharing them, the blog's notebook has basically two documents loaded).

On Sunday, July 9, 2017 at 2:58:50 PM UTC+8, nicolas.fr wrote:
Well, I'm not sure to understand what you are trying to do but, it's clear that you can't reuse the same CDS instance in another document. Generally speaking, bokeh doesn't allow to share models between documents (a limitation that makes sense).

> the intent is to update the content of these sources on events

I don't see what you mean here. Bokeh offers several ways to 'stream' new data and update the associated plots accordingly. But, once more, whatever is update mode you use, you will not be able to share you data sources between several documents.

--
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/7c30c007-bc2b-415c-80b1-8dbfb92e1b6b%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.