Closed kcpevey closed 6 months ago
@iameskild @pierrotsmnrd Do you have more information on the difference between panel
and panel serve
on the framework choices?
I am confused here. I thought that launching a panel app (whether from a py file or notebook) on a web browser, you would always use panel serve
. But you can use panel
when launching from python. Is that what it is?
@ppwadhwa If I recall correctly :
panel
is to serve a notebook directly, like panel serve app.ipynb
panel serve
is to serve a python script that contains pn.serve(...)
I agree the naming is confusing
Thank you for the response, @pierrotsmnrd !!! I will update the FAQs with this.
@ppwadhwa it's worth checking if I didn't get this wrong, and maybe test it as well.
I have not been able to get the panel-serve
option to work for me. The panel
option seems to work with a notebook, or a python file with pn.serve(...)
.
Do we need the panel-serve option?
There was a specific reason we needed to add the panel-serve option. @pierrotsmnrd do you recall what that was?
If I recall correctly, we needed the panel-serve
option to serve a panel app from a python script, served with pn.serve(...)
.
The panel
option, at that time, only allowed a path to a notebook.
If it's now possible to run either a notebook or a python script with pn.serve(...)
, from the panel
entry of CDSDashboards, then panel serve
is unnecessary.
@ppwadhwa can you show me the script with pn.serve(...)
you used ?
@pierrotsmnrd I took this code from the panel docs. It will deploy using the panel
option, but will not when using panel-serve
. Is there something different I should do here?
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
csv_file = 'https://raw.githubusercontent.com/holoviz/panel/main/examples/assets/occupancy.csv'
data = pd.read_csv(csv_file, parse_dates=['date'], index_col='date')
import matplotlib as mpl
mpl.use('agg')
from matplotlib.figure import Figure
def mpl_plot(avg, highlight):
fig = Figure()
ax = fig.add_subplot()
avg.plot(ax=ax)
if len(highlight): highlight.plot(style='o', ax=ax)
return fig
def find_outliers(variable='Temperature', window=30, sigma=10, view_fn=mpl_plot):
avg = data[variable].rolling(window=window).mean()
residual = data[variable] - avg
std = residual.rolling(window=window).std()
outliers = (np.abs(residual) > std * sigma)
return view_fn(avg, avg[outliers])
import panel as pn
pn.extension()
window = pn.widgets.IntSlider(name='window', value=30, start=1, end=60)
sigma = pn.widgets.IntSlider(name='sigma', value=10, start=0, end=20)
interactive = pn.bind(find_outliers, window=window, sigma=sigma)
first_app = pn.Column(window, sigma, interactive)
first_app.servable();
pn.serve(first_app)
This is no longer valid as CDS dashboards has been replaced by jhub-apps which does not have this usecase.
Preliminary Checks
Summary
FAQ item: What is the difference between the
panel
andpanel-serve
option as the dashboarding framework?Simple answer: Use
panel-serve
for serving viapy
files andpanel
for serving via notebooks (and some py files?).Perhaps either @iameskild or @pierrotsmnrd can add more technical details on the difference.
Steps to Resolve this Issue
add doc