nebari-dev / nebari-docs

📖 Documentation for Nebari
https://www.nebari.dev
BSD 3-Clause "New" or "Revised" License
14 stars 29 forks source link

[DOC] - FAQ item - Difference between `panel` and `panel-serve` on dashboard setup #242

Closed kcpevey closed 6 months ago

kcpevey commented 1 year ago

Preliminary Checks

Summary

FAQ item: What is the difference between the panel and panel-serve option as the dashboarding framework?

Simple answer: Use panel-serve for serving via py files and panel 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

ppwadhwa commented 1 year 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?

pierrotsmnrd commented 1 year ago

@ppwadhwa If I recall correctly :

I agree the naming is confusing

ppwadhwa commented 1 year ago

Thank you for the response, @pierrotsmnrd !!! I will update the FAQs with this.

pierrotsmnrd commented 1 year ago

@ppwadhwa it's worth checking if I didn't get this wrong, and maybe test it as well.

ppwadhwa commented 1 year ago

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?

kcpevey commented 1 year ago

There was a specific reason we needed to add the panel-serve option. @pierrotsmnrd do you recall what that was?

pierrotsmnrd commented 1 year ago

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 ?

ppwadhwa commented 1 year ago

@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)
kcpevey commented 6 months ago

This is no longer valid as CDS dashboards has been replaced by jhub-apps which does not have this usecase.