Skip to content

Commit eb00f96

Browse files
paddymulclaude
andauthored
fix: use Pyodide-bundled fastparquet for WASM marimo test (#532)
Install fastparquet and pyarrow from Pyodide's native WASM bundle before installing buckaroo with deps=False, avoiding micropip's dependency resolution failure on non-pure-Python wheels. - Pre-install fastparquet, pyarrow from Pyodide bundle in buckaroo_simple.py - Install buckaroo with deps=False to skip failing dep resolution - Add browser console/error capture to Playwright test for CI debugging - Increase test timeouts (120s widget, 180s global) for WASM compilation - Make serialization_utils.py handle missing fastparquet gracefully - Include generated WASM HTML output Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 01909fb commit eb00f96

693 files changed

Lines changed: 9940 additions & 17 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

buckaroo/serialization_utils.py

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@
55
from typing import Dict, Any, List, Tuple
66
from pandas._libs.tslibs import timezones
77
from pandas.core.dtypes.dtypes import DatetimeTZDtype
8-
from fastparquet import json as fp_json
8+
try:
9+
from fastparquet import json as fp_json
10+
HAS_FASTPARQUET = True
11+
except ImportError:
12+
fp_json = None
13+
HAS_FASTPARQUET = False
914
import logging
1015

1116
from buckaroo.df_util import old_col_new_col, to_chars
@@ -128,19 +133,20 @@ def pd_to_obj(df:pd.DataFrame) -> Dict[str, Any]:
128133
pass
129134

130135

131-
class MyJsonImpl(fp_json.BaseImpl):
132-
def __init__(self):
133-
pass
134-
#for some reason the following line causes errors, so I have to reimport ujson_dumps
135-
# from pandas._libs.json import ujson_dumps
136-
# self.dumps = ujson_dumps
136+
if HAS_FASTPARQUET:
137+
class MyJsonImpl(fp_json.BaseImpl):
138+
def __init__(self):
139+
pass
140+
#for some reason the following line causes errors, so I have to reimport ujson_dumps
141+
# from pandas._libs.json import ujson_dumps
142+
# self.dumps = ujson_dumps
137143

138-
def dumps(self, data):
139-
from pandas._libs.json import ujson_dumps
140-
return ujson_dumps(data, default_handler=str).encode("utf-8")
144+
def dumps(self, data):
145+
from pandas._libs.json import ujson_dumps
146+
return ujson_dumps(data, default_handler=str).encode("utf-8")
141147

142-
def loads(self, s):
143-
return self.api.loads(s)
148+
def loads(self, s):
149+
return self.api.loads(s)
144150

145151
def get_multiindex_to_cols_sers(index) -> List[Tuple[str, Any]]: #pd.Series[Any]
146152
if not isinstance(index, pd.MultiIndex):
@@ -168,6 +174,12 @@ def prepare_df_for_serialization(df:pd.DataFrame) -> pd.DataFrame:
168174
return df2
169175

170176
def to_parquet(df):
177+
if not HAS_FASTPARQUET:
178+
raise ImportError(
179+
"fastparquet is required for parquet serialization but is not installed. "
180+
"Install it with: pip install fastparquet"
181+
)
182+
171183
data: BytesIO = BytesIO()
172184

173185
# data.close doesn't work in pyodide, so we make close a no-op

docs/example-notebooks/marimo-wasm/buckaroo_simple.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,14 @@ async def _():
1212

1313
if "pyodide" in sys.modules:
1414
import micropip
15-
await micropip.install("buckaroo", keep_going=True)
15+
# Install native WASM packages from Pyodide's bundle first
16+
# (Pyodide 0.27.7 bundles fastparquet 2024.5.0, pyarrow, numpy, etc.)
17+
await micropip.install("fastparquet")
18+
await micropip.install("pyarrow")
19+
# Install buckaroo's pure-python deps, then buckaroo itself with deps=False
20+
# to skip dependency resolution (which fails on non-pure-Python deps)
21+
await micropip.install(["anywidget", "graphlib_backport", "cloudpickle"])
22+
await micropip.install("buckaroo", deps=False)
1623

1724
import buckaroo
1825
from buckaroo import BuckarooWidget, BuckarooInfiniteWidget

docs/extra-html/example_notebooks/buckaroo_simple/.nojekyll

Whitespace-only changes.

0 commit comments

Comments
 (0)