marimo-team / marimo

A reactive notebook for Python — run reproducible experiments, execute as a script, deploy as an app, and version with git.
https://marimo.io
Apache License 2.0
7.47k stars 258 forks source link

data table not updating properly anymore after pagination [regression] #2231

Open proycon opened 1 month ago

proycon commented 1 month ago

Describe the bug

We (@dirkroorda and I) found a regression in the display of polars dataframes in mo.ui.table. After pagination, the table is no longer responsive to changing input. (see code to reproduce). We think the problem was introduced in v0.8.4, probably in #2115 . At least versions v0.7.7 to v0.8.3 do have the expected behaviour.

Environment

{
  "marimo": "0.8.11",
  "OS": "Linux",
  "OS Version": "6.10.7-arch1-1",
  "Processor": "",
  "Python Version": "3.12.5",
  "Binaries": {
    "Browser": "--",
    "Node": "v22.8.0"
  },
  "Dependencies": {
    "click": "8.1.7",
    "importlib-resources": "missing",
    "jedi": "0.19.1",
    "markdown": "3.6",
    "pygments": "2.18.0",
    "pymdown-extensions": "10.8.1",
    "ruff": "0.5.2",
    "starlette": "0.37.2",
    "tomlkit": "0.13.0",
    "typing-extensions": "missing",
    "uvicorn": "0.30.1",
    "websockets": "12.0"
  },
  "Optional Dependencies": {
    "pandas": "2.2.2",
    "polars": "1.2.0"
  }
}

We also tested three different browsers (firefox, safari, chromium) and on both Linux and on mac.

Code to reproduce

The problem is apparent in this notebook: https://github.com/knaw-huc/brieven-van-hooft-notebook , steps to reproduce are:

  1. marimo run the notebook (starting it may take a while because of data download)
  2. In the section Exploring vocabularies, change the field datakey. You see the table below updates accordingly, do this a few times without doing anything else to see the intended behaviour.
  3. Now select datakey = recipient and navigate to page 2 in the table.
  4. Change the data key to something else again, the table now no longer updates! (this is the bug since v0.8.4, prior versions worked fine)
mscolnick commented 1 month ago

@proycon - thanks for filing and i am investingating this now. i am having a bit of issues running the notebook myself. couple questions that could help

  1. is the schema of the table changing when you change the datakey?
  2. are there any errors when running marimo edit (we hide some errors when in marimo run)
  3. if it only happens in marimo run, can you run with --redirect-console-to-browser and see if there is anything obvious in the browser console
proycon commented 1 month ago

Thanks for looking into this:

  1. is the schema of the table changing when you change the datakey?

No, it's always ["Value", "Occurences"].

  1. are there any errors when running marimo edit (we hide some errors when in marimo run)

No, the same problem reproduces in edit mode. There are no errors in stderr nor in the browser console.

proycon commented 1 month ago

Another relevant observation, if I switch to page 2 and then immediately back to page 1, and then change the datakey field, then the problem does not occur either!

mscolnick commented 1 month ago

I am getting [StamError] DeserializationError: Deserialization failed: EOF while parsing a string at line 31611423 column 13 when starting up the application (I am on macOS)

proycon commented 1 month ago

I am getting [StamError] DeserializationError: Deserialization failed: EOF while parsing a string at line 31611423 column 13 when starting up the application (I am on macOS)

I suddenly see that too now, wasn't there yesterday, I'm investigating...

proycon commented 1 month ago

That second issue (unrelated to the actual issue) looks like some kind of race condition in the cell execution order. As if it starts reading the file when it's not entirely flushed to disk yet? I don't know the details of it yet. If you restart the notebook once after the initial data download finishes, then it seems to be okay. I'm not sure yet, but I can reproduce that problem on marimo 0.8.9 and 0.8.11 (delete hoof001hwva.output.store.stam.json from $CWD to force redownload) , but not yet on 0.8.3 and 0.7.7, so I wonder it might be a second regression or a problem in my marimo code which didn't surface before?

proycon commented 1 month ago

I now made a separate issue for this spin-off problem we encountered while debugging the current issue: #2246

akshayka commented 1 month ago

@proycon is this still an issue, or could it be caused by the spin-off problem?

proycon commented 1 month ago

@proycon is this still an issue, or could it be caused by the spin-off problem?

This is still an issue yes (I tried the latest 0.8.13). After pagination the table's page seems 'stuck' that page, so when loading different data into it that has less than one page, it doesn't show at all. If loading data into it that does have that page, then it shows (at that specific page).