Get help from the marimo community

Updated 3 weeks ago

wasm published notebook with pandas read csv error

At a glance

The community members are trying to use pandas instead of polars in a sample code, but are encountering an exception: "BadGzipFile('Not a gzipped file (b'sp')')" when running the code. The issue seems to be related to the way GitHub Pages is handling the CSV file, as the code works fine in other environments. The community members suggest that the issue might be a bug in GitHub Pages headers or pandas, and one of them notes that using the "raw" URL of the CSV file on the master branch could be a workaround, although it would break the handy utility mo.notebook_location().

Useful resources
Trying to change the penguins sample to use pandas instead of polars, results in This cell raised an exception: BadGzipFile('Not a gzipped file (b'sp')')
Attachments
image.png
image.png
Marked as solution
We aren’t doing anything fancy, so might just be a bug in GH pages headers or pandas
View full solution
M
l
20 comments
Does the is work locally or just fails in wasm? Looks like pandas could be failing on incorrect headers. Maybe file an issue in their repo?
works normal other envs except when serving on gh pages
sorry, could have been clear that the issue with following the gh template
We aren’t doing anything fancy, so might just be a bug in GH pages headers or pandas
ok, would have to be using requests to get the csv contents then pass to pd to read as string, looks like pandas and polars have different opinion on url 😦
it appears to be that github pages returning the CSV as content-type: text/csv causing the issue on pandas although polars is happy to accept as is, so, another option is to use the "raw" url of the csv file on master branch, of course, this certainly "breaks" the handy utils mo.notebook_location()
isn't the content type content-type: text/csv correct?
why would pandas not like that?
ya, beats me 😦
btw, @Myles Scolnick how do we export wasm of python scripts file used in notebook?
Can you explain that a bit more?
suppose we move that build df into a local python package itself, and import the function in notebook to build the df. it would cause "package not found" on wasm notebook because the local package not being "packed" along with the wasm export
Ah I see. Marimo doesn’t handle this for you
We do somewhat if you build on our community cloud, but not when using “marimo export” from the cli
i see, meaning need to produce wheel for wasm notebook to do micropip import, or something else?
here's one way to build local wheel and install it using micropip

  1. build wheel, $ uv build
  2. copy the local wheel to the public folder of the wasm public folder
  3. on notebook, micropip install and use the wheel package as normal
    Plain Text
    whl = str(mo.notebook_location() / "public" / "utils-0.1.0-py3-none-any.whl")
    import micropip
    await micropip.install(whl)
    
    from utils import (...)
  4. export wasm of notebook as normal
is this what is expected with wheel install of local package in the context of marimo wasm, @Myles Scolnick ?
Yea that seems like a good solution to me
I’m not sure of another way
Add a reply
Sign up and join the conversation on Discord