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

[BUG] updating table view causes the table to disappear #12916

Open
benduffy1 opened this issue Mar 7, 2023 · 6 comments
Open

[BUG] updating table view causes the table to disappear #12916

benduffy1 opened this issue Mar 7, 2023 · 6 comments

Comments

@benduffy1
Copy link

Software versions

Python version : 3.10.8 (main, Nov 4 2022, 08:45:25) [Clang 12.0.0 ]
IPython version : 8.8.0
Tornado version : 6.2
Bokeh version : 3.0.3
BokehJS static path : /Users/ben/miniconda3/envs/image-labeller/lib/python3.10/site-packages/bokeh/server/static
node.js version : v16.13.1
npm version : 8.1.2
Operating system : macOS-12.6-arm64-arm-64bit

Browser name and version

firefox opera chrome

Jupyter notebook / Jupyter Lab version

No response

Expected behavior

trying to dynamically update the table view by setting a DataTable's view, I expected it to update the view as happens in bokeh 2.4, but instead the table disappears entirely in 3.03. Not sure if this is expected because of user error or if this is a bug..

Observed behavior

table no longer displays in browser after it updates

Example code

import numpy as np
import pandas as pd
from bokeh.layouts import column
from bokeh.models import DataTable, ColumnDataSource, TableColumn, BooleanFilter, CDSView, IndexFilter
from bokeh.server.server import Server
from tornado.ioloop import IOLoop


class T:
    def __call__(self, doc):
        self.doc = doc
        data = pd.DataFrame(np.random.random([10, 10]))
        data.columns = [str(x) for x in data.columns]
        self.source = ColumnDataSource(data=data)
        cols = [TableColumn(field=x) for x in data.columns]

        self.table = DataTable(source=self.source, columns=cols)
        self.doc.add_root(column(self.table))
        self.doc.add_periodic_callback(self.rand_view, 5000)

    def rand_view(self):
        self.table.view = CDSView(filter=IndexFilter([np.random.randint(0, len(self.source.data))]))


if __name__ == '__main__':

    io_loop = IOLoop.current()
    app_factory = T()

    server = Server({"/": app_factory}, io_loop=io_loop, port=int(5006))
    server.start()

    io_loop.add_callback(server.show, "/")
    io_loop.start()

Stack traceback or browser console output

No response

Screenshots

No response

@mattpap
Copy link
Contributor

mattpap commented Mar 8, 2023

Fails with:

properties.js:96 Uncaught Error: CDSView(p1291).indices is unset
    at PrimitiveProperty.get_value (properties.js:96:1)
    at CDSView.get [as indices] (has_props.js:66:1)
    at TableDataProvider.init (data_table.js:39:1)
    at new TableDataProvider (data_table.js:32:1)
    at DataTableView._after_render (data_table.js:304:1)
    at DataTableView.after_render (layout_dom.js:373:1)
    at DataTableView.<anonymous> (data_table.js:135:1)
    at DataTableView.new_slot (view.js:14:1)
    at Signal0.emit (signaling.js:50:1)
    at Signal0.emit (signaling.js:59:1)

@mattpap
Copy link
Contributor

mattpap commented Mar 8, 2023

This works:

self.table.view.filter = IndexFilter([np.random.randint(0, len(self.source.data))])

and is preferable to replacing CDSView.

@mattpap mattpap added this to the 3.2 milestone Mar 8, 2023
@benduffy1
Copy link
Author

thanks for responding so quickly.. I tried that as well but for me changing the filter doesn't update the displayed table, unless I'm using that wrong

@mattpap
Copy link
Contributor

mattpap commented Mar 8, 2023

Updating filter is indeed broken in 3.0. It's fixed in 3.1rc. Bokeh 3.1 will be released this week.

@benduffy1
Copy link
Author

ah i see okay, great thank you !

@bryevdv
Copy link
Member

bryevdv commented Mar 8, 2023

Should we make view properties themselves readonly, similar to source.selections to encourage updating only via setting filter ? These days there is always a default "all" view, correct?

@mattpap mattpap modified the milestones: 3.2, 3.3 Jun 14, 2023
@mattpap mattpap modified the milestones: 3.3, 3.x Oct 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants