holoviz / panel

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

KeyError 'data' on table edit #5513

Closed nmillerPCMC closed 3 months ago

nmillerPCMC commented 1 year ago

Just trying to get the Tabulator example posted on the main webpage to work. Editing the cells throws a KeyError exception. https://panel.holoviz.org/reference/widgets/Tabulator.html

ALL software version info

panel v1.2.2 ipywidgets v8.1.1 bokeh v3.2.2 jupyter_bokeh v3..0.7 Windows 10 python 3.11 working within VScode v1.82.2 with Jupyter Extension v2023.8.1002501831 (this library, plus any other relevant software, e.g. bokeh, python, notebook, OS, browser, etc)

Description of expected behavior and the observed behavior

should be able to edit without fatal error

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

#Holoviz panel
import datetime as dt
import numpy as np
import pandas as pd
import panel as pn

np.random.seed(7)
pn.extension('tabulator')

df_widget = pn.widgets.Tabulator(df)
df = pd.DataFrame({
    'int': [1, 2, 3],
    'float': [3.14, 6.28, 9.42],
    'str': ['A', 'B', 'C'],
    'bool': [True, False, True],
    'date': [dt.date(2019, 1, 1), dt.date(2020, 1, 1), dt.date(2020, 1, 10)],
    'datetime': [dt.datetime(2019, 1, 1, 10), dt.datetime(2020, 1, 1, 12), dt.datetime(2020, 1, 10, 13)]
}, index=[1, 2, 3])

df_widget = pn.widgets.Tabulator(df, buttons={'Print': "<i class='fa fa-print'></i>"})
display(df_widget)

Stack traceback and/or browser JavaScript console output


KeyError Traceback (most recent call last) File c:\Users\NMiller\AppData\Local\pypoetry\Cache\virtualenvs\poetry-A7ZAAhQy-py3.11\Lib\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'

Screenshots or screencasts of the bug in action

hoxbro commented 12 months ago

Hi, can you check what versions of Bokeh and ipywidgets_bokeh you have installed?

nmillerPCMC commented 12 months ago

bokeh version 3.2.2

I do not have ipywidgets_bokeh listed as installed. Is it perhaps included within ipywidgets v8.1.0? or do I need to install it directly?

hoxbro commented 12 months ago

Try installing it; be sure you get the latest version 1.5.

nmillerPCMC commented 12 months ago

installed 1.5. Same issue.

hoxbro commented 12 months ago

mmh, I don't have any clear ideas then, it works on my computer.

Can you send me your full package list with pip list or conda env export?

nmillerPCMC commented 12 months ago

(poetry-py3.11) PS C:\code\PCMC_LBCT\poetry> poetry show alabaster 0.7.13 A configurable sidebar-enabled Sphinx theme appdirs 1.4.4 A small Python module for determining appropriate platform-specific dirs, e.g. a "user data dir".
arrow 1.2.3 Better dates & times for Python asgiref 3.6.0 ASGI specs, helper code, and adapters astroid 2.15.4 An abstract syntax tree for Python with inference support. asttokens 2.2.1 Annotate AST trees with source code positions atomicwrites 1.4.1 Atomic file writes. attrs 23.1.0 Classes Without Boilerplate autopep8 2.0.2 A tool that automatically formats Python code to conform to the PEP 8 style guide babel 2.12.1 Internationalization utilities backcall 0.2.0 Specifications for callback functions passed in to an API bcrypt 4.0.1 Modern password hashing for your software and your servers beautifulsoup4 4.12.2 Screen-scraping library binaryornot 0.4.4 Ultra-lightweight pure Python package to check if a file is binary or text. black 23.3.0 The uncompromising code formatter. bleach 6.0.0 An easy safelist-based HTML-sanitizing tool. blinker 1.6.2 Fast, simple object-to-object and broadcast signaling bokeh 3.2.2 Interactive plots and applications in the browser from Python bqplot 0.12.40 Interactive plotting for the Jupyter notebook, using d3.js and ipywidgets. certifi 2022.12.7 Python package for providing Mozilla's CA Bundle. cffi 1.15.1 Foreign Function Interface for Python calling C code. chardet 5.1.0 Universal encoding detector for Python 3 charset-normalizer 3.1.0 The Real First Universal Charset Detector. Open, modern and actively maintained alternative to Chardet. chart-studio 1.1.0 Utilities for interfacing with plotly's Chart Studio ciso8601 2.3.0 Fast ISO8601 date time parser for Python written in C click 8.1.3 Composable command line interface toolkit cloudpickle 2.2.1 Extended pickling support for Python objects colorama 0.4.6 Cross-platform colored terminal text. coloredlogs 15.0.1 Colored terminal output for Python's logging module comm 0.1.3 Jupyter Python Comm implementation, for usage in ipykernel, xeus-python etc. contourpy 1.1.0 Python library for calculating contours of 2D quadrilateral grids cookiecutter 2.1.1 A command-line utility that creates projects from project templates, e.g. creating a Python package project from a Python pack...
cryptography 40.0.2 cryptography is a package which provides cryptographic recipes and primitives to Python developers. dash 2.9.3 A Python framework for building reactive web-apps. Developed by Plotly. dash-ag-grid 2.0.0 Dash wrapper around AG Grid, the best interactive data grid for the web. dash-bootstrap-components 1.4.1 Bootstrap themed components for use in Plotly Dash dash-core-components 2.0.0 Core component suite for Dash dash-html-components 2.0.0 Vanilla HTML components for Dash dash-mantine-components 0.12.1 Plotly Dash Components based on Mantine dash-table 5.0.0 Dash table datetime 5.2 This package provides a DateTime data type, as known from Zope. Unless you need to communicate with Zope APIs, you're probably...
debugpy 1.6.7 An implementation of the Debug Adapter Protocol for Python decorator 5.1.1 Decorators for Humans defusedxml 0.7.1 XML bomb protection for Python stdlib modules diff-match-patch 20230430 Diff Match and Patch dill 0.3.6 serialize all of python django 4.2.1 A high-level Python web framework that encourages rapid development and clean, pragmatic design. django-environ 0.10.0 A package that allows you to utilize 12factor inspired environment variables to configure your Django application. docstring-to-markdown 0.12 On the fly conversion of Python docstrings to markdown docutils 0.19 Docutils -- Python Documentation Utilities dotwiz 0.4.0 DotWiz is a blazing fast dict subclass that enables accessing (nested) keys in dot notation. environ 1.0 Stack Based Globals Management et-xmlfile 1.1.0 An implementation of lxml.xmlfile for the standard library executing 1.2.0 Get the currently executing AST node of a frame, and other information fabric 3.0.1 High level SSH command execution fastjsonschema 2.16.3 Fastest Python implementation of JSON schema flake8 6.0.0 the modular source code checker: pep8 pyflakes and co flask 2.3.2 A simple framework for building complex web applications. frozendict 2.3.8 A simple immutable dictionary gast 0.4.0 Python AST that abstracts the underlying Python version git-python 1.0.3 combination and simplification of some useful git commands gitdb 4.0.10 Git Object Database gitpython 3.1.31 GitPython is a Python library used to interact with Git repositories greenlet 2.0.2 Lightweight in-process concurrent programming html5lib 1.1 HTML parser based on the WHATWG HTML specification humanfriendly 10.0 Human friendly output for text interfaces using Python icecream 2.1.3 Never use print() to debug again; inspect variables, expressions, and program execution with a single, simple function call.
idna 3.4 Internationalized Domain Names in Applications (IDNA) imagesize 1.4.1 Getting image size from png/jpeg/jpeg2000/gif file import-ipynb 0.1.4 Imports A.ipynb into B.ipynb importlib-metadata 6.6.0 Read metadata from Python packages inflection 0.5.1 A port of Ruby on Rails inflector to Python influxdb 5.3.1 InfluxDB client influxdb-client 1.36.1 InfluxDB 2.0 Python client library intervaltree 3.1.0 Editable interval tree data structure for Python 2 and 3 invoke 2.1.1 Pythonic task execution ipydatagrid 1.2.0 Fast Datagrid widget for the Jupyter Notebook and JupyterLab ipykernel 6.22.0 IPython Kernel for Jupyter ipython 8.13.2 IPython: Productive Interactive Computing ipython-genutils 0.2.0 Vestigial utilities from IPython ipywidgets 8.1.0 Jupyter interactive widgets ipywidgets-bokeh 1.5.0 Allows embedding of Jupyter widgets in Bokeh layouts. isort 5.12.0 A Python utility / library to sort Python imports. itsdangerous 2.1.2 Safely pass data to untrusted environments and back. jaraco-classes 3.2.3 Utility functions for Python class constructs jedi 0.18.2 An autocompletion tool for Python that can be used for text editors. jellyfish 0.11.2 Approximate and phonetic matching of strings. jinja2 3.1.2 A very fast and expressive template engine. jinja2-time 0.2.0 Jinja2 Extension for Dates and Times jsonschema 4.17.3 An implementation of JSON Schema validation for Python jupyter-bokeh 3.0.7 A Jupyter extension for rendering Bokeh content. jupyter-client 8.2.0 Jupyter protocol implementation and client libraries jupyter-core 5.3.0 Jupyter core package. A base package on which Jupyter projects rely. jupyterlab-pygments 0.2.2 Pygments theme using JupyterLab CSS variables jupyterlab-widgets 3.0.8 Jupyter interactive widgets for JupyterLab kaleido 0.2.1 Static image export for web-based visualization libraries with zero dependencies keyring 23.13.1 Store and access your passwords safely. lazy-object-proxy 1.9.0 A fast and thorough lazy object proxy. linkify-it-py 2.0.2 Links recognition library with FULL unicode support. lxml 4.9.2 Powerful and Pythonic XML processing library combining libxml2/libxslt with the ElementTree API. markdown 3.4.4 Python implementation of John Gruber's Markdown. markdown-it-py 3.0.0 Python port of markdown-it. Markdown parsing, done right! markupsafe 2.1.2 Safely add untrusted strings to HTML/XML markup. matplotlib-inline 0.1.6 Inline Matplotlib backend for Jupyter mccabe 0.7.0 McCabe checker, plugin for flake8 mdit-py-plugins 0.4.0 Collection of plugins for markdown-it-py mdurl 0.1.2 Markdown URL utilities mistune 2.0.5 A sane Markdown parser with useful plugins and renderers more-itertools 9.1.0 More routines for operating on iterables, beyond itertools msal 1.23.0 The Microsoft Authentication Library (MSAL) for Python library enables your app to access the Microsoft Cloud by supporting au...
msgpack 1.0.5 MessagePack serializer multitasking 0.0.11 Non-blocking Python methods using decorators mypy-extensions 1.0.0 Type system extensions for programs checked with the mypy type checker. nbclient 0.7.4 A client library for executing notebooks. Formerly nbconvert's ExecutePreprocessor. nbconvert 7.3.1 Converting Jupyter Notebooks nbformat 5.8.0 The Jupyter Notebook format nest-asyncio 1.5.6 Patch asyncio to allow nested event loops numpy 1.24.3 Fundamental package for array computing in Python numpydoc 1.5.0 Sphinx extension to support docstrings in Numpy format office365-rest-python-client 2.4.3 Microsoft 365 & Microsoft Graph Library for Python openpyxl 3.1.2 A Python library to read/write Excel 2010 xlsx/xlsm files packaging 23.1 Core utilities for Python packages pandarallel 1.6.5 An easy to use library to speed up computation (by parallelizing on multi CPUs) with pandas. pandas 2.0.1 Powerful data structures for data analysis, time series, and statistics pandocfilters 1.5.0 Utilities for writing pandoc filters in python panel 1.2.2 The powerful data exploration & web app framework for Python. param 1.13.0 Make your Python code clearer and more reliable by declaring Parameters. paramiko 3.1.0 SSH2 protocol library parso 0.8.3 A Python Parser pathspec 0.11.1 Utility library for gitignore style pattern matching of file paths. pexpect 4.8.0 Pexpect allows easy control of interactive console applications. pickleshare 0.7.5 Tiny 'shelve'-like database with concurrency support pillow 10.0.0 Python Imaging Library (Fork) platformdirs 3.5.0 A small Python package for determining appropriate platform-specific dirs, e.g. a "user data dir". plotly 5.14.1 An open-source, interactive data visualization library for Python pluggy 1.0.0 plugin and hook calling mechanisms for python prompt-toolkit 3.0.38 Library for building powerful interactive command lines in Python psutil 5.9.5 Cross-platform lib for process and system monitoring in Python. psycopg 3.1.9 PostgreSQL database adapter for Python psycopg-binary 3.1.9 PostgreSQL database adapter for Python -- C optimisation distribution psycopg2 2.9.6 psycopg2 - Python-PostgreSQL Database Adapter psycopg2-binary 2.9.6 psycopg2 - Python-PostgreSQL Database Adapter ptyprocess 0.7.0 Run a subprocess in a pseudo terminal pure-eval 0.2.2 Safely evaluate AST nodes without side effects py2vega 0.6.1 A Python to Vega-expression transpiler. pyarrow 12.0.0 Python library for Apache Arrow pycodestyle 2.10.0 Python style guide checker pycparser 2.21 C parser in Python pydocstyle 6.3.0 Python docstring style checker pyflakes 3.0.1 passive checker of Python programs pygments 2.15.1 Pygments is a syntax highlighting package written in Python. pyheck 0.1.5 Python bindings for heck, the Rust case conversion library pyjwt 2.8.0 JSON Web Token implementation in Python pylint 2.17.3 python code static checker pylint-venv 3.0.1 pylint-venv provides a Pylint init-hook to use the same Pylint installation with different virtual environments. pyls-spyder 0.4.0 Spyder extensions for the python-lsp-server pymysql 1.0.3 Pure Python MySQL Driver pynacl 1.5.0 Python binding to the Networking and Cryptography (NaCl) library pyodbc 4.0.39 DB API Module for ODBC pyorbital 1.7.3 Orbital parameters and astronomical computations in Python pyqt5 5.15.9 Python bindings for the Qt cross platform application toolkit pyqt5-qt5 5.15.2 The subset of a Qt installation needed by PyQt5. pyqt5-sip 12.12.1 The sip module support for PyQt5 pyqtwebengine 5.15.6 Python bindings for the Qt WebEngine framework pyqtwebengine-qt5 5.15.2 The subset of a Qt installation needed by PyQtWebEngine. pyreadline3 3.4.1 A python implementation of GNU readline. pyrsistent 0.19.3 Persistent/Functional/Immutable data structures python-dateutil 2.8.2 Extensions to the standard Python datetime module python-lsp-black 1.2.1 Black plugin for the Python LSP Server python-lsp-jsonrpc 1.0.0 JSON RPC 2.0 server library python-lsp-server 1.7.2 Python Language Server for the Language Server Protocol python-slugify 8.0.1 A Python slugify application that also handles Unicode pytoolconfig 1.2.5 Python tool configuration pytz 2023.3 World timezone definitions, modern and historical pyviz-comms 3.0.0 A JupyterLab extension for rendering HoloViz content. pywin32 306 Python for Window Extensions pywin32-ctypes 0.2.0 pywinpty 2.0.10 Pseudo terminal support for Windows from Python. pyyaml 6.0 YAML parser and emitter for Python pyzmq 25.0.2 Python bindings for 0MQ qdarkstyle 3.1 The most complete dark/light style sheet for C++/Python and Qt applications qstylizer 0.2.2 Stylesheet Generator for PyQt{4-5}/PySide{1-2} qtawesome 1.2.3 FontAwesome icons in PyQt and PySide applications qtconsole 5.4.3 Jupyter Qt console qtpy 2.3.1 Provides an abstraction layer on top of the various Qt bindings (PyQt5/6 and PySide2/6). questdb 1.1.0 QuestDB client library for Python reactivex 4.0.4 ReactiveX (Rx) for Python requests 2.29.0 Python HTTP for Humans. retrying 1.3.4 Retrying rope 1.8.0 a python refactoring library... rtree 1.0.1 R-Tree spatial index for Python GIS scipy 1.10.1 Fundamental algorithms for scientific computing in Python setuptools 68.0.0 Easily download, build, install, upgrade, and uninstall Python packages simple-file-checksum 1.2.2 Returns the MD5, SHA1, SHA256, SHA384, or SHA512 checksum of a file. six 1.16.0 Python 2 and 3 compatibility utilities smmap 5.0.0 A pure Python implementation of a sliding window memory map manager snowballstemmer 2.2.0 This package provides 29 stemmers for 28 languages generated from Snowball algorithms. sortedcontainers 2.4.0 Sorted Containers -- Sorted List, Sorted Dict, Sorted Set soupsieve 2.4.1 A modern CSS selector implementation for Beautiful Soup. sphinx 7.0.0 Python documentation generator sphinxcontrib-applehelp 1.0.4 sphinxcontrib-applehelp is a Sphinx extension which outputs Apple help books sphinxcontrib-devhelp 1.0.2 sphinxcontrib-devhelp is a sphinx extension which outputs Devhelp document. sphinxcontrib-htmlhelp 2.0.1 sphinxcontrib-htmlhelp is a sphinx extension which renders HTML help files sphinxcontrib-jsmath 1.0.1 A sphinx extension which renders display math in HTML via JavaScript sphinxcontrib-qthelp 1.0.3 sphinxcontrib-qthelp is a sphinx extension which outputs QtHelp document. sphinxcontrib-serializinghtml 1.1.5 sphinxcontrib-serializinghtml is a sphinx extension which outputs "serialized" HTML files (json and pickle). spyder 5.4.3 The Scientific Python Development Environment spyder-kernels 2.4.3 Jupyter kernels for Spyder's console spyder-terminal 1.2.2 Spyder Plugin for displaying a virtual terminal (OS independent) inside the main Spyder window sqlalchemy 2.0.12 Database Abstraction Library sqlparse 0.4.4 A non-validating SQL parser. stack-data 0.6.2 Extract data from python stack frames and tracebacks for informative displays tenacity 8.2.2 Retry code until it succeeds terminado 0.17.1 Tornado websocket backend for the Xterm.js Javascript terminal emulator library. text-unidecode 1.3 The most basic Text::Unidecode port textdistance 4.5.0 Compute distance between the two texts. three-merge 0.1.1 Simple library for merging two strings with respect to a base one tinycss2 1.2.1 A tiny CSS parser toml 0.10.2 Python Library for Tom's Obvious, Minimal Language tomlkit 0.11.8 Style preserving TOML library tornado 6.3.1 Tornado is a Python web framework and asynchronous networking library, originally developed at FriendFeed. tqdm 4.65.1 Fast, Extensible Progress Meter traitlets 5.9.0 Traitlets Python configuration system traittypes 0.2.1 Scipy trait types typing-extensions 4.5.0 Backported and Experimental Type Hints for Python 3.7+ tzdata 2023.3 Provider of IANA time zone data tzlocal 5.0.1 tzinfo object for the local timezone uc-micro-py 1.0.2 Micro subset of unicode data files for linkify-it-py projects. ujson 5.7.0 Ultra fast JSON encoder and decoder for Python urllib3 1.26.15 HTTP library with thread-safe connection pooling, file post, and more. uuid 1.30 UUID object and generation functions (Python 2.3 or higher) watchdog 3.0.0 Filesystem events monitoring wcwidth 0.2.6 Measures the displayed width of unicode strings in a terminal webencodings 0.5.1 Character encoding aliases for legacy web content werkzeug 2.3.4 The comprehensive WSGI web application library. whatthepatch 1.0.4 A patch parsing and application library. widgetsnbextension 4.0.8 Jupyter interactive widgets for Jupyter Notebook wrapt 1.15.0 Module for decorators, wrappers and monkey patching. xarray 2023.4.2 N-D labeled arrays and datasets in Python xyzservices 2023.7.0 Source of XYZ tiles providers yapf 0.32.0 A formatter for Python code. yfinance 0.2.18 Download market data from Yahoo! Finance API zipp 3.15.0 Backport of pathlib-compatible object wrapper for zip files zope-interface 6.0 Interfaces for Python

sylvaint commented 10 months ago

Getting same error.

earshinov commented 4 months ago

Same problem. Already tried experimenting with different versions of jupyter-boken, bokeh, ipywidgets, panel etc. Added

 elif kind == "ColumnsPatched":
+    import sys
+    print(content, file=sys.stderr)
     model = content["model"]
     patches = content["data"]

     assert isinstance(model, ColumnDataSource)
     model.patch(patches, setter=setter)

to jupyter_bokeh/widgets.py directly inside my venv and got this:

{'kind': 'ColumnsPatched', 'attr': 'data', 'model': {'id': '0e79a6be-6a5d-46f3-a5ff-00145578fdab'}, 'patches': {'type': 'map', 'entries': [['name', [[7, 'value UPD']]]]}}

I have no idea where it comes from, but looks like it isn't the format jupyter_boken expects.

I am running this on Windows inside VS Code (with its built-in support for Jupyter notebooks).

maximlt commented 3 months ago

I've been able to reproduce and opened a tentative PR on jupyter_bokeh to fix the reported bug https://github.com/bokeh/jupyter_bokeh/pull/206.