holoviz / panel

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

Tabulator and dataframe widget error on edit and won't update anymore #6711

Closed JulienLrx closed 6 months ago

JulienLrx commented 7 months ago

Editing a cell in the tabulator widget throw a key error.

python 3.11.8 Panel 1.4.1 Bokeh 3.4.0 jupyter-bokeh 4.0.1

simple code used to reproduce the error (error is thrown upon exiting the cell) :

df = pd.DataFrame({
    "selected": [True, False, True],
    "Titre": ["TED1", "TED2", "TED3"],
    "id": [1, 2, 3],
    "check": [True, False, True]
}, index=[1, 2, 3])

pn.widgets.Tabulator(df).servable()

stack :

`File /opt/conda/lib/python3.11/site-packages/jupyter_bokeh/widgets.py:162, in BokehModel._sync_model(self, _model, content, _buffers)
    160 elif kind == "ColumnsPatched":
    161     model = content["model"]
--> 162     patches = content["data"]
    164     assert isinstance(model, ColumnDataSource)
    165     model.patch(patches, setter=setter)

KeyError: 'data'`
JulienLrx commented 7 months ago

Same problem with the dataframe widget (pn.widgets.DataFrame). Also the tabulator or the dataframe won't update anymore after a cell has been edited. (both with implicit and explicit linking)

simple exemple :

df = pd.DataFrame({
    "selected": [True, False, True],
    "Score": [3.14, 6.28, 9.42],
    "Titre": ["TED1", "TED2", "TED3"]
}, index=[1, 2, 3])

df2 = pd.DataFrame({
    "selected": [True, False, True],
    "Score": [3.14, 6.28, 9.42],
    "Titre": ["GGG1", "GGG2", "GGG3"]
}, index=[1, 2, 3])

def get_data(select):
    if select == "test1":
        return df
    else:
        return df2

select = pn.widgets.Select(name="base",options=["test1","test2"])
table = pn.widgets.DataFrame(pn.bind(get_data,select))
pn.FlexBox(select,table)
earshinov commented 7 months ago

Duplicates #5513

maximlt commented 6 months ago

Indeed it's a duplicate, closing in favor of https://github.com/holoviz/panel/issues/5513.