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

Finalize Basic Tutorials #6425

Merged
merged 26 commits into from
Mar 19, 2024
Merged

Finalize Basic Tutorials #6425

merged 26 commits into from
Mar 19, 2024

Conversation

MarcSkovMadsen
Copy link
Collaborator

@MarcSkovMadsen MarcSkovMadsen commented Mar 3, 2024

WAITING FOR PHILIPP REVIEW AND GUIDANCE

Closes #6390

Adds the missing content to the basic tutorials

Todo

  • React to User Input
    • Draft content proposal
    • Check that it covers what is needed by other sections
    • Philipp to review content and update code to best practice
    • Refactor and reformulate content to make it readable, engaging and easy to digest.
  • Reactive Expressions
    • Draft content proposal
    • Check that it covers what is needed by other sections
    • Philipp to review content and update code to best practice
    • Refactor and reformulate content to make it readable, engaging and easy to digest.
  • Update Todo App
    • Philipp to provide code for best practice version.
    • Marc to add/ update explanation
  • Update Classifier App
    • Philipp to provide code for best practice version
    • Marc to add/ update the explanation.
  • Panes: Add note that this is very much a repetition of pn.panel. If it feels too repetitive it can quickly be skimmed. But its there to be able to compare and contrast the two approaches.
  • Philipp to get {pyodide} code blocks to render output when build and interactive when run.
  • Improve Streaming Dashboard (build_streaming_dashboard.md) to be consistent with other tutorials.
  • Convert (tutorial) mp4 videos to iphone compatible mp4 videos
    • Clean up build_animation.md. It includes extra video for demonstrating issue

Related issues

To finish the Todo list above Philipp would have to help fix or workaround the issues below.


Try dragging the `wind_speed` slider. Notice that the `power_generation` function is called twice every time you change the `wind_speed` `value`.

To solve this problem you should add *caching* or use *reactive expressions* (`pn.rx`). You will learn about *reactive expressions* in the next section.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Should we ask the user to add caching as an exercise?

doc/tutorials/basic/pn_bind.md Show resolved Hide resolved
doc/tutorials/basic/pn_bind.md Show resolved Hide resolved
doc/tutorials/basic/pn_rx.md Outdated Show resolved Hide resolved
doc/tutorials/basic/pn_rx.md Outdated Show resolved Hide resolved
pn.Column(submit, b_stop_wind_turbine).servable()
```

### Keep the UI responsive with threads or processes
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Please provide your best practice version of the example in this section Philipp taking into account holoviz/param#806 (comment), #6426 and holoviz/param#912.

@MarcSkovMadsen
Copy link
Collaborator Author

MarcSkovMadsen commented Mar 3, 2024

I've requested a preliminary of the content of this PR from @philippjfr . Does this cover the skills we want to teach our basic users? Are the examples best practice? If not please update the code.

Please also guide how we get the issues mentioned fixed or worked around. Thanks.

@MarcSkovMadsen MarcSkovMadsen added this to the next milestone Mar 3, 2024
@MarcSkovMadsen MarcSkovMadsen linked an issue Mar 3, 2024 that may be closed by this pull request
13 tasks
@@ -75,6 +75,18 @@ Now that you've got the basics down, it's time to put your skills to the test:
- **[Build a Streaming Dashboard](build_streaming_dashboard.md)**
- **[Build a Chat Bot](build_chatbot.md)**

## Community Tutorials
Copy link
Collaborator Author

@MarcSkovMadsen MarcSkovMadsen Mar 8, 2024

Choose a reason for hiding this comment

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

We will probably have to update this list once in a while.

It would be really awesome if @sophiamyang would update the 3 Ways to Build a Panel Visualization Dashboard blog post. Main points to update would be

  • hvplot.interactive to pn.rx (code below)
  • button_type+button_style (as in code below)
  • sizing_mode of HoloViews pane (as in code below)
  • accent (as in code below)
  • the picture showing logos and download numbers. Panel logo is blue number and download numbers much higher.
import panel as pn
import hvplot.pandas

# Load Data
from bokeh.sampledata.autompg import autompg_clean as df

# Make DataFrame Pipeline Interactive
idf = pn.rx(df)

# Define Panel widgets
cylinders = pn.widgets.IntSlider(name='Cylinders', start=4, end=8, step=2)
mfr = pn.widgets.ToggleGroup(
    name='MFR',
    options=['ford', 'chevrolet', 'honda', 'toyota', 'audi'], 
    value=['ford', 'chevrolet', 'honda', 'toyota', 'audi'],
    button_type='primary',
    button_style="outline",
    )
yaxis = pn.widgets.RadioButtonGroup(
    name='Y axis', 
    options=['hp', 'weight'],
    button_type='primary',
    button_style="outline",
)

# Combine pipeline and widgets
rx_pipeline = (
    idf[
        (idf.cyl == cylinders) & 
        (idf.mfr.isin(mfr))
    ]
    .groupby(['origin', 'mpg'])[yaxis].mean()
    .to_frame()
    .reset_index()
    .sort_values(by='mpg')  
    .reset_index(drop=True)
)

# Pipe to hvplot
rx_plot = rx_pipeline.hvplot(x='mpg', y=yaxis, by='origin', color=["#ff6f69", "#ffcc5c", "#88d8b0"], line_width=6, height=400)

# Layout using Template
template = pn.template.FastListTemplate(
    title='Interactive DataFrame Dashboards with hvplot .interactive', 
    sidebar=[cylinders, 'Manufacturers', mfr, 'Y axis' , yaxis],
    main=[pn.pane.HoloViews(rx_plot, sizing_mode="stretch_width")],
    accent="#88d8b0",
)
template.servable()

@philippjfr
Copy link
Member

Merging this as is for now and picking it up again tomorrow for final edits.

@philippjfr philippjfr merged commit 62e5417 into main Mar 19, 2024
7 checks passed
@philippjfr philippjfr deleted the enhancement/finalize-basic-tutorial branch March 19, 2024 18:12
@philippjfr philippjfr removed this from the next milestone Mar 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Finalize Tutorials for Panel 1.4
2 participants