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

Add ability to Skip Param<Ref|Function|Method> updates #6396

Merged
merged 3 commits into from Mar 4, 2024
Merged

Conversation

philippjfr
Copy link
Member

@philippjfr philippjfr commented Feb 26, 2024

This PR is the counter-part to a change in Param introduced in holoviz/param#908. Specifically we add support for handling param.Skip exceptions. This allows writing reactive callbacks that skip events if certain conditions aren't met. This can be useful in scenarios where you want to skip updates for invalid parameter combinations or if you want to wait on a button click or some other event to actually re-evaluate the function or method.

An example is submission form:

name = pn.widgets.TextInput()
age = pn.widgets.FloatInput()
button = pn.widgets.Button(name='Submit!')

def submit_fn(name, age, submit):
    if not submit:
        raise Skip()
    return 'Submitted user {name}  of {age=}.'

pn.bind(submit_fn, name, age, button)

Copy link

codecov bot commented Feb 26, 2024

Codecov Report

Attention: Patch coverage is 94.73684% with 3 lines in your changes are missing coverage. Please review.

Project coverage is 71.64%. Comparing base (93b8d95) to head (1c0fdd4).

Files Patch % Lines
panel/param.py 86.36% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6396      +/-   ##
==========================================
+ Coverage   71.61%   71.64%   +0.02%     
==========================================
  Files         310      310              
  Lines       45841    45894      +53     
==========================================
+ Hits        32831    32882      +51     
- Misses      13010    13012       +2     
Flag Coverage Δ
unitexamples-tests 71.64% <94.73%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@philippjfr philippjfr added this to the v1.4.0 milestone Feb 26, 2024
@philippjfr philippjfr merged commit 611d373 into main Mar 4, 2024
10 of 15 checks passed
@philippjfr philippjfr deleted the param_skip branch March 4, 2024 17:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant