I run code in a REPL connected to a jupyter kernel managed by a jupyterlab server running on port 8888. I then visualise various plots with code like the following
import pandas as pd
import hvplot.pandas
import panel
df = pd.DataFrame({"A":[1,2]})
pane = panel.panel(df.hvplot())
pane.show()
The above works well. I can show many such panes on different ports calling pane.show()
, close them all at once with panel.state.kill_all_servers()
, and even group many panes on the same port with a dictionary in panel.serve({"this_pane": pane})
… My use is to interact with the data in this REPL as I continue manipulating the data.
I use emacs with emacs-jupyter but my question is applicable in a jupyter notebook or jupyter console. I want to show the apps under the same port as the jupyter server, perhaps under a new slag like https://localhost:8888/myapps/this_pane/
. That is, I want to achieve what the panel preview button does in the jupyter notebook, where the same port 8888 is used, or perhaps what jupyter-panel-proxy
does where it adds a https://localhost:8888/panel
service. But I want to do it using methods available from a console.
If it makes a difference, I am using nb-conda-kernels to launch ipykernels in other conda environments.
The reason I want this is so that I can access the many plots when I run the jupyter server remotely (with one ssh or one docker port forwarding - the one of the jupyter server). The alternative is to have two port forwarding, 8888 for the jupyter server and 8889 for the bokeh server, and call each time I want a new plot to stop the previous one
running_server = pane.show(port=8889)
# interact..
running_server.stop()
# do some more work
running_server = next_pane.show(port=8889)
# want to see the first one again briefly..
running_server.stop()
running_server = pane.show(port=8889)
# continue with next_pane..