holoviz / panel

Panel: The powerful data exploration & web app framework for Python
https://panel.holoviz.org
BSD 3-Clause "New" or "Revised" License
4.8k stars 519 forks source link

Syncing `value_throttled` as a query parameter should raise an Exception #7481

Open MP-MaximilianLattka opened 1 week ago

MP-MaximilianLattka commented 1 week ago

ALL software version info

Software Version Info ```plaintext Python 3.12.7 Panel 1.5.3 ```

Description of expected behavior and the observed behavior

value_throttled of various widgets is a read-only attribute and it is not possible to hook it up via pn.state.location.sync. I would expect an exception to be raised if the user attempts to do so anyways.

(Please don't confuse this issue with https://github.com/holoviz/panel/issues/7482 which features a similar code snippet)

Complete, minimal, self-contained example code that reproduces the issue

import panel as pn
import pandas as pd

pn.extension("tabulator", notifications=False)

template = pn.template.BootstrapTemplate()

df_full = pd.DataFrame({"year": list(range(2000, 2021))})

table = pn.widgets.Tabulator(df_full)
slider = pn.widgets.RangeSlider(start=2000, end=2020, name='Years')

@pn.depends(slider.param.value_throttled, watch=True)
def filter_df(value):
    start, end = value
    table.value = df_full[(df_full["year"] >= start) & (df_full["year"] <= end)]

if pn.state.location:
    pn.state.location.sync(slider, {"value_throttled": "years"})

template.main.append(pn.Column(table))
template.sidebar.append(pn.Column(slider))
template.servable();

Stack traceback and/or browser JavaScript console output

Screenshots or screencasts of the bug in action

jbednar commented 1 week ago

I can reproduce this issue, which to me seems like a bug (if only a bug in our error checking).