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.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
fix: wasm notebooks on ff (#839)
Myles Scolnickf3f297d7a1df
diff --git a/docs/guides/wasm.md b/docs/guides/wasm.mdindex 8a146d0f6c..58905d077f 100644--- a/docs/guides/wasm.md+++ b/docs/guides/wasm.md@@ -37,7 +37,6 @@ WASM notebooks are a new feature. If you run intoproblems, please open a [GitHub issue](https://github.com/marimo-team/marimo/issues).```-## Creating and sharing WASM notebooksWASM notebooks run at [marimo.app](https://marimo.app).@@ -70,7 +69,7 @@ Please be aware that marimo permalinks are publicly accessible.### Creating WASM notebooks from local notebooksIn the marimo editor's notebook action menu, use `Share > Create WebAssembly-link` to get a `marimo.app/...` URL representing your notebook:+link` to get a `marimo.app/...` URL representing your notebook:<div align="center"><figure>@@ -78,7 +77,6 @@ link` to get a `marimo.app/...` URL representing your notebook:</figure></div>-WASM notebooks come with common Python packages installed, but you may need to[install additional packages using micropip](#installing-packages).@@ -162,9 +160,9 @@ providing your users with an interactive code playground.```html<iframe- src="https://marimo.app/l/aojjhb?embed=true"- width="800"- height="300"+ src="https://marimo.app/l/aojjhb?embed=true"+ width="800"+ height="300"></iframe>```@@ -177,9 +175,9 @@ URL to your notebook](#creating-and-sharing-wasm-notebooks), then put it in an i```html<iframe- src="https://marimo.app/l/c7h6pz?embed=true"- width="800"- height="300"+ src="https://marimo.app/l/c7h6pz?embed=true"+ width="800"+ height="300"></iframe>```@@ -195,9 +193,9 @@ You can optionally render embedded notebooks in read-only mode by appending```html<iframe- src="https://marimo.app/l/c7h6pz?mode=read&embed=true"- width="800"- height="300"+ src="https://marimo.app/l/c7h6pz?mode=read&embed=true"+ width="800"+ height="300"></iframe>```@@ -211,7 +209,6 @@ have some limitations.**Packages.** Not all packages are available in WASM notebooks; see [Pyodide'sdocumentation on supported packages.](https://pyodide.org/en/stable/usage/packages-in-pyodide.html)-**Code completion.** Code completion and docstring hints are notcurrently supported. This will be fixed in the future.@@ -220,3 +217,9 @@ currently supported. This will be fixed in the future.**Threading and multi-processing.** WASM notebooks do not support multithreadingand multiprocessing. [This may be fixed in the future](https://github.com/pyodide/pyodide/issues/237).+## Browser support++WASM notebooks are supported in the latest versions of Chrome, Firefox, Edge, and Safari.++Chrome is the recommended browser for WASM notebooks as it seems to have the+best performance and compatibility.diff --git a/frontend/src/core/pyodide/worker/bootstrap.ts b/frontend/src/core/pyodide/worker/bootstrap.tsindex 20987c1c7a..b9204ddd9e 100644--- a/frontend/src/core/pyodide/worker/bootstrap.ts+++ b/frontend/src/core/pyodide/worker/bootstrap.ts@@ -6,7 +6,10 @@ import { SerializedBridge } from "./types";declare let loadPyodide:| undefined- | ((opts: { packages: string[] }) => Promise<PyodideInterface>);+ | ((opts: {+ packages: string[];+ indexURL: string;+ }) => Promise<PyodideInterface>);export async function bootstrap() {if (!loadPyodide) {@@ -18,29 +21,33 @@ export async function bootstrap() {// Perf: These get loaded while pyodide is being bootstrapped// The packages can be found here: https://pyodide.org/en/stable/usage/packages-in-pyodide.htmlpackages: ["micropip", "docutils", "Pygments"],+ // Without this, this fails in Firefox with+ // `Could not extract indexURL path from pyodide module`+ // This fixes for Firefox and does not break Chrome/others+ indexURL: "https://cdn.jsdelivr.net/pyodide/v0.25.0/full/",});// Install marimo and its dependenciesconst marimoWheel =process.env.NODE_ENV === "production"? "marimo >= 0.2.5"- : "http://localhost:8000/dist/marimo-0.2.6-py3-none-any.whl";+ : "http://localhost:8000/dist/marimo-0.2.8-py3-none-any.whl";await pyodide.runPythonAsync(`import micropipmicropip.add_mock_package("multiprocessing", "*", modules={- "multiprocessing": None,- "multiprocessing.connection": None,- "multiprocessing.context": None,- "multiprocessing.managers": None,- "multiprocessing.pool": None,- "multiprocessing.sharedctypes": None,- "multiprocessing.shared_memory": None,- "multiprocessing.spawn": None,+ "multiprocessing": None,+ "multiprocessing.connection": None,+ "multiprocessing.context": None,+ "multiprocessing.managers": None,+ "multiprocessing.pool": None,+ "multiprocessing.sharedctypes": None,+ "multiprocessing.shared_memory": None,+ "multiprocessing.spawn": None,})micropip.add_mock_package("jedi", "*", modules={- "jedi": None,- "jedi.api": None,+ "jedi": None,+ "jedi.api": None,})await micropip.install(@@ -51,8 +58,8 @@ export async function bootstrap() {"pymdown-extensions",],deps=False- );- `);+ );+ `);return pyodide;}