marimo
marimo copied to clipboard
Marimo is unable to save to PNG for some (not all) notebooks
Describe the bug
Saving to PNG fails for some notebooks.
The toaster appears with the error message, but no information is logged to the browser console - no errors, warnings, etc are added.
Environment
{
"marimo": "0.9.16",
"OS": "Linux",
"OS Version": "5.15.0-124-generic",
"Processor": "x86_64",
"Python Version": "3.10.13",
"Binaries": {
"Browser": "--",
"Node": "--"
},
"Dependencies": {
"click": "8.1.7",
"docutils": "0.21.2",
"itsdangerous": "2.2.0",
"jedi": "0.19.1",
"markdown": "3.7",
"narwhals": "1.13.2",
"packaging": "24.1",
"psutil": "6.1.0",
"pygments": "2.18.0",
"pymdown-extensions": "10.11.2",
"pyyaml": "6.0.2",
"ruff": "0.7.1",
"starlette": "0.41.0",
"tomlkit": "0.13.2",
"typing-extensions": "4.12.2",
"uvicorn": "0.32.0",
"websockets": "12.0"
},
"Optional Dependencies": {
"altair": "5.4.1",
"pandas": "2.2.3",
"pyarrow": "17.0.0"
}
}
Code to reproduce
My guess is there's a failure in downloadByUrl here: https://github.com/marimo-team/marimo/blob/7dfbc560dbbe49678dbfaba6c7af437c53aa75b5/frontend/src/utils/download.ts#L18
But because there's no JS error emitted, I don't know exactly how to reproduce.
I've got a notebook with 2 Pandas DataFrames displayed and 4 Altair charts.
The DataFrames are displayed by returning the DF at the end of the cell as per https://docs.marimo.io/guides/working_with_data/dataframes.html#displaying-dataframes - so I'm assuming they're using mo.ui.table.
When I comment out the DataFrames, then the download works. When I switch to mo.plain(...) to render the DataFrames, then download works.
I don't think there's anything special about the DataFrames apart from they have a "large" number of columns - the first one is 37 columns, but the second one is a limited subset of columns aggregated.
Thanks for reporting. Are you able to get it to consistently fail? Are you able to share the code? It looks like chrome has a 2mb limit for what we are doing, but Firefox does not. What browser are you using? Can you try safari or Firefox?
Thanks for reporting.
NP 🫡
Are you able to get it to consistently fail?
Yes I think so - I was on Friday and I can check again today.
Are you able to share the code?
Not the exact notebook I have now because it's full of financials, but maybe I can find a way to strip it down.
It looks like chrome has a 2mb limit for what we are doing, but Firefox does not. What browser are you using?
Am on Firefox 132.
Can you try safari or Firefox?
Not sure what other browsers I can try with.
I think there are two possible avenues:
- See if it works in another browser, or
- Create a shareable notebook that fails.
Not sure what's best to push on.
If you can share a similar notebook, I can try in other browsers for you, and it will help us debug the issue.
Just some small updates here:
- Able to reproduce this with latest
0.9.27. - Have had two more notebooks fail to render PNG.
- Notebooks seem to need to have a "large" DataFrame in them to cause the failure. Previously I had "wide" data (more than 30 cols). This time I've got only 8 cols, but 1.2M rows.
- The most recent notebook had a single piece of information shown from its big DataFrame - a single column description:
round(df['samples_count'].describe(), 0)👈🏻 Once I comment this out, the notebook can be rendered to PNG. - PNG failure happens whether the download is triggered from the burger menu or the ctrl-K palette.
Sorry to drive by this old-ish issue, but any progress on this? This is currently affecting producing Mermaid diagrams with Marimo
Hi @joenash 👋🏻
Great that you've also experienced the failure - I've been getting worried it was just me 😅 . There hasn't been any progress on this that I can see. I've not been able to get time to build a reproducer.
Could you share a bit more about the scenario you're experiencing - are diagrams using the Marimo "save to PNG" feature? Are there any 'big' dataframes in the notebooks? What browsers is this affecting?
The same issue here. I am not displaying any dataframes directly, but using them in the plotly choropleth map and line graphs. Dataframes are 'big', especially the unemployment history dataframe. Those opensourced data I used inside my OSSConf25 github repository. Interesting, error saving to png occurs in Firefox, but not in Chromium web browser. Even in Chromium, plotly choropleth map is not displayed in saved png (but the line graphs are OK). I think, the configuration option for disabling 'Download to PNG' will be useful. The same results can be achieved by simple screenshots :-)
Hey @jamescooke, thanks for the response!
In my case, I’m unable to export any mermaid diagram to PNG, from a fresh notebook with no other contents/anything in memory. E.g. if I did mo.mermaid with a simple mermaid example, no dataframes, it will render fine, but export gives the failure message. Like @misolietavec above I’ve resorted to opening it fullscreen and screenshotting (which in practice is fine).
This is on Firefox and Chrome running under Windows 10, with Marimo running on Ubuntu 20.04 WSL2