Unable to use containers as attributes in an App?

I need to create an app with dynamic list of plots in Bokeh. When I try to do the following:

Inline image 1

and then, within create() (i.e. the constructor) if I try to do the following so that I can populate the plots:

    # Create the figure container
    obj.plot = OrderedDict()

I get:

AttributeError: unexpected attribute ‘plot’ to MyApp, similar attributes are plots_box

Is this not legal in Bokeh? How can I create an app with a dynamic of plots?

Thanks,

Josh

Hi Josh,

Cross-language work is fraught with places for things to go wrong, so we have had to impose some strictures to allow program state to be reasoned about in a meaningful way. All Bokeh model classes (children of HasProps, basically every object that has to be able to be serialized) performs strict validation or its property attributes, and furthermore, complains loudly if you try to set a public attribute that is not one of the properties defined on the class. However, you can add any private attributes that you like. Call the attribute "_plots" and you should be fine.

Just to expand a bit, this is a bit of an weird middle case. Nothing stops you from adding a (non-property) class attribute like you've done on the class definition. You've run into our property validation logic when using an instance. But perhaps we should stop you. We could certainly check for (and complain about) any non-property attributes on Bokeh models in the metaclass at class creation time so that this situation is reported earlier.

Bryan

···

On Apr 16, 2015, at 7:38 PM, Josh Wasserstein <ribonucleico[email protected]> wrote:

I need to create an app with dynamic list of plots in Bokeh. When I try to do the following:

<Screen Shot 2015-04-16 at 8.34.25 PM.png>

and then, within create() (i.e. the constructor) if I try to do the following so that I can populate the plots:

        # Create the figure container
        obj.plot = OrderedDict()

I get:

AttributeError: unexpected attribute 'plot' to MyApp, similar attributes are plots_box

Is this not legal in Bokeh? How can I create an app with a dynamic of plots?

Thanks,

Josh

--
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/CAD4ivxVghzv2timnfndLX38sOMBHrDjjBWfN-u_o7J6uR1Nppg%40mail.gmail.com.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Thank you Bryan. I think I understand your point. The problem I have in mind is creating apps (classes) with dynamic layouts and widgets, meaning the app would create & display widgets depending on the user input. For example, in the problem that I am working on, if the user chooses to plot data for the last 4 hours, I would like the app to create 4 plots (and hopefully I can index them in some container within the class).

There may be other ways of doing this (you suggest using “_plots” which may just be perfectly fine). I am not particularly concerned with how to do it, as long as there is a reasonable way having this functionality somehow.

Thanks again,

Josh

···

On Thu, Apr 16, 2015 at 9:32 PM, Bryan Van de Ven [email protected] wrote:

Hi Josh,

Cross-language work is fraught with places for things to go wrong, so we have had to impose some strictures to allow program state to be reasoned about in a meaningful way. All Bokeh model classes (children of HasProps, basically every object that has to be able to be serialized) performs strict validation or its property attributes, and furthermore, complains loudly if you try to set a public attribute that is not one of the properties defined on the class. However, you can add any private attributes that you like. Call the attribute “_plots” and you should be fine.

Just to expand a bit, this is a bit of an weird middle case. Nothing stops you from adding a (non-property) class attribute like you’ve done on the class definition. You’ve run into our property validation logic when using an instance. But perhaps we should stop you. We could certainly check for (and complain about) any non-property attributes on Bokeh models in the metaclass at class creation time so that this situation is reported earlier.

Bryan

On Apr 16, 2015, at 7:38 PM, Josh Wasserstein [email protected] wrote:

I need to create an app with dynamic list of plots in Bokeh. When I try to do the following:

<Screen Shot 2015-04-16 at 8.34.25 PM.png>

and then, within create() (i.e. the constructor) if I try to do the following so that I can populate the plots:

    # Create the figure container
    obj.plot = OrderedDict()

I get:

AttributeError: unexpected attribute ‘plot’ to MyApp, similar attributes are plots_box

Is this not legal in Bokeh? How can I create an app with a dynamic of plots?

Thanks,

Josh

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/CAD4ivxVghzv2timnfndLX38sOMBHrDjjBWfN-u_o7J6uR1Nppg%40mail.gmail.com.

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/B924DD0E-DD26-45A3-A872-D372355CDCFD%40continuum.io.

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

Josh,

I would say that if you would like these plot dictionaries be serialized and be available on the server app, the best thing to do is to add a real Bokeh property to the app, something like:

    plots = Dict(String, Instance(Plot))

(or whatever the appropriate key type should be) but I might be misunderstanding the use-case.

Bryan

···

On Apr 18, 2015, at 4:29 PM, Josh Wasserstein <[email protected]> wrote:

Thank you Bryan. I think I understand your point. The problem I have in mind is creating apps (classes) with dynamic layouts and widgets, meaning the app would create & display widgets depending on the user input. For example, in the problem that I am working on, if the user chooses to plot data for the last 4 hours, I would like the app to create 4 plots (and hopefully I can index them in some container within the class).

There may be other ways of doing this (you suggest using "_plots" which may just be perfectly fine). I am not particularly concerned with how to do it, as long as there is a reasonable way having this functionality somehow.

Thanks again,

Josh

On Thu, Apr 16, 2015 at 9:32 PM, Bryan Van de Ven <br[email protected]> wrote:
Hi Josh,

Cross-language work is fraught with places for things to go wrong, so we have had to impose some strictures to allow program state to be reasoned about in a meaningful way. All Bokeh model classes (children of HasProps, basically every object that has to be able to be serialized) performs strict validation or its property attributes, and furthermore, complains loudly if you try to set a public attribute that is not one of the properties defined on the class. However, you can add any private attributes that you like. Call the attribute "_plots" and you should be fine.

Just to expand a bit, this is a bit of an weird middle case. Nothing stops you from adding a (non-property) class attribute like you've done on the class definition. You've run into our property validation logic when using an instance. But perhaps we should stop you. We could certainly check for (and complain about) any non-property attributes on Bokeh models in the metaclass at class creation time so that this situation is reported earlier.

Bryan

> On Apr 16, 2015, at 7:38 PM, Josh Wasserstein <[email protected]> wrote:
>
> I need to create an app with dynamic list of plots in Bokeh. When I try to do the following:
>
> <Screen Shot 2015-04-16 at 8.34.25 PM.png>
>
>
> and then, within create() (i.e. the constructor) if I try to do the following so that I can populate the plots:
>
> # Create the figure container
> obj.plot = OrderedDict()
>
>
> I get:
>
> AttributeError: unexpected attribute 'plot' to MyApp, similar attributes are plots_box
>
> Is this not legal in Bokeh? How can I create an app with a dynamic of plots?
>
> Thanks,
>
> Josh
>
> --
> 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/CAD4ivxVghzv2timnfndLX38sOMBHrDjjBWfN-u_o7J6uR1Nppg%40mail.gmail.com.
> 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/B924DD0E-DD26-45A3-A872-D372355CDCFD%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/CAD4ivxU%3D3E7g_CQ9fQSBp3cQ4G-a23ffYBKaQok-LhQr4ketqg%40mail.gmail.com.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.