perspective icon indicating copy to clipboard operation
perspective copied to clipboard

Table 'remove' operation does not reflect jupyter widget data

Open ypldan opened this issue 4 years ago • 4 comments

Bug Report

Steps to Reproduce:

  1. Create table and update it with value:
from perspective import Table, PerspectiveWidget
import time
sample_schema = {
    'key': str,
    'value': int
}
sample_table = Table(sample_schema, limit=100, index='key')
sample_table.update([{'key': 'What is the answer?', 'value': 42}])
  1. Create and display widget:
sample_widget = PerspectiveWidget(sample_table, index='key')
sample_widget

Result: image

  1. Update and remove rows:
sample_table.update([{'key': 'Hej', 'value': 74}])
sample_table.remove(['Hej'])
sample_table.view().to_df()

Result: image 4. Display widget in other cell, content will be updated in both widgets:

sample_widget

Result: image

Expected Result:

According to docs on 'remove' method: Removes propagate to views derived from the table.

Actual Result:

Removes took no effect on widget.

Environment:

jovyan@jupyter:~$ jupyter labextension list
JupyterLab v3.1.8
/home/jovyan/.local/share/jupyter/labextensions
        @jupyter-widgets/jupyterlab-manager v3.0.1 enabled OK (python, jupyterlab_widgets)

Other labextensions (built into JupyterLab)
   app dir: /opt/conda/share/jupyter/lab
        @finos/perspective-jupyterlab v1.0.0 enabled OK

jovyan@jupyter:~$ pip3 list | grep perspective
perspective-python            1.0.0
jovyan@jupyter:~$ jupyter --version
Selected Jupyter core packages...
IPython          : 7.28.0
ipykernel        : 5.5.5
ipywidgets       : 7.6.5
jupyter_client   : 7.0.6
jupyter_core     : 4.8.1
jupyter_server   : 1.11.1
jupyterlab       : 3.1.8
nbclient         : 0.5.4
nbconvert        : 6.2.0
nbformat         : 5.1.3
notebook         : 6.4.3
qtconsole        : not installed
traitlets        : 5.1.0

ypldan avatar Oct 28 '21 10:10 ypldan

Thanks for the detailed report!

We're aware of this issue. This should only affects client mode, which has recently become the default for PerspectiveWidget - setting the kwarg server=True will use server mode and work around this for now, propagating removes correctly. Check out the docs on PerspectiveWidget.__init__() for more info.

widget = PerspectiveWidget(data, server=True)

We're working on getting this implemented for client-server replicated mode (which is now the default in PerspectiveWidget) - I'll update this issue when a release version is in the works.

texodus avatar Oct 31 '21 03:10 texodus

Thank you for response! I my case it resulted in widget stopped responding and updating. Could you please tell me, where I could learn how these two modes differ from each other? Also is there any ETA for client-server mode support?

ypldan avatar Nov 01 '21 09:11 ypldan

Server mode works fine on binder and I'm aware of no open issues with this specifically (and as I said, it was the default until just recently). If you're having issues with it, I need to see a repro.

There is an in-depth explanation of the various run modes in the docs.

texodus avatar Nov 01 '21 20:11 texodus

Thank you for link to explanation, I've just read it, and it became clear to me, why is this happening.

I'm basically using the widget to visualise order book using live tick L2 data.

Anyway, I found a workaround how to do that without "remove" operation in server-client mode, but still will wait for the update on remove operation for this mode.

Thank you!

ypldan avatar Nov 02 '21 07:11 ypldan