Cannot add Bokeh Bar Charts to a document

from bokeh.charts import Bar, output_file, show

from bokeh.sampledata.autompg import autompg as df
from bokeh.document import Document

p = Bar(df, ‘cyl’, values=‘mpg’, title=“Total MPG by CYL”, group=‘yr’, legend=‘top_right’)

mydoc = Document()

mydoc.add§

``

Gives the error:

RuntimeError: Models must be owned by only a single document, <bokeh.models.sources.ColumnDataSource object at 0x15446bc10> is already in a doc

``

This used to work in previous versions of Bokeh, and I have no idea how to accomplish this now.

For the moment, you need to explicitly turn off the "autoadd" feature, which automatically causes the Chart to add itself to the default-created and automatically-available "current documemt". Once you do that, you can create your plot and add it to you explicit/custom document. Note that you also want to use "add_root" now:

  In [1]: from bokeh.charts import Bar, output_file, show

  In [2]: from bokeh.sampledata.autompg import autompg as df

  In [3]: from bokeh.document import Document

  In [4]: from bokeh.io import curstate

  In [5]: curstate().autoadd = False

  In [6]: p = Bar(df, 'cyl', values='mpg', title="Total MPG by CYL", group='yr', legend='top_right')

  In [7]: mydoc = Document()

  In [8]: mydoc.add_root(p)

The implicit default document is a very useful concept for a great many use cases, but as you can see it makes some other use-cases a bit more clunky. As with many things, there is always a trade-off. We are still working to find the right balance, or if there is a way to help improve this use case without sacrificing the general ease of use the current document affords.

Thanks,

Bryan

···

On Feb 1, 2016, at 1:36 PM, [email protected] wrote:

from bokeh.charts import Bar, output_file, show
from bokeh.sampledata.autompg import autompg as df
from bokeh.document import Document

p = Bar(df, 'cyl', values='mpg', title="Total MPG by CYL", group='yr', legend='top_right')

mydoc = Document()
mydoc.add(p)

Gives the error:
RuntimeError: Models must be owned by only a single document, <bokeh.models.sources.ColumnDataSource object at 0x15446bc10> is already in a doc
This used to work in previous versions of Bokeh, and I have no idea how to accomplish this now.

--
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/5cb00f1c-1b5b-424d-8ba7-ebf25e842c5b%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Using your example code, I get the error


<details class='elided'>
<summary title='Show trimmed content'>&#183;&#183;&#183;</summary>

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-3-39a5786d354e> in <module>()
      3 from bokeh.document import Document
      4 from bokeh.io import curstate
----> 5 curstate().autoadd = False
      6 p = Bar(df, 'cyl', values='mpg', title="Total MPG by CYL", group='yr', legend='top_right')
      7 mydoc = Document()

AttributeError: can't set attribute

``

On Monday, February 1, 2016 at 4:29:20 PM UTC-6, Bryan Van de ven wrote:

For the moment, you need to explicitly turn off the “autoadd” feature, which automatically causes the Chart to add itself to the default-created and automatically-available “current documemt”. Once you do that, you can create your plot and add it to you explicit/custom document. Note that you also want to use “add_root” now:

    In [1]: from bokeh.charts import Bar, output_file, show



    In [2]: from bokeh.sampledata.autompg import autompg as df



    In [3]: from bokeh.document import Document



    In [4]: from [bokeh.io](http://bokeh.io) import curstate



    In [5]: curstate().autoadd = False



    In [6]: p = Bar(df, 'cyl', values='mpg', title="Total MPG by CYL", group='yr', legend='top_right')



    In [7]: mydoc = Document()



    In [8]: mydoc.add_root(p)

The implicit default document is a very useful concept for a great many use cases, but as you can see it makes some other use-cases a bit more clunky. As with many things, there is always a trade-off. We are still working to find the right balance, or if there is a way to help improve this use case without sacrificing the general ease of use the current document affords.

Thanks,

Bryan

On Feb 1, 2016, at 1:36 PM, [email protected] wrote:

from bokeh.charts import Bar, output_file, show

from bokeh.sampledata.autompg import autompg as df

from bokeh.document import Document

p = Bar(df, ‘cyl’, values=‘mpg’, title=“Total MPG by CYL”, group=‘yr’, legend=‘top_right’)

mydoc = Document()

mydoc.add§

Gives the error:

RuntimeError: Models must be owned by only a single document, <bokeh.models.sources.ColumnDataSource object at 0x15446bc10> is already in a doc

This used to work in previous versions of Bokeh, and I have no idea how to accomplish this now.


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/5cb00f1c-1b5b-424d-8ba7-ebf25e842c5b%40continuum.io.

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

Ah, sorry, this setting is new since the last full release. You can install a recent "dev build" as described here:

  http://bokeh.pydata.org/en/latest/docs/installation.html#developer-builds

Or we will (hopefully) have 0.11.1 out in the next day or so.

Bryan

···

On Feb 2, 2016, at 10:40 AM, [email protected] wrote:

Using your example code, I get the error
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-3-39a5786d354e> in <module>()
      3 from bokeh.document import Document
      4 from bokeh.io import curstate
----> 5 curstate().autoadd = False
      6 p = Bar(df, 'cyl', values='mpg', title="Total MPG by CYL", group='yr', legend='top_right')
      7 mydoc = Document()

AttributeError: can't set attribute

On Monday, February 1, 2016 at 4:29:20 PM UTC-6, Bryan Van de ven wrote:
For the moment, you need to explicitly turn off the "autoadd" feature, which automatically causes the Chart to add itself to the default-created and automatically-available "current documemt". Once you do that, you can create your plot and add it to you explicit/custom document. Note that you also want to use "add_root" now:

        In [1]: from bokeh.charts import Bar, output_file, show

        In [2]: from bokeh.sampledata.autompg import autompg as df

        In [3]: from bokeh.document import Document

        In [4]: from bokeh.io import curstate

        In [5]: curstate().autoadd = False

        In [6]: p = Bar(df, 'cyl', values='mpg', title="Total MPG by CYL", group='yr', legend='top_right')

        In [7]: mydoc = Document()

        In [8]: mydoc.add_root(p)

The implicit default document is a very useful concept for a great many use cases, but as you can see it makes some other use-cases a bit more clunky. As with many things, there is always a trade-off. We are still working to find the right balance, or if there is a way to help improve this use case without sacrificing the general ease of use the current document affords.

Thanks,

Bryan

> On Feb 1, 2016, at 1:36 PM, [email protected] wrote:
>
> from bokeh.charts import Bar, output_file, show
> from bokeh.sampledata.autompg import autompg as df
> from bokeh.document import Document
>
> p = Bar(df, 'cyl', values='mpg', title="Total MPG by CYL", group='yr', legend='top_right')
>
> mydoc = Document()
> mydoc.add(p)
>
> Gives the error:
> RuntimeError: Models must be owned by only a single document, <bokeh.models.sources.ColumnDataSource object at 0x15446bc10> is already in a doc
> This used to work in previous versions of Bokeh, and I have no idea how to accomplish this now.
>
> --
> 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/5cb00f1c-1b5b-424d-8ba7-ebf25e842c5b%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/a23be443-5039-47a6-9c59-9128284549b2%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

After a seemingly endless stream of fixes and updates, things appear to be working now. Thanks!

···

On Tuesday, February 2, 2016 at 10:45:57 AM UTC-6, Bryan Van de ven wrote:

Ah, sorry, this setting is new since the last full release. You can install a recent “dev build” as described here:

    [http://bokeh.pydata.org/en/latest/docs/installation.html#developer-builds](http://bokeh.pydata.org/en/latest/docs/installation.html#developer-builds)

Or we will (hopefully) have 0.11.1 out in the next day or so.

Bryan

On Feb 2, 2016, at 10:40 AM, [email protected] wrote:

Using your example code, I get the error


AttributeError Traceback (most recent call last)

in ()

  3 from bokeh.document import Document
  4 from [bokeh.io](http://bokeh.io) import curstate

----> 5 curstate().autoadd = False

  6 p = Bar(df, 'cyl', values='mpg', title="Total MPG by CYL", group='yr', legend='top_right')
  7 mydoc = Document()

AttributeError: can’t set attribute

On Monday, February 1, 2016 at 4:29:20 PM UTC-6, Bryan Van de ven wrote:

For the moment, you need to explicitly turn off the “autoadd” feature, which automatically causes the Chart to add itself to the default-created and automatically-available “current documemt”. Once you do that, you can create your plot and add it to you explicit/custom document. Note that you also want to use “add_root” now:

    In [1]: from bokeh.charts import Bar, output_file, show

    In [2]: from bokeh.sampledata.autompg import autompg as df

    In [3]: from bokeh.document import Document

    In [4]: from [bokeh.io](http://bokeh.io) import curstate

    In [5]: curstate().autoadd = False

    In [6]: p = Bar(df, 'cyl', values='mpg', title="Total MPG by CYL", group='yr', legend='top_right')

    In [7]: mydoc = Document()

    In [8]: mydoc.add_root(p)

The implicit default document is a very useful concept for a great many use cases, but as you can see it makes some other use-cases a bit more clunky. As with many things, there is always a trade-off. We are still working to find the right balance, or if there is a way to help improve this use case without sacrificing the general ease of use the current document affords.

Thanks,

Bryan

On Feb 1, 2016, at 1:36 PM, [email protected] wrote:

from bokeh.charts import Bar, output_file, show
from bokeh.sampledata.autompg import autompg as df
from bokeh.document import Document

p = Bar(df, ‘cyl’, values=‘mpg’, title=“Total MPG by CYL”, group=‘yr’, legend=‘top_right’)

mydoc = Document()
mydoc.add§

Gives the error:
RuntimeError: Models must be owned by only a single document, <bokeh.models.sources.ColumnDataSource object at 0x15446bc10> is already in a doc
This used to work in previous versions of Bokeh, and I have no idea how to accomplish this now.


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/5cb00f1c-1b5b-424d-8ba7-ebf25e842c5b%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/a23be443-5039-47a6-9c59-9128284549b2%40continuum.io.

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

After a seemingly endless stream of fixes and updates, things appear to be working now. Thanks!

Hi,

I definitely appreciate and empathize with the frustrations that API changes can cause. We definitely want to minimize them, and mitigate any apparent abruptness of them (e.g., by forcing deprecation warnings on all the time) But the library is not quite to the level of capability we intend to provide, and there are still mistakes from the past to learn and correct (I'll take my fair share of responsibility for them). Sometimes you don't know a thing is not quite right until you try it, and we are a small, part-time team with limited resources. Expansive "plan ahead" usability investigations are simply beyond our means. So I would say at this stage some changes are unavoidable. (Aside, new contributors/committers would be *extremely* welcome)

This is one reason we have not yet pushed a "1.0" label. However, my opinion is that the end is in sight, as we approach on the original vision that inspired the library, and that an integral part of our "1.0" release requirements is to strictly maintain APIs under test, and move to semantic versioning for our releases. Our current target and planning is roughly for this Summer (fingers crossed). We definitely won't be "done" at that point, but we should be at a plateau of stability that should serve well as the basis for future work for a long time to come. I hope you can bear with us and any remaining "construction mess" as we round this final lap.

Thanks,

Bryan

···

On Feb 2, 2016, at 3:47 PM, [email protected] wrote:

On Tuesday, February 2, 2016 at 10:45:57 AM UTC-6, Bryan Van de ven wrote:
Ah, sorry, this setting is new since the last full release. You can install a recent "dev build" as described here:

        http://bokeh.pydata.org/en/latest/docs/installation.html#developer-builds

Or we will (hopefully) have 0.11.1 out in the next day or so.

Bryan

> On Feb 2, 2016, at 10:40 AM, [email protected] wrote:
>
> Using your example code, I get the error
> ---------------------------------------------------------------------------
> AttributeError Traceback (most recent call last)
> <ipython-input-3-39a5786d354e> in <module>()
> 3 from bokeh.document import Document
> 4 from bokeh.io import curstate
> ----> 5 curstate().autoadd = False
> 6 p = Bar(df, 'cyl', values='mpg', title="Total MPG by CYL", group='yr', legend='top_right')
> 7 mydoc = Document()
>
> AttributeError: can't set attribute
>
>
>
> On Monday, February 1, 2016 at 4:29:20 PM UTC-6, Bryan Van de ven wrote:
> For the moment, you need to explicitly turn off the "autoadd" feature, which automatically causes the Chart to add itself to the default-created and automatically-available "current documemt". Once you do that, you can create your plot and add it to you explicit/custom document. Note that you also want to use "add_root" now:
>
> In [1]: from bokeh.charts import Bar, output_file, show
>
> In [2]: from bokeh.sampledata.autompg import autompg as df
>
> In [3]: from bokeh.document import Document
>
> In [4]: from bokeh.io import curstate
>
> In [5]: curstate().autoadd = False
>
> In [6]: p = Bar(df, 'cyl', values='mpg', title="Total MPG by CYL", group='yr', legend='top_right')
>
> In [7]: mydoc = Document()
>
> In [8]: mydoc.add_root(p)
>
> The implicit default document is a very useful concept for a great many use cases, but as you can see it makes some other use-cases a bit more clunky. As with many things, there is always a trade-off. We are still working to find the right balance, or if there is a way to help improve this use case without sacrificing the general ease of use the current document affords.
>
> Thanks,
>
> Bryan
>
>
>
>
> > On Feb 1, 2016, at 1:36 PM, [email protected] wrote:
> >
> > from bokeh.charts import Bar, output_file, show
> > from bokeh.sampledata.autompg import autompg as df
> > from bokeh.document import Document
> >
> > p = Bar(df, 'cyl', values='mpg', title="Total MPG by CYL", group='yr', legend='top_right')
> >
> > mydoc = Document()
> > mydoc.add(p)
> >
> > Gives the error:
> > RuntimeError: Models must be owned by only a single document, <bokeh.models.sources.ColumnDataSource object at 0x15446bc10> is already in a doc
> > This used to work in previous versions of Bokeh, and I have no idea how to accomplish this now.
> >
> > --
> > 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/5cb00f1c-1b5b-424d-8ba7-ebf25e842c5b%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/a23be443-5039-47a6-9c59-9128284549b2%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/c2edd4e6-d521-43f4-8c83-9f5bcdbdb7d9%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Thanks Bryan. Yeah, I love the tools and what you guys are doing, and I totally understand that big changes are going to happen when developing a new package, especially when you’re talking about a visualization package. Glad to hear there’s an end in sight as far as big API changes go.

– Chris

···

On Wednesday, February 3, 2016 at 12:48:13 PM UTC-6, Bryan Van de ven wrote:

On Feb 2, 2016, at 3:47 PM, [email protected] wrote:

After a seemingly endless stream of fixes and updates, things appear to be working now. Thanks!

Hi,

I definitely appreciate and empathize with the frustrations that API changes can cause. We definitely want to minimize them, and mitigate any apparent abruptness of them (e.g., by forcing deprecation warnings on all the time) But the library is not quite to the level of capability we intend to provide, and there are still mistakes from the past to learn and correct (I’ll take my fair share of responsibility for them). Sometimes you don’t know a thing is not quite right until you try it, and we are a small, part-time team with limited resources. Expansive “plan ahead” usability investigations are simply beyond our means. So I would say at this stage some changes are unavoidable. (Aside, new contributors/committers would be extremely welcome)

This is one reason we have not yet pushed a “1.0” label. However, my opinion is that the end is in sight, as we approach on the original vision that inspired the library, and that an integral part of our “1.0” release requirements is to strictly maintain APIs under test, and move to semantic versioning for our releases. Our current target and planning is roughly for this Summer (fingers crossed). We definitely won’t be “done” at that point, but we should be at a plateau of stability that should serve well as the basis for future work for a long time to come. I hope you can bear with us and any remaining “construction mess” as we round this final lap.

Thanks,

Bryan

On Tuesday, February 2, 2016 at 10:45:57 AM UTC-6, Bryan Van de ven wrote:

Ah, sorry, this setting is new since the last full release. You can install a recent “dev build” as described here:

    [http://bokeh.pydata.org/en/latest/docs/installation.html#developer-builds](http://bokeh.pydata.org/en/latest/docs/installation.html#developer-builds)

Or we will (hopefully) have 0.11.1 out in the next day or so.

Bryan

On Feb 2, 2016, at 10:40 AM, [email protected] wrote:

Using your example code, I get the error

AttributeError Traceback (most recent call last)
in ()
3 from bokeh.document import Document
4 from bokeh.io import curstate
----> 5 curstate().autoadd = False
6 p = Bar(df, ‘cyl’, values=‘mpg’, title=“Total MPG by CYL”, group=‘yr’, legend=‘top_right’)
7 mydoc = Document()

AttributeError: can’t set attribute

On Monday, February 1, 2016 at 4:29:20 PM UTC-6, Bryan Van de ven wrote:
For the moment, you need to explicitly turn off the “autoadd” feature, which automatically causes the Chart to add itself to the default-created and automatically-available “current documemt”. Once you do that, you can create your plot and add it to you explicit/custom document. Note that you also want to use “add_root” now:

    In [1]: from bokeh.charts import Bar, output_file, show

    In [2]: from bokeh.sampledata.autompg import autompg as df

    In [3]: from bokeh.document import Document

    In [4]: from [bokeh.io](http://bokeh.io) import curstate

    In [5]: curstate().autoadd = False

    In [6]: p = Bar(df, 'cyl', values='mpg', title="Total MPG by CYL", group='yr', legend='top_right')

    In [7]: mydoc = Document()

    In [8]: mydoc.add_root(p)

The implicit default document is a very useful concept for a great many use cases, but as you can see it makes some other use-cases a bit more clunky. As with many things, there is always a trade-off. We are still working to find the right balance, or if there is a way to help improve this use case without sacrificing the general ease of use the current document affords.

Thanks,

Bryan

On Feb 1, 2016, at 1:36 PM, [email protected] wrote:

from bokeh.charts import Bar, output_file, show
from bokeh.sampledata.autompg import autompg as df
from bokeh.document import Document

p = Bar(df, ‘cyl’, values=‘mpg’, title=“Total MPG by CYL”, group=‘yr’, legend=‘top_right’)

mydoc = Document()
mydoc.add§

Gives the error:
RuntimeError: Models must be owned by only a single document, <bokeh.models.sources.ColumnDataSource object at 0x15446bc10> is already in a doc
This used to work in previous versions of Bokeh, and I have no idea how to accomplish this now.


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/5cb00f1c-1b5b-424d-8ba7-ebf25e842c5b%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/a23be443-5039-47a6-9c59-9128284549b2%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].io.

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/c2edd4e6-d521-43f4-8c83-9f5bcdbdb7d9%40continuum.io.

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