Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

fix: auto-install pyarrow when polars+mo.sql present in wasm (#3983)

Akshay Agrawal9a3183fe49ec
diff --git a/frontend/src/components/editor/__tests__/data-attributes.test.tsx b/frontend/src/components/editor/__tests__/data-attributes.test.tsx
index a3a5533c4d..6754029dfa 100644
--- a/frontend/src/components/editor/__tests__/data-attributes.test.tsx
+++ b/frontend/src/components/editor/__tests__/data-attributes.test.tsx
@@ -56,6 +56,7 @@ describe("Cell data attributes", () => {
watcher_on_save: "lazy",
output_max_bytes: 1_000_000,
std_stream_max_bytes: 1_000_000,
+ pythonpath: [],
},
server: {
browser: "default",
diff --git a/frontend/src/core/islands/worker/worker.tsx b/frontend/src/core/islands/worker/worker.tsx
index 9e15fb6ee8..6a092687a7 100644
--- a/frontend/src/core/islands/worker/worker.tsx
+++ b/frontend/src/core/islands/worker/worker.tsx
@@ -90,6 +90,13 @@ const requestHandler = createRPCRequestHandler({
code = `import pandas\n${code}`;
code = `import duckdb\n${code}`;
code = `import sqlglot\n${code}`;
+
+ // Polars + SQL requires pyarrow, and installing
+ // after notebook load does not work. As a heuristic,
+ // if it appears that the notebook uses polars, add pyarrow.
+ if (code.includes("polars")) {
+ code = `import pyarrow\n${code}`;
+ }
}
await self.pyodide.loadPackagesFromImports(code, {
diff --git a/frontend/src/core/wasm/worker/bootstrap.ts b/frontend/src/core/wasm/worker/bootstrap.ts
index 342520a95a..3045818481 100644
--- a/frontend/src/core/wasm/worker/bootstrap.ts
+++ b/frontend/src/core/wasm/worker/bootstrap.ts
@@ -166,6 +166,13 @@ export class DefaultWasmController implements WasmController {
code = `import pandas\n${code}`;
code = `import duckdb\n${code}`;
code = `import sqlglot\n${code}`;
+
+ // Polars + SQL requires pyarrow, and installing
+ // after notebook load does not work. As a heuristic,
+ // if it appears that the notebook uses polars, add pyarrow.
+ if (code.includes("polars")) {
+ code = `import pyarrow\n${code}`;
+ }
}
// Add:
diff --git a/frontend/src/core/wasm/worker/worker.ts b/frontend/src/core/wasm/worker/worker.ts
index 5a879ee115..50c2d37d4d 100644
--- a/frontend/src/core/wasm/worker/worker.ts
+++ b/frontend/src/core/wasm/worker/worker.ts
@@ -141,6 +141,13 @@ const requestHandler = createRPCRequestHandler({
code = `import pandas\n${code}`;
code = `import duckdb\n${code}`;
code = `import sqlglot\n${code}`;
+
+ // Polars + SQL requires pyarrow, and installing
+ // after notebook load does not work. As a heuristic,
+ // if it appears that the notebook uses polars, add pyarrow.
+ if (code.includes("polars")) {
+ code = `import pyarrow\n${code}`;
+ }
}
await self.pyodide.loadPackagesFromImports(code, {