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
docs: convert gifs to webm for better performance (#3478)
Myles Scolnickaf17db479482
diff --git a/docs/_static/docs-dataframe-table.webm b/docs/_static/docs-dataframe-table.webmnew file mode 100644index 0000000000..5ef1d2112aBinary files /dev/null and b/docs/_static/docs-dataframe-table.webm differdiff --git a/docs/_static/docs-dataframe-transform.webm b/docs/_static/docs-dataframe-transform.webmnew file mode 100644index 0000000000..86f09a88d4Binary files /dev/null and b/docs/_static/docs-dataframe-transform.webm differdiff --git a/docs/_static/docs-delete-cell.webm b/docs/_static/docs-delete-cell.webmnew file mode 100644index 0000000000..ce4f51a195Binary files /dev/null and b/docs/_static/docs-delete-cell.webm differdiff --git a/docs/_static/docs-df.webm b/docs/_static/docs-df.webmnew file mode 100644index 0000000000..28fc15b398Binary files /dev/null and b/docs/_static/docs-df.webm differdiff --git a/docs/_static/docs-disable-cell.webm b/docs/_static/docs-disable-cell.webmnew file mode 100644index 0000000000..46ea7c74e4Binary files /dev/null and b/docs/_static/docs-disable-cell.webm differdiff --git a/docs/_static/docs-enable-cell.webm b/docs/_static/docs-enable-cell.webmnew file mode 100644index 0000000000..41a3667981Binary files /dev/null and b/docs/_static/docs-enable-cell.webm differdiff --git a/docs/_static/docs-intro-app.webm b/docs/_static/docs-intro-app.webmnew file mode 100644index 0000000000..ff44c771cdBinary files /dev/null and b/docs/_static/docs-intro-app.webm differdiff --git a/docs/_static/docs-intro.webm b/docs/_static/docs-intro.webmnew file mode 100644index 0000000000..5f28b6798cBinary files /dev/null and b/docs/_static/docs-intro.webm differdiff --git a/docs/_static/docs-markdown-toggle.webm b/docs/_static/docs-markdown-toggle.webmnew file mode 100644index 0000000000..3797836163Binary files /dev/null and b/docs/_static/docs-markdown-toggle.webm differdiff --git a/docs/_static/docs-model-comparison.webm b/docs/_static/docs-model-comparison.webmnew file mode 100644index 0000000000..f039ae2754Binary files /dev/null and b/docs/_static/docs-model-comparison.webm differdiff --git a/docs/_static/docs-state-counter.webm b/docs/_static/docs-state-counter.webmnew file mode 100644index 0000000000..7f84419684Binary files /dev/null and b/docs/_static/docs-state-counter.webm differdiff --git a/docs/_static/docs-state-task-list.webm b/docs/_static/docs-state-task-list.webmnew file mode 100644index 0000000000..3374f438f5Binary files /dev/null and b/docs/_static/docs-state-task-list.webm differdiff --git a/docs/_static/docs-state-tied.webm b/docs/_static/docs-state-tied.webmnew file mode 100644index 0000000000..e6a2b54e9fBinary files /dev/null and b/docs/_static/docs-state-tied.webm differdiff --git a/docs/_static/embedding.webm b/docs/_static/embedding.webmnew file mode 100644index 0000000000..b611d36b53Binary files /dev/null and b/docs/_static/embedding.webm differdiff --git a/docs/_static/faq-marimo-ui.webm b/docs/_static/faq-marimo-ui.webmnew file mode 100644index 0000000000..e6d47112f0Binary files /dev/null and b/docs/_static/faq-marimo-ui.webm differdiff --git a/docs/_static/intro_condensed.webm b/docs/_static/intro_condensed.webmnew file mode 100644index 0000000000..edee1d73e2Binary files /dev/null and b/docs/_static/intro_condensed.webm differdiff --git a/docs/_static/intro_tutorial.webm b/docs/_static/intro_tutorial.webmnew file mode 100644index 0000000000..9da5afe340Binary files /dev/null and b/docs/_static/intro_tutorial.webm differdiff --git a/docs/_static/outputs.webm b/docs/_static/outputs.webmnew file mode 100644index 0000000000..14035c39b3Binary files /dev/null and b/docs/_static/outputs.webm differdiff --git a/docs/_static/reactive.webm b/docs/_static/reactive.webmnew file mode 100644index 0000000000..dd6288753eBinary files /dev/null and b/docs/_static/reactive.webm differdiff --git a/docs/_static/readme-ui-form.webm b/docs/_static/readme-ui-form.webmnew file mode 100644index 0000000000..d5b6ed2dd1Binary files /dev/null and b/docs/_static/readme-ui-form.webm differdiff --git a/docs/_static/readme-ui.webm b/docs/_static/readme-ui.webmnew file mode 100644index 0000000000..53c228506dBinary files /dev/null and b/docs/_static/readme-ui.webm differdiff --git a/docs/_static/readme.webm b/docs/_static/readme.webmnew file mode 100644index 0000000000..58ed04faf1Binary files /dev/null and b/docs/_static/readme.webm differdiff --git a/docs/_static/share-wasm-link.webm b/docs/_static/share-wasm-link.webmnew file mode 100644index 0000000000..1268bb974eBinary files /dev/null and b/docs/_static/share-wasm-link.webm differdiff --git a/docs/faq.md b/docs/faq.mdindex 93bf291eec..c52464c951 100644--- a/docs/faq.md+++ b/docs/faq.md@@ -90,7 +90,8 @@ synchronized with the Python kernel: no callbacks, no observers, no manuallyre-running cells.<p align="center">-<img src="/_static/faq-marimo-ui.gif" width="600px" />+<video autoplay muted loop width="600px" align="center" src="/_static/faq-marimo-ui.webm">+</video></p>## Using marimodiff --git a/docs/getting_started/key_concepts.md b/docs/getting_started/key_concepts.mdindex 8c23800478..5a23185ead 100644--- a/docs/getting_started/key_concepts.md+++ b/docs/getting_started/key_concepts.md@@ -52,7 +52,8 @@ variables defined by that cell._ This is reactive execution.<div align="center"><figure>-<img src="/_static/reactive.gif" width="600px"/>+<video autoplay muted loop width="600px" align="center" src="/_static/reactive.webm">+</video></figure></div>@@ -106,7 +107,8 @@ other marimo elements to build rich composite outputs:<div align="center"><figure>-<img src="/_static/outputs.gif" width="600px"/>+<video autoplay muted loop width="600px" align="center" src="/_static/outputs.webm">+</video></figure></div>@@ -137,7 +139,8 @@ that can wrap other UI elements.<div align="center"><figure>-<img src="/_static/readme-ui.gif" width="600px"/>+<video autoplay muted loop width="600px" align="center" src="/_static/readme-ui.webm">+</video></figure></div>diff --git a/docs/getting_started/quickstart.md b/docs/getting_started/quickstart.mdindex c7a5be2435..a480219708 100644--- a/docs/getting_started/quickstart.md+++ b/docs/getting_started/quickstart.md@@ -138,6 +138,6 @@ all marimo notebooks in your current directory.<div align="center"><figure>-<img src="/assets/vscode-marimo.png" alt="VS Code extension for marimo"/>+<img src="/_static/vscode-marimo.png" alt="VS Code extension for marimo"/></figure></div>diff --git a/docs/guides/editor_features/overview.md b/docs/guides/editor_features/overview.mdindex 7174226a6f..debe379693 100644--- a/docs/guides/editor_features/overview.md+++ b/docs/guides/editor_features/overview.md@@ -128,7 +128,8 @@ Get a link to share your notebook via our [online playground](../wasm.md):<div align="center"><figure>-<img src="/_static/share-wasm-link.gif"/>+<video autoplay muted loop width="100%" height="100%" align="center" src="/_static/share-wasm-link.webm">+</video></figure></div>diff --git a/docs/guides/interactivity.md b/docs/guides/interactivity.mdindex 451848a26b..d10af0e1ad 100644--- a/docs/guides/interactivity.md+++ b/docs/guides/interactivity.md@@ -7,7 +7,8 @@ global variable automatically runs all cells that reference it.**<div align="center"><figure>-<img src="/_static/readme-ui.gif"/>+<video autoplay muted loop width="100%" height="100%" align="center" src="/_static/readme-ui.webm">+</video></figure></div>@@ -74,7 +75,8 @@ value on form submission.<div align="center"><figure>-<img src="/_static/readme-ui-form.gif"/>+<video autoplay muted loop width="100%" height="100%" align="center" src="/_static/readme-ui-form.webm">+</video><figcaption>Use a form to gate value updates on submission</figcaption></figure></div>diff --git a/docs/guides/outputs.md b/docs/guides/outputs.mdindex e90edc5e96..91e067d31e 100644--- a/docs/guides/outputs.md+++ b/docs/guides/outputs.md@@ -7,7 +7,8 @@ documented in the [API reference](../api/index.md).<div align="center"><figure>-<img src="/_static/outputs.gif"/>+<video autoplay muted loop width="100%" height="100%" align="center" src="/_static/outputs.webm">+</video></figure></div>@@ -73,7 +74,8 @@ top right.<div align="center"><figure>-<img src="/_static/docs-markdown-toggle.gif"/>+<video autoplay muted loop width="100%" height="100%" align="center" src="/_static/docs-markdown-toggle.webm">+</video><figcaption>marimo is pure Python, even when you're using markdown.</figcaption></figure></div>diff --git a/docs/guides/publishing/playground.md b/docs/guides/publishing/playground.mdindex 88094a533d..ba249ba0ed 100644--- a/docs/guides/publishing/playground.md+++ b/docs/guides/publishing/playground.md@@ -123,7 +123,8 @@ link` to get a `marimo.app/...` URL representing your notebook:<div align="center"><figure>-<img src="/_static/share-wasm-link.gif"/>+<video autoplay muted loop width="100%" height="100%" align="center" src="/_static/share-wasm-link.webm">+</video></figure></div>diff --git a/docs/guides/reactivity.md b/docs/guides/reactivity.mdindex 96604effda..4bcda2f18f 100644--- a/docs/guides/reactivity.md+++ b/docs/guides/reactivity.md@@ -67,7 +67,8 @@ eliminates a common cause of bugs in traditional notebooks like Jupyter.<!-- <div align="center"><figure>-<img src="/_static/docs-delete-cell.gif"/>+<video autoplay muted loop width="100%" height="100%" align="center" src="/_static/docs-delete-cell.webm">+</video><figcaption>No hidden state: deleting a cell deletes its variables.</figcaption></figure></div> -->@@ -195,7 +196,8 @@ disabled, it and its dependents are blocked from running.<div align="center"><figure>-<img src="/_static/docs-disable-cell.gif"/>+<video autoplay muted loop width="100%" height="100%" align="center" src="/_static/docs-disable-cell.webm">+</video><figcaption>Disabling a cell blocks it from running.</figcaption></figure></div>@@ -205,7 +207,8 @@ disabled, marimo will automatically run it.<div align="center"><figure>-<img src="/_static/docs-enable-cell.gif"/>+<video autoplay muted loop width="100%" height="100%" align="center" src="/_static/docs-enable-cell.webm">+</video><figcaption>Enable a cell through the context menu. Stale cells runautomatically.</figcaption></figure>diff --git a/docs/guides/state.md b/docs/guides/state.mdindex f57b889ae5..36ca8dea7d 100644--- a/docs/guides/state.md+++ b/docs/guides/state.md@@ -42,7 +42,8 @@ But sometimes, you might want interactions to mutate state:<div align="center" style="margin-top:2rem; margin-bottom:2rem"><figure>-<img src="/_static/docs-state-task-list.gif"/>+<video autoplay muted loop width="100%" height="100%" align="center" src="/_static/docs-state-task-list.webm">+</video></figure><figcaption>A proof-of-concept TODO list made using state.</figcaption></div>@@ -52,7 +53,8 @@ But sometimes, you might want interactions to mutate state:<div align="center" style="margin-top:2rem; margin-bottom:2rem"><figure>-<img src="/_static/docs-state-tied.gif"/>+<video autoplay muted loop width="100%" height="100%" align="center" src="/_static/docs-state-tied.webm">+</video><figcaption>Use state to tie two elements together in a cycle.</figcaption></figure></div>@@ -153,7 +155,8 @@ implementation using state is simpler.<div align="center"><figure>-<img src="/_static/docs-state-counter.gif"/>+<video autoplay muted loop width="100%" height="100%" align="center" src="/_static/docs-state-counter.webm">+</video></figure></div>@@ -195,7 +198,8 @@ value depends on the other. This is impossible to do without `mo.state`.<div align="center"><figure>-<img src="/_static/docs-state-tied.gif"/>+<video autoplay muted loop width="100%" height="100%" align="center" src="/_static/docs-state-tied.webm">+</video></figure></div>@@ -249,7 +253,8 @@ The next few cells use state to create a todo list.<div align="center"><figure>-<img src="/_static/docs-state-task-list.gif"/>+<video autoplay muted loop width="100%" height="100%" align="center" src="/_static/docs-state-task-list.webm">+</video></figure></div>diff --git a/docs/guides/working_with_data/dataframes.md b/docs/guides/working_with_data/dataframes.mdindex c24d4d3438..7fc21be1a4 100644--- a/docs/guides/working_with_data/dataframes.md+++ b/docs/guides/working_with_data/dataframes.md@@ -17,7 +17,7 @@ marimo lets you page through, search, sort, and filter dataframes, making itextremely easy to get a feel for your data.<figure>-<video autoplay controls loop width="100%" height="100%" align="center" src="/_static/docs-df.mp4">+<video autoplay muted loop width="100%" height="100%" align="center" src="/_static/docs-df.webm"></video><figcaption>marimo brings dataframes to life.</figcaption></figure>@@ -86,7 +86,8 @@ notebook.<div align="center"><figure>-<img src="/_static/docs-dataframe-transform.gif"/>+<video autoplay muted loop width="100%" height="100%" align="center" src="/_static/docs-dataframe-transform.webm">+</video><figcaption>Build transformations using a GUI</figcaption></figure></div>@@ -200,7 +201,8 @@ dataframe_.<div align="center"><figure>-<img src="/_static/docs-dataframe-table.gif"/>+<video autoplay muted loop width="100%" height="100%" align="center" src="/_static/docs-dataframe-table.webm">+</video><figcaption>Select rows in a table, get them back as a dataframe</figcaption></figure></div>diff --git a/docs/guides/working_with_data/plotting.md b/docs/guides/working_with_data/plotting.mdindex 7d5b74dc21..daf91c41a8 100644--- a/docs/guides/working_with_data/plotting.md+++ b/docs/guides/working_with_data/plotting.md@@ -69,7 +69,8 @@ automatically made available as Pandas dataframes in Python._<div align="center"><figure>-<img src="/_static/docs-intro.gif" width="600px"/>+<video autoplay muted loop width="600px" align="center" src="/_static/docs-intro.webm">+</video></figure></div>diff --git a/docs/hooks.py b/docs/hooks.pynew file mode 100644index 0000000000..b70a8adc03--- /dev/null+++ b/docs/hooks.py@@ -0,0 +1,26 @@+import re+from pathlib import Path+from typing import Any+++def on_page_markdown(markdown: str, **kwargs: Any) -> str:+ del kwargs+ static_dir = Path("docs/")+ if not static_dir.exists():+ return markdown++ # Find all src="/" patterns+ pattern = r'src="(/[^"]+)"'+ matches = re.finditer(pattern, markdown)++ for match in matches:+ src_path = match.group(1)+ # Remove leading slash and check if file exists in _static+ relative_path = src_path.lstrip("/")+ full_path = static_dir / relative_path++ if not full_path.exists():+ print(f"⚠️ Warning: Static asset not found: {src_path}")+ print(f" Expected at: {full_path}")++ return markdowndiff --git a/docs/index.md b/docs/index.mdindex b35273fe68..c494b5f6de 100644--- a/docs/index.md+++ b/docs/index.md@@ -75,7 +75,8 @@ reference its variables, eliminating the error-prone task of manuallyre-running cells. Delete a cell and marimo scrubs its variables from programmemory, eliminating hidden state.-<img src="https://raw.githubusercontent.com/marimo-team/marimo/main/docs/_static/reactive.gif" width="700px" />+<video autoplay muted loop width="700px" align="center" src="/_static/reactive.webm">+</video><a name="expensive-notebooks"></a>@@ -93,13 +94,14 @@ transformers](api/inputs/dataframe.md), and [chatinterfaces](api/inputs/chat.md), and the cells thatuse them are automatically re-run with their latest values.-<img src="https://raw.githubusercontent.com/marimo-team/marimo/main/docs/_static/readme-ui.gif" width="700px" />+<video autoplay muted loop width="700px" align="center" src="/_static/readme-ui.webm">+</video>**Interactive dataframes.** [Page through, search, filter, andsort](./guides/working_with_data/dataframes.md)millions of rows blazingly fast, no code required.-<img src="_static/docs-df.gif">+<video autoplay muted loop width="100%" height="100%" align="center" src="/_static/docs-df.mp4">**Performant runtime.** marimo runs only those cells that need to be run bystatically analyzing your code.@@ -155,7 +157,8 @@ code hidden and uneditable:marimo run your_notebook.py```-<img src="https://raw.githubusercontent.com/marimo-team/marimo/main/docs/_static/docs-model-comparison.gif" style="border-radius: 8px" width="450px" />+<video autoplay muted loop width="450px" align="center" src="/_static/docs-model-comparison.webm" style="border-radius: 8px">+</video>**Execute as scripts.** Execute a notebook as a script at thecommand line:@@ -190,7 +193,8 @@ marimo is easy to get started with, with lots of room for power users.For example, here's an embedding visualizer made in marimo([video](https://marimo.io/videos/landing/full.mp4)):-<img src="https://raw.githubusercontent.com/marimo-team/marimo/main/docs/_static/embedding.gif" width="700px" />+<video autoplay muted loop width="700px" align="center" src="/_static/embedding.webm">+</video>Check out our [guides](guides/index.md), our [examplegallery](https://marimo.io/gallery), and our@@ -201,22 +205,26 @@ GitHub to learn more.<tr><td><a target="_blank" href="getting_started/key_concepts">- <img src="_static/reactive.gif" style="max-height: 150px; width: auto; display: block" />+ <video autoplay muted loop style="max-height: 150px; width: auto; display: block" src="/_static/reactive.webm">+ </video></a></td><td><a target="_blank" href="api/inputs/">- <img src="https://raw.githubusercontent.com/marimo-team/marimo/main/docs/_static/readme-ui.gif" style="max-height: 150px; width: auto; display: block" />+ <video autoplay muted loop style="max-height: 150px; width: auto; display: block" src="/_static/readme-ui.webm">+ </video></a></td><td><a target="_blank" href="guides/working_with_data/plotting">- <img src="https://raw.githubusercontent.com/marimo-team/marimo/main/docs/_static/docs-intro.gif" style="max-height: 150px; width: auto; display: block" />+ <video autoplay muted loop style="max-height: 150px; width: auto; display: block" src="/_static/docs-intro.webm">+ </video></a></td><td><a target="_blank" href="api/layouts/">- <img src="https://raw.githubusercontent.com/marimo-team/marimo/main/docs/_static/outputs.gif" style="max-height: 150px; width: auto; display: block" />+ <video autoplay muted loop style="max-height: 150px; width: auto; display: block" src="/_static/outputs.webm">+ </video></a></td></tr>diff --git a/scripts/convert_gif_to_webm.py b/scripts/convert_gif_to_webm.pynew file mode 100644index 0000000000..e6fdac9881--- /dev/null+++ b/scripts/convert_gif_to_webm.py@@ -0,0 +1,163 @@+import marimo++__generated_with = "0.10.13"+app = marimo.App(width="medium")+++def _():+ import marimo as mo++ return (mo,)++[email protected](hide_code=True)+def _(mo):+ mo.md(r"""# Convert gifs to webm format""")+ return+++def _(mo):+ mo.md(+ """+ You can either use the UI below or run:++ ```bash+ python convert_gif_to_webm.py -- --folder /path/to/folder+ ```+ """+ )+ return+++def _():+ import os+ import subprocess+ from pathlib import Path++ return Path, os, subprocess++[email protected](hide_code=True)+def _(Path, os, subprocess):+ def get_gifs_from_folder(input_folder):+ return list(Path(input_folder).glob("**/*.gif"))++ def convert_gif_to_webm(gif_files, force=False):+ if not gif_files:+ print("No GIF files found in the specified folder.")+ return++ print(f"Found {len(gif_files)} GIF files. Starting conversion...")++ for gif_path in gif_files:+ output_path = gif_path.with_suffix(".webm")++ def print_size_info(gif_path, output_path):+ original_size = os.path.getsize(gif_path)+ new_size = os.path.getsize(output_path)+ reduction = (1 - new_size / original_size) * 100+ print(f"Size reduced by {reduction:.1f}%")+ print(f"Original: {original_size/1024:.1f}KB")+ print(f"New: {new_size/1024:.1f}KB")+ print("-" * 50)++ if output_path.exists() and not force:+ print(f"Skipping {gif_path} - output already exists")+ print_size_info(gif_path, output_path)+ continue++ print(f"Converting: {gif_path}")++ try:+ # FFmpeg command to convert GIF to WebM+ cmd = [+ "ffmpeg",+ "-i",+ str(gif_path),+ "-c:v",+ "libvpx-vp9", # Use VP9 codec+ "-b:v",+ "1M", # Bitrate+ "-auto-alt-ref",+ "0",+ "-f",+ "webm",+ str(output_path),+ ]++ result = subprocess.run(+ cmd, capture_output=True, text=True, timeout=20+ )++ if result.returncode == 0:+ print(f"Successfully converted: {output_path}")+ print_size_info(gif_path, output_path)+ else:+ print(f"Error converting {gif_path}")+ print(f"Error: {result.stderr}")++ except subprocess.TimeoutExpired:+ print(+ f"Timeout converting {gif_path} - took longer than 20 seconds"+ )+ except Exception as e:+ print(f"Error processing {gif_path}: {str(e)}")++ return convert_gif_to_webm, get_gifs_from_folder+++def _(mo):+ files = mo.ui.file_browser(multiple=True)+ force = mo.ui.checkbox(label="Force overwrite existing files")+ return files, force+++def _(Path, files):+ gifs = [Path(f.path) for f in files.value]+ return (gifs,)+++def _(gifs, mo):+ run_selection = mo.ui.run_button(+ label="Convert selection", disabled=len(gifs) == 0+ )+ run_selection = mo.ui.run_button(+ label="Convert all in folder", disabled=len(gifs) == 0+ )+ run_selection+ return (run_selection,)+++def _(convert_gif_to_webm, gifs, mo, run_selection, force):+ if run_selection.value:+ with mo.status.spinner("Converting GIFs to WebM..."):+ convert_gif_to_webm(gifs, force=force.value)+ return+++def _(convert_gif_to_webm, get_gifs_from_folder, mo, os):+ folder_path = mo.cli_args().get("folder")+ _force = mo.cli_args().get("force")+ if _force is None:+ _force = False++ if mo.app_meta().mode != "script":+ mo.stop(True, "Not running as a script")++ if not os.path.exists(folder_path):+ raise Exception("Specified folder does not exist!")+ else:+ convert_gif_to_webm(get_gifs_from_folder(folder_path), force=_force)+ return folder_path+++if __name__ == "__main__":+ app.run()