Skip to content Skip to sidebar Skip to footer

Why Is My Plot Updated By Panel (twice) When I Change A Button Setting That Shouldn't Trigger Any Updates? (panel Holoviz)

I made a class to explore and train models. When I change the value of dropdown 'choose_model_type' in the code example below, I would expect nothing to change in my dashboard, sin

Solution 1:

The problem here is one of validation, specifically the issue is here: @param.depends('y', watch=True). y is not a parameter in your example, therefore param.depends can't resolve it and ends up falling back to depending on all parameters. I've filed an issue to resolve this here. If you change your example to:

y = param.Series(default=df[pred_target.default])

It will work, however you will still have the issue with the callback being called twice. This is because you have set watch=True in the depends declaration. Setting watch=True only makes sense for methods that have side-effects, if your method is something that returns a value then it will rarely make sense to set it. To expand on that, when you pass the method to panel, e.g. pn.Row(model_trainer.plot_y), it will automatically watch the parameters and call the method to update the plot when the parameters change.

Post a Comment for "Why Is My Plot Updated By Panel (twice) When I Change A Button Setting That Shouldn't Trigger Any Updates? (panel Holoviz)"