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
5.39k stars 158 forks source link

polars pyo3_runtime.PanicException makes notebook unresponsive #1711

Closed ggggggggg closed 4 days ago

ggggggggg commented 4 days ago

Describe the bug

I create a new notebook, and paste the following into the first cell, and execute the code. The notebook is now unresponsive. As in when I enter 4 in the next cell, and hit shift-enter no output appears showing the result 4. In all other cases of exceptions, the notebook remains responsive, so I expect it to do so for this exception. Also I ran the same code in an ipython REPL. I get the same exception, but the REPL remains responsive. This leads me to believe the bug lies within Marimo rather than polars.

Environment

{ "marimo": "0.6.25", "OS": "Windows", "OS Version": "10", "Processor": "Intel64 Family 6 Model 85 Stepping 4, GenuineIntel", "Python Version": "3.10.11", "Binaries": { "Browser": "126.0.6478.127", "Node": "--" }, "Requirements": { "click": "8.1.7", "importlib-resources": "missing", "jedi": "0.19.0", "markdown": "3.6", "pymdown-extensions": "10.8.1", "pygments": "2.16.1", "tomlkit": "0.12.5", "uvicorn": "0.30.1", "starlette": "0.37.2", "websockets": "12.0", "typing-extensions": "4.7.1", "black": "23.7.0" } }

Code to reproduce

import polars as pl
import numpy as np
d = pl.DataFrame({"a": [np.arange(5) + i for i in range(5)]})
res = d.select(
    pl.col("a").map_batches(
        lambda x: {"filt_value": np.dot(x, x), "filt_phase": 5.0},
        is_elementwise=True),
    )
mscolnick commented 4 days ago

thanks for sharing this issue. this looks like a bug in marimo trying to stringify the variable for the variable explorerer

akshayka commented 4 days ago

@ggggggggg just cut version 0.6.26, which contains a fix. Should be on PyPI momentarily.