-
-
Notifications
You must be signed in to change notification settings - Fork 540
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Panel embed not working with more than one pane in the same panel/layout #1222
Comments
Can I ask why this is labeled as an enhancement and not a bug? Is this the expected behavior when embedding multiple widget/panel combinations? |
I guess it's both in fact. I'd expect this to work (so it's technically a bug) but at the same time at present I'd expect it to cause computing the cross-product of all widget options when ideally it would independently evaluate the two interactive elements and store them separetly. |
Thanks! I'm trying to debug this and I noticed that in the example above (and my own code), if the second Select widget has the last value selected (in this example, if you select "F"), the first widget updates its corresponding markdown as expected. If you select anything other than the last value in the second widget, then the first widget does not work anymore. Update:
Notice that only value |
The issue seems to be caused by Line 296 in 4bf8756
And the fact that
The problem is when iterating over the widget values (using Lines 311 to 318 in 4bf8756
When setting I quickly verified this by setting:
which triggers the change events. Is there a better way to manually trigger the |
I've just encountered this bug and spent some time trying to figure out, what was going on. At least for me exporting interactive html files is the best part of Panel, so I really care about this issue not being forgotten. Thank you for your work. |
It looks like this is still happening in version 0.13.1; I believe that it will be hard to fix... |
Honestly, it's more of a feature than a fix. The embed functionality was only ever designed for very simple applications, indeed it came out of the idea of HoloViews HoloMap components which embedded their contents which really consist only of a plot and a number of widgets that drive that plot. I think it wouldn't be that difficult to implement this. The main issue to solve is how you indicate which components are linked together, it should be possible in theory to figure out which widgets have effects on which other components but it's a very hard problem. A clean API that lets you express "these widgets control these components and these widgets control these other components" would make the problem a ton easier. If anyone has suggestions on what that might look like that'd be very helpful. |
cross_product indeed seems to be doing something weird.
The output is
(13 times against the total of 9). So some values will not be updated. |
Even the single panel with two widgets actually exhibits the same behavior.
Gives a panel with all plots except of the last one with a=3 and b=6. |
I was wondering if there was any update on this? I think I'm running into the same thing: when using a FYI, I've tried some things and none have worked, including:
Possibly related:
My notebook: #!/usr/bin/env python
# coding: utf-8
# In[ ]:
import matplotlib as mpl
import matplotlib.backends.backend_agg
import matplotlib.pyplot as plt
import pandas as pd
import panel as pn
# In[ ]:
# pn.extension(safe_embed=True)
pn.extension("ipywidgets", safe_embed=True)
plt.ioff()
mpl.rcParams["figure.max_open_warning"] = 0
# In[ ]:
def func0(mult=2, title="abc"):
ax = None
df = pd.DataFrame({"a": [1, 2, 3]}) * mult
df.plot(title=f"mult={mult}, title={title!r}", ax=ax)
effective_fig = plt.gcf()
pane = pn.pane.Matplotlib(effective_fig)
return pane
def func1(mult=2, title="abc"):
fig = mpl.figure.Figure()
matplotlib.backends.backend_agg.FigureCanvas(fig) # Init canvas
ax = fig.subplots()
df = pd.DataFrame({"a": [1, 2, 3]}) * mult
df.plot(title=f"mult={mult}, title={title!r}", ax=ax)
effective_fig = fig
pane = pn.pane.Matplotlib(effective_fig)
return pane
def func2(mult=2, title="abc"):
fig = mpl.figure.Figure()
matplotlib.backends.backend_agg.FigureCanvas(fig) # Init canvas
ax = fig.subplots()
df = pd.DataFrame({"a": [1, 2, 3]}) * mult
df.plot(title=f"mult={mult}, title={title!r}", ax=ax)
effective_fig = fig
pane = pn.pane.Matplotlib(effective_fig)
pane.param.trigger("object")
return pane
# None of these work
func = func0
# func = func1
# func = func2
# In[ ]:
# None of these work
# interact_view = pn.interact(func, mult=[1.0, 2.0, 3.0], title=["abc", "def"])
interact_view = pn.interact(func, mult=[1, 2, 3])
# interact_view = pn.interact(func, mult=(1, 3))
# interact_view = pn.interact(func, title=["abc", "def"])
interact_view
# In[ ]:
interact_view.embed(max_states=500, max_opts=500, progress=True) Here are some versions of interest (I can provide more):
Thanks! |
I also observed the behaviour described by @horatiubota, namely when one chooses the last option from the second selector, the interactivity using the first selector works, otherwise not. Following the observation from @horatiubota I can make the interactivity work by changing Line 318 in 4bf8756
to
|
Tested in OSX and Linux, Panel versions from 0.8.3 to 0.9.4 (and Bokeh 1.4.0 and 2.0.0, according to Panel requirements)
The issue
Hi! I am trying to embed a simple Panel layout (in this case in the notebook, but it could very well be with
my_layout.save(embed=True)
that contains:pn.widgets.Select
, but it doesn't matter)pn.pane.Markdown
)Where one pane is created through a reactive function involving one widget, and the other pane through another reactive function involving the other widget, as follows:
Nothing special, it works as expected. However, I plan to generate a standalone HTML with these elements (no Bokeh Server, as my client does not know what is Python), so the easiest way would be to just wrap the elements inside a
pn.Column
, embed the column and call it a day:However, the embedding is not responding as it should be. For some reason, the first Markdown does not work; whereas the second one works perfectly. Please take a look at this video:

I believe there is some problem with
pn.io.embed()
. I have tried to look at the code, but it has been really hard for me to figure out how the element tree is transversed in order to find what has to been transformed into a JsLink.I mean, I believe it is a very first-world problem and not a whole lot of users will ever need to live without the Bokeh/Panel Server, but I have spent hours looking for the bug (the code above is just an example; the real code I'm writing is way more obfuscated).
If instead of placing everything in one Column we use two (one for each widget+pane), the problem disappears. However, exporting the whole thing as one HTML instead of two is way harder in that way (in fact, I have not been able to do so).
Thank you again for Panel. It's awesome.
The text was updated successfully, but these errors were encountered: