`export_chart` method does not work
Background
On both systems and environments that I've tried, the export_chart method does not work.
I've been trying on my work machine, a Ubuntu VM, and had this issue so I decided to try on my personal machine to see if it was an environment issue. That still could be the case, but I don't know enough about the internals of Panel and Bokeh to determine that. I have tried both in a Jupyter notebook and in a deployed Panel app, with the same result.
What's Wrong
Whenever I use the export_chart method, I get a TimeoutError. I'm using this dataset and creating a chart via the GUI with Color as "Make", x-axis as "Model", and y-axis as "Model Year". Then, I call export_chart and get a TimeoutError after 5 seconds.
The first thing I tried was to increase the timeout interval, but it still never returned. I'm not knowledgeable enough about React to know if there's something obvious that was accidentally left in, and I don't know enough about the internals of the Bokeh server communication with the frontend to see if something here is messing it up. The export code button on the frontend works fine, which makes it clear to me that either the message from GraphicWalker is not reaching the component, or the response from the component isn't making it back.
Minimal Example
I created a venv and pip installed panel-graphic-walker, notebook, and jupyter_bokeh. Then, I ran these cells in my notebook:
import panel as pn
import pandas as pd
from panel_gwalker import GraphicWalker
pn.extension()
cars = pd.read_csv('Electric_Vehicle_Population_Data_20241208.csv')
gw = GraphicWalker(cars)
then, in order to access the GUI and update settings,
gw
and finally, to export the settings:
await gw.export_chart()
I have tried to export_chart with every mode and every scope with the same result.
OS and Packages
Home machine: Ubuntu 22.04.3 LTS
Work machine: Ubuntu 22.04.???
Currently, I'm using WSL2 with Ubuntu as my dev environment on my personal machine, . My work machine is a new Ubuntu install from a few months ago, but I don't have the exact info.
Package List
I created a venv and pip installed `panel-graphic-walker`, `notebook`, and `jupyter_bokeh`.
anyio==4.7.0
argon2-cffi==23.1.0
argon2-cffi-bindings==21.2.0
arrow==1.3.0
asttokens==3.0.0
async-lru==2.0.4
attrs==24.2.0
babel==2.16.0
beautifulsoup4==4.12.3
bleach==6.2.0
bokeh==3.6.2
certifi==2024.8.30
cffi==1.17.1
charset-normalizer==3.4.0
comm==0.2.2
contourpy==1.3.1
debugpy==1.8.9
decorator==5.1.1
defusedxml==0.7.1
exceptiongroup==1.2.2
executing==2.1.0
fastjsonschema==2.21.1
fqdn==1.5.1
h11==0.14.0
httpcore==1.0.7
httpx==0.28.1
idna==3.10
ipykernel==6.29.5
ipython==8.30.0
ipywidgets==8.1.5
isoduration==20.11.0
jedi==0.19.2
Jinja2==3.1.4
json5==0.10.0
jsonpointer==3.0.0
jsonschema==4.23.0
jsonschema-specifications==2024.10.1
jupyter-events==0.10.0
jupyter-lsp==2.2.5
jupyter_bokeh==4.0.5
jupyter_client==8.6.3
jupyter_core==5.7.2
jupyter_server==2.14.2
jupyter_server_terminals==0.5.3
jupyterlab==4.3.2
jupyterlab_pygments==0.3.0
jupyterlab_server==2.27.3
jupyterlab_widgets==3.0.13
linkify-it-py==2.0.3
Markdown==3.7
markdown-it-py==3.0.0
MarkupSafe==3.0.2
matplotlib-inline==0.1.7
mdit-py-plugins==0.4.2
mdurl==0.1.2
mistune==3.0.2
narwhals==1.16.0
nbclient==0.10.1
nbconvert==7.16.4
nbformat==5.10.4
nest-asyncio==1.6.0
notebook==7.3.1
notebook_shim==0.2.4
numpy==2.2.0
overrides==7.7.0
packaging==24.2
pandas==2.2.3
pandocfilters==1.5.1
panel==1.5.4
panel-graphic-walker==0.5.0
param==2.1.1
parso==0.8.4
pexpect==4.9.0
pillow==11.0.0
platformdirs==4.3.6
prometheus_client==0.21.1
prompt_toolkit==3.0.48
psutil==6.1.0
ptyprocess==0.7.0
pure_eval==0.2.3
pycparser==2.22
Pygments==2.18.0
python-dateutil==2.9.0.post0
python-json-logger==2.0.7
pytz==2024.2
pyviz_comms==3.0.3
PyYAML==6.0.2
pyzmq==26.2.0
referencing==0.35.1
requests==2.32.3
rfc3339-validator==0.1.4
rfc3986-validator==0.1.1
rpds-py==0.22.3
Send2Trash==1.8.3
six==1.17.0
sniffio==1.3.1
soupsieve==2.6
stack-data==0.6.3
terminado==0.18.1
tinycss2==1.4.0
tomli==2.2.1
tornado==6.4.2
tqdm==4.67.1
traitlets==5.14.3
types-python-dateutil==2.9.0.20241206
typing_extensions==4.12.2
tzdata==2024.2
uc-micro-py==1.0.3
uri-template==1.3.0
urllib3==2.2.3
wcwidth==0.2.13
webcolors==24.11.1
webencodings==0.5.1
websocket-client==1.8.0
widgetsnbextension==4.0.13
xyzservices==2024.9.0
I'm starting to think that this is just an issue with my understanding of async Python, or the interaction of Panel with async Python. In the example reference_app application, the ExportControls UI piece is able to export the spec perfectly fine in my environment -- I just can't replicate this directly using the export_chart method in my own application.
Any tips would be appreciated.
Thanks for you patience. At least this example works for me on the server in a fresh install
import pandas as pd
import panel as pn
from panel_gwalker import GraphicWalker
pn.extension()
cars = pd.DataFrame({"x": [1, 2, 3], "y": [1, 2, 3]})
gw = GraphicWalker(cars)
async def handle_click(event):
print("exporting ...")
data = await gw.export_chart()
print(data)
button = pn.widgets.Button(name="Next", on_click=handle_click)
pn.Column(gw, button).servable()
Let me try on my jupyterhub.
I can replicate your issue in my JupyterHub. The browser console also shows an error.
@philippjfr. Do you have any idea why there is an exception in serverconnection.js?