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

New user feedback #7043

Merged
merged 16 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions doc/explanation/api/examples/outliers_declarative.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,40 @@ pn.Column(obj.param, obj.view)
```

To support various domains, you can create hierarchies of classes encapsulating parameters and functionality across different object families. Parameters and code can inherit across classes as needed, without depending on any specific GUI library. This approach facilitates the maintenance of large codebases, all displayable and editable with Panel, adaptable over time. For a more complex illustration, refer to the [Attractors Panel app](https://examples.holoviz.org/gallery/attractors/attractors_panel.html) ([source](https://github.com/holoviz-topics/examples/tree/main/attractors)), and explore the Panel codebase itself for extensive usage of Param throughout the codebase.

## Serving the Notebook
philippjfr marked this conversation as resolved.
Show resolved Hide resolved

Lets finalize our app by organizing our components in a nicely styled template (`MaterialTemplate`) and mark it `.servable()` to add it to our served app:

```python
pn.template.MaterialTemplate(
site="Panel",
title="Getting Started App",
sidebar=[obj.param],
main=[obj.view],
).servable(); # The ; is needed in the notebook to not display the template. Its not needed in a script
```

Save the notebook with the name `app.ipynb`.

Finally, we'll serve the app by running the command below in a terminal:

```bash
panel serve app.ipynb --autoreload
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately the getting started app displays

2024-07-30 06:41:20,719 Dropping a patch because it contains a previously known reference (id='p1269'). Most of the time this is harmless and usually a result of updating a model on one side of a communications channel while it was being removed on the other end.
2024-07-30 06:41:20,956 Dropping a patch because it contains a previously known reference (id='p1369'). Most of the time this is harmless and usually a result of updating a model on one side of a communications channel while it was being removed on the other end.
2024-07-30 06:41:21,789 Dropping a patch because it contains a previously known reference (id='p1551'). Most of the time this is harmless and usually a result of updating a model on one side of a communications channel while it was being removed on the other end.
2024-07-30 06:41:22,023 Dropping a patch because it contains a previously known reference (id='p1646'). Most of the time this is harmless and usually a result of updating a model on one side of a communications channel while it was being removed on the other end.
2024-07-30 06:41:22,255 Dropping a patch because it contains a previously known reference (id='p1738'). Most of the time this is harmless and usually a result of updating a model on one side of a communications channel while it was being removed on the other end.
2024-07-30 06:41:22,501 Dropping a patch because it contains a previously known reference (id='p1828'). Most of the time this is harmless and usually a result of updating a model on one side of a communications channel while it was being removed on the other end.
2024-07-30 06:41:22,740 Dropping a patch because it contains a previously known reference (id='p1918'). Most of the time this is harmless and usually a result of updating a model on one side of a communications channel while it was being removed on the other end.
2024-07-30 06:41:23,807 Dropping a patch because it contains a previously known reference (id='p2106'). Most of the time this is harmless and usually a result of updating a model on one side of a communications channel while it was being removed on the other end.
2024-07-30 06:41:24,047 Dropping a patch because it contains a previously known reference (id='p2207'). Most of the time this is harmless and usually a result of updating a model on one side of a communications channel while it was being removed on the other end.

This is highly confusing for a new user. Even though it states it probably not a problem its overload of information and signals that something is not fully robust.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't reproduce this.

Copy link
Collaborator Author

@MarcSkovMadsen MarcSkovMadsen Sep 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm on the main branch of Panel and get this when I drag the top left slider.

dropping-patch.mp4

hvplot==0.10.0, holoviews==1.19.1,bokeh=3.5.0.

import hvplot.pandas
import numpy as np
import pandas as pd
import panel as pn

PRIMARY_COLOR = "#0072B5"
SECONDARY_COLOR = "#B54300"
CSV_FILE = (
    "https://raw.githubusercontent.com/holoviz/panel/main/examples/assets/occupancy.csv"
)

pn.extension(design="material", sizing_mode="stretch_width")

@pn.cache
def get_data():
  return pd.read_csv(CSV_FILE, parse_dates=["date"], index_col="date")

data = get_data()

def transform_data(variable, window, sigma):
    """Calculates the rolling average and identifies outliers"""
    avg = data[variable].rolling(window=window).mean()
    residual = data[variable] - avg
    std = residual.rolling(window=window).std()
    outliers = np.abs(residual) > std * sigma
    return avg, avg[outliers]


def get_plot(variable="Temperature", window=30, sigma=10):
    """Plots the rolling average and the outliers"""
    avg, highlight = transform_data(variable, window, sigma)
    return avg.hvplot(
        height=300, legend=False, color=PRIMARY_COLOR
    ) * highlight.hvplot.scatter(color=SECONDARY_COLOR, padding=0.1, legend=False)

variable_widget = pn.widgets.Select(name="variable", value="Temperature", options=list(data.columns))
window_widget = pn.widgets.IntSlider(name="window", value=30, start=1, end=60)
sigma_widget = pn.widgets.IntSlider(name="sigma", value=10, start=0, end=20)

bound_plot = pn.bind(
    get_plot, variable=variable_widget, window=window_widget, sigma=sigma_widget
)

pn.template.MaterialTemplate(
    site="Panel",
    title="Getting Started App",
    sidebar=[variable_widget, window_widget, sigma_widget],
    main=[bound_plot],
).servable(); # The ; is needed in the notebook to not display the template. Its not needed in a script

philippjfr marked this conversation as resolved.
Show resolved Hide resolved
```

Now, open the app in your browser at [http://localhost:5006/app](http://localhost:5006/app).

It should look like this:

![Getting Started App](../../../_static/images/getting_started_app.png)

:::{tip}

If you prefer developing in a Python Script using an editor, you can copy the code into a file `app.py` and serve it.

```bash
panel serve app.py --autoreload
```

:::
6 changes: 4 additions & 2 deletions doc/getting_started/build_app.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ If you're eager to roll up your sleeves and build this app alongside us, we reco
Initially, the code block outputs on this website offer limited interactivity, indicated by the <font color="darkgoldenrod">golden</font> border to the left of the output below. By clicking the play button (<svg class="pyodide-run-icon" style="width:32px;height:25px" viewBox="0 0 24 24"> <path stroke="none" fill="#28a745" d="M8,5.14V19.14L19,12.14L8,5.14Z"></path> </svg>), you can activate full interactivity, marked by a <font color="green">green</font> left-border.
:::

## Fetching the Data
## Configuring the Application

First, let's import the necessary dependencies and define some variables:

Expand All @@ -37,6 +37,8 @@ Next, we'll import the Panel JavaScript dependencies using `pn.extension(...)`.
pn.extension(design="material", sizing_mode="stretch_width")
```

## Fetching the Data

Now, let's load the [UCI ML dataset](http://archive.ics.uci.edu/dataset/357/occupancy+detection) that measured the environment in a meeting room. We'll speed up our application by caching (`@pn.cache`) the data across users:

```{pyodide}
Expand Down Expand Up @@ -121,7 +123,7 @@ pn.template.MaterialTemplate(

Save the notebook with the name `app.ipynb`.

Finally, we'll serve the app with:
Finally, we'll serve the app by running the command below in a terminal:

```bash
panel serve app.ipynb --autoreload
Expand Down
32 changes: 32 additions & 0 deletions doc/getting_started/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,38 @@ Make sure Panel is installed in the same environment as JupyterLab/Jupyter Noteb
If you plan to use Panel in a non-Jupyter notebook environment, such as Google Colab or VSCode, refer to the [relevant how-to section](../how_to/notebook/other_nb.md).
:::

## Updating Panel
MarcSkovMadsen marked this conversation as resolved.
Show resolved Hide resolved

:::{important}

Instead of updating, we recommend that you create a new virtual environment from scratch and reinstall Panel to minimize the risk of potential issues.

:::

We suggest updating the dependencies `param` and `bokeh` along with `panel` and `watchfiles` to reduce the likelihood of problems.

:::::{tab-set}

::::{tab-item} pip
:sync: pip

```bash
pip install --upgrade panel watchfiles param bokeh
MarcSkovMadsen marked this conversation as resolved.
Show resolved Hide resolved
```

::::

::::{tab-item} conda
:sync: conda

```bash
conda update panel watchfiles param bokeh
```

::::

:::::

## Next Steps

Now that you have installed Panel, let's [build a simple application](build_app.md).
Loading