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.

improve: examples (#2400)

Akshay Agrawal1c0c00b521e7
diff --git a/.github/workflows/test_cli.yaml b/.github/workflows/test_cli.yaml
index 6aaad146de..64ffda04cc 100644
--- a/.github/workflows/test_cli.yaml
+++ b/.github/workflows/test_cli.yaml
@@ -158,7 +158,6 @@ jobs:
run: |
uv pip install pytest pytest-asyncio
uv pip install ./marimo*whl
- uv pip install -r examples/requirements.txt
- name: Test examples
shell: bash
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 3ceda03d6a..c872e34a73 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -10,7 +10,7 @@ repos:
rev: v0.41.0
hooks:
- id: markdownlint-fix
- args: [-c, configs/.markdownlint.yaml, --fix]
+ args: [-c, configs/.markdownlint.yaml, --fix, --disable, MD028]
exclude: ^marimo/_tutorials/.*\.md
- repo: https://github.com/crate-ci/typos
diff --git a/examples/README.md b/examples/README.md
index c237f0c28d..9f68ef5639 100644
--- a/examples/README.md
+++ b/examples/README.md
@@ -2,6 +2,36 @@
This folder contains example marimo notebooks.
-- The requirements used by these notebooks are in `requirements.txt`.
-- Install the requirements in your virtual environment with `pip install -r requirements.txt`
-- Open an example with `marimo edit`
+- 🖱️ [`ui/`](ui/): marimo's many UI elements or widgets
+- 🛢️ [`sql/`](sql/): SQL and Python inter-op
+- 🤖 [`ai/`](ai/): AI-related examples
+- 📦 [`third_party/`](third_party/): using popular third-party packages in marimo
+- ☁️ [`cloud/`](cloud/): using various cloud providers
+- ✨ [`misc/`](misc/): miscellenous topical examples
+
+> [!NOTE]
+> Submit a
+> [pull request](https://github.com/marimo-team/marimo/pulls) to add an example!
+> We especially welcome library developers to add examples to `third_party/`.
+
+> [!Tip]
+> marimo ships with tutorials to help you get started: start with
+> `marimo tutorial intro` at the command line.
+
+## Running examples
+
+The requirements of each notebook are serialized in them as a top-level
+comment. Here are the steps to open an example notebook:
+
+1. [Install marimo](https://docs.marimo.io/getting_started/index.html#installation)
+2. [Install `uv`](https://github.com/astral-sh/uv/?tab=readme-ov-file#installation)
+3. Open an example with `marimo edit --sandbox <notebook.py>`.
+
+> [!TIP]
+> The [`--sandbox` flag](https://docs.marimo.io/guides/editor_features/package_management.html) opens the notebook in an isolated virtual environment, > automatically installing the notebook's dependencies 📦
+
+## More examples 🌟
+
+Every week, we highlight stellar examples and projects from our community.
+Check them out at our [marimo spotlights](https://github.com/marimo-team/spotlights)
+repo!
diff --git a/examples/ai/openai.py b/examples/ai/build_a_superhero.py
similarity index 77%
rename from examples/ai/openai.py
rename to examples/ai/build_a_superhero.py
index 3aafa2e695..7558231df1 100644
--- a/examples/ai/openai.py
+++ b/examples/ai/build_a_superhero.py
@@ -1,12 +1,20 @@
+# /// script
+# requires-python = ">=3.9"
+# dependencies = [
+# "marimo",
+# "openai==1.47.1",
+# ]
+# ///
+
import marimo
-__generated_with = "0.1.0"
+__generated_with = "0.8.19"
app = marimo.App()
[email protected](hide_code=True)
def __(mo):
- mo.md("## Build a Superhero with Generative AI")
+ mo.md("""## Build a Superhero with Generative AI""")
return
@@ -14,6 +22,7 @@ def __(mo):
def __(mo):
openaikey = mo.ui.text(label="🤖 OpenAI Key", kind="password")
config = mo.hstack([openaikey])
+
mo.accordion({"⚙️ Enter your OpenAI key": config})
return config, openaikey
@@ -22,7 +31,7 @@ def __(mo):
def __(mo):
item = mo.ui.text(label="Enter the name of an animal: ").form()
item
- return item,
+ return (item,)
@app.cell
@@ -30,7 +39,7 @@ def __(item, mo):
content = f"💬 Suggest three superhero names, given the following animal: {item.value}"
mo.md(content) if item.value else None
- return content,
+ return (content,)
@app.cell
@@ -54,32 +63,10 @@ def __(content, item, mo, openai, openaikey):
mo.md(
f"""
- 🤖 Response:
-
- {result}
- """
- ) if item.value else None
- result = None
- if item.value:
- response = openai.ChatCompletion.create(
- model="gpt-4-turbo",
- messages=[
- {
- "role": "system",
- "content": "You are a creative assistant. Your responses should use newlines.",
- },
- {"role": "user", "content": content},
- ],
- )
-
- result = response.choices[0].message.content
-
- mo.md(
- f"""
- 🤖 Response:
-
- {result}
- """
+ 🤖 Response:
+
+ {result}
+ """
) if item.value else None
return response, result
@@ -91,7 +78,7 @@ def __(mo, result):
mo.md(
f"""
- Choose a super hero: {superhero}
+ Choose a superhero: {superhero}
"""
) if result else None
return choices, superhero
@@ -131,7 +118,7 @@ def __(mo, openai, superhero):
def __(catchphrase, mo):
generate_image_button = mo.ui.button(label="📷 Generate Image")
generate_image_button if catchphrase else None
- return generate_image_button,
+ return (generate_image_button,)
@app.cell
diff --git a/examples/ai/micrograd_mlp.py b/examples/ai/micrograd_mlp.py
index 2ceec3a0de..dac1a892b4 100644
--- a/examples/ai/micrograd_mlp.py
+++ b/examples/ai/micrograd_mlp.py
@@ -1,14 +1,38 @@
+# /// script
+# requires-python = ">=3.9"
+# dependencies = [
+# "marimo",
+# "matplotlib==3.9.2",
+# "micrograd==0.1.0",
+# "numpy==1.26.4",
+# "scikit-learn==1.5.2",
+# ]
+# ///
+
import marimo
-__generated_with = "0.2.10"
+__generated_with = "0.8.19"
app = marimo.App()
[email protected](hide_code=True)
+def __(mo):
+ mo.md("""# Neural Networks with Micrograd""")
+ return
+
+
[email protected](hide_code=True)
def __(mo):
mo.md(
- r"""
- ### Micrograd demo
+ """
+ This marimo notebook trains a tiny **neural network** using
+ Andrej Karpathy's [micrograd
+ library](https://github.com/karpathy/micrograd).
+ Micrograd is an implementation of PyTorch-like automatic
+ differentiation using only Python scalar operations. This notebook was
+ adapted from a [demo
+ notebook](https://github.com/karpathy/micrograd/blob/master/demo.ipynb) by
+ Andrej.
"""
)
return
@@ -19,6 +43,9 @@ def __():
import random
import numpy as np
import matplotlib.pyplot as plt
+
+ np.random.seed(1337)
+ random.seed(1337)
return np, plt, random
@@ -29,41 +56,131 @@ def __():
return Layer, MLP, Neuron, Value
-def __(np, random):
- np.random.seed(1337)
- random.seed(1337)
[email protected](hide_code=True)
+def __(mo):
+ mo.md(
+ """
+ We start by generating a synthetic dataset of points labeled +1 or -1.
+ Our goal is to train a network that can classify these points according
+ to their labels, learning a decision boundary that separates them.
+ """
+ )
return
@app.cell
-def __(plt):
- # make up a dataset
-
+def __():
from sklearn.datasets import make_moons, make_blobs
X, y = make_moons(n_samples=100, noise=0.1)
-
y = y * 2 - 1 # make y be -1 or 1
- # visualize in 2D
- plt.figure(figsize=(5, 5))
- plt.scatter(X[:, 0], X[:, 1], c=y, s=20, cmap="jet")
return X, make_blobs, make_moons, y
@app.cell
-def __(MLP):
- # initialize a model
- model = MLP(2, [16, 16, 1]) # 2-layer neural network
+def __(X, mo, plt, y):
+ plt.figure(figsize=(5, 5))
+ mo.center(plt.scatter(X[:, 0], X[:, 1], c=y, s=20, cmap="jet"))
+ return
+
+
[email protected](hide_code=True)
+def __(mo):
+ mo.md(
+ """
+ Note that the decision boundary must be **nonlinear**, which can be readily
+ learned by neural networks. This could also be achieved by "shallow" or
+ classical machine learning methods with the appropriate featurization or
+ [kernelization](https://scikit-learn.org/stable/modules/svm.html).
+ """
+ )
+ return
+
+
[email protected](hide_code=True)
+def __(mo):
+ mo.md(
+ """
+ **Try it!** Train a neural network by hitting the "Train" button. The
+ learned decision boundary will be plotted below.
+
+ _Try experimenting with the parameters. What happens if you change
+ the number of layers and their sizes?_
+ """
+ )
+ return
+
+
+def __(mo):
+ n_layers = mo.ui.slider(
+ start=1, stop=2, step=1, value=2, show_value=True,
+ label="number of layers"
+ )
+ n_layers
+ return (n_layers,)
+
+
+def __(mo, n_layers):
+ layer_sizes = mo.ui.array([
+ mo.ui.slider(4, 16, step=1, value=12, show_value=True)
+ for i in range(n_layers.value)
+ ], label="layer sizes")
+
+ iterations = mo.ui.slider(
+ start=1,
+ stop=40,
+ step=1,
+ value=20,
+ show_value=True,
+ label="gradient steps"
+ )
+
+ training_parameters = mo.md(
+ """
+ {layer_sizes}
+
+ {iterations}
+ """
+ ).batch(layer_sizes=layer_sizes, iterations=iterations).form(
+ submit_button_label="Train",
+ bordered=False,
+ show_clear_button=True,
+ clear_button_label="Reset"
+ )
+
+ training_parameters
+ return iterations, layer_sizes, training_parameters
+
+
+def __(MLP, mo, n_layers, train, training_parameters):
+ mo.stop(
+ training_parameters.value is None,
+ mo.md("Click the `Train` button to continue").callout(kind="warn")
+ )
+
+ model = MLP(n_layers.value, training_parameters.value["layer_sizes"] + [1])
print(model)
print("number of parameters", len(model.parameters()))
- return model,
+
+ trained_model = train(
+ model,
+ iters=training_parameters.value["iterations"]
+ )
+ return model, trained_model
+
+
+def __(plot_decision_boundary, trained_model):
+ plot_decision_boundary(trained_model)
+ return
@app.cell
-def __(Value, X, model, np, y):
- # loss function
- def loss(batch_size=None):
+def __(Value, X, np, y):
+ def loss(model, batch_size=None):
# inline DataLoader :)
if batch_size is None:
@@ -89,76 +206,61 @@ def __(Value, X, model, np, y):
(yi > 0) == (scorei.data > 0) for yi, scorei in zip(yb, scores)
]
return total_loss, sum(accuracy) / len(accuracy)
-
- _total_loss, _acc = loss()
- print(_total_loss, _acc)
- return loss,
+ return (loss,)
@app.cell
-def __(loss, model):
- # optimization
- for k in range(20):
+def __(loss, mo):
+ def train(model, iters=20):
+ for k in mo.status.progress_bar(range(iters)):
+
+ # forward
+ total_loss, acc = loss(model)
- # forward
- total_loss, acc = loss()
+ # backward
+ model.zero_grad()
+ total_loss.backward()
- # backward
- model.zero_grad()
- total_loss.backward()
+ # update (sgd)
+ learning_rate = 1.0 - 0.9 * k / 100
+ for p in model.parameters():
+ p.data -= learning_rate * p.grad
- # update (sgd)
- learning_rate = 1.0 - 0.9 * k / 100
- for p in model.parameters():
- p.data -= learning_rate * p.grad
+ if k % 1 == 0:
+ print(f"step {k} loss {total_loss.data}, accuracy {acc*100}%")
- if k % 1 == 0:
- print(f"step {k} loss {total_loss.data}, accuracy {acc*100}%")
- return acc, k, learning_rate, p, total_loss
+ return model
+ return (train,)
@app.cell
-def __(Value, X, model, np, plt, y):
- # visualize decision boundary
-
- h = 0.25
- x_min, x_max = X[:, 0].min() - 1, X[:, 0].max() + 1
- y_min, y_max = X[:, 1].min() - 1, X[:, 1].max() + 1
- xx, yy = np.meshgrid(
- np.arange(x_min, x_max, h), np.arange(y_min, y_max, h)
- )
- Xmesh = np.c_[xx.ravel(), yy.ravel()]
- inputs = [list(map(Value, xrow)) for xrow in Xmesh]
- scores = list(map(model, inputs))
- Z = np.array([s.data > 0 for s in scores])
- Z = Z.reshape(xx.shape)
-
- fig = plt.figure()
- plt.contourf(xx, yy, Z, cmap=plt.cm.Spectral, alpha=0.8)
- plt.scatter(X[:, 0], X[:, 1], c=y, s=40, cmap=plt.cm.Spectral)
- plt.xlim(xx.min(), xx.max())
- plt.ylim(yy.min(), yy.max())
- plt.gca()
- return (
- Xmesh,
- Z,
- fig,
- h,
- inputs,
- scores,
- x_max,
- x_min,
- xx,
- y_max,
- y_min,
- yy,
- )
+def __(Value, X, np, plt, y):
+ def plot_decision_boundary(model):
+ h = 0.25
+ x_min, x_max = X[:, 0].min() - 1, X[:, 0].max() + 1
+ y_min, y_max = X[:, 1].min() - 1, X[:, 1].max() + 1
+ xx, yy = np.meshgrid(
+ np.arange(x_min, x_max, h), np.arange(y_min, y_max, h)
+ )
+ Xmesh = np.c_[xx.ravel(), yy.ravel()]
+ inputs = [list(map(Value, xrow)) for xrow in Xmesh]
+ scores = list(map(model, inputs))
+ Z = np.array([s.data > 0 for s in scores])
+ Z = Z.reshape(xx.shape)
+
+ fig = plt.figure()
+ plt.contourf(xx, yy, Z, cmap=plt.cm.Spectral, alpha=0.8)
+ plt.scatter(X[:, 0], X[:, 1], c=y, s=40, cmap=plt.cm.Spectral)
+ plt.xlim(xx.min(), xx.max())
+ plt.ylim(yy.min(), yy.max())
+ return plt.gca()
+ return (plot_decision_boundary,)
@app.cell
def __():
import marimo as mo
- return mo,
+ return (mo,)
if __name__ == "__main__":
diff --git a/examples/ai/model_comparison/model_comparison.py b/examples/ai/model_comparison.py
similarity index 87%
rename from examples/ai/model_comparison/model_comparison.py
rename to examples/ai/model_comparison.py
index dfa1799818..5281d50724 100644
--- a/examples/ai/model_comparison/model_comparison.py
+++ b/examples/ai/model_comparison.py
@@ -1,16 +1,34 @@
+# /// script
+# requires-python = ">=3.9"
+# dependencies = [
+# "marimo",
+# ]
+# ///
+
import marimo
-__generated_with = "0.1.8"
+__generated_with = "0.8.19"
app = marimo.App()
[email protected](hide_code=True)
def __(mo):
- mo.md("# Model Comparison")
+ mo.md("""# Model Comparison""")
return
[email protected](hide_code=True)
+def __(mo):
+ mo.md(
+ r"""
+ !!! tip "This notebook is best viewed as an app."
+ Hit `Cmd/Ctrl+.` or click the "app view" button in the bottom right.
+ """
+ )
+ return
+
+
[email protected](hide_code=True)
def __(NUMBER_OF_EXAMPLES, mo):
get_index, set_index = mo.state(0)
@@ -36,7 +54,7 @@ def __(NUMBER_OF_EXAMPLES, mo):
)
[email protected](hide_code=True)
def __(NUMBER_OF_EXAMPLES, get_index, mo, set_index):
index = mo.ui.number(
0,
@@ -47,16 +65,16 @@ def __(NUMBER_OF_EXAMPLES, get_index, mo, set_index):
label="example number",
on_change=set_index,
)
- return index,
+ return (index,)
[email protected](hide_code=True)
def __(mo):
mo.md(f"_Models A and B both predict spans. Which do you prefer?_")
return
[email protected](hide_code=True)
def __(NUMBER_OF_EXAMPLES, mo, num_a_preferred, num_b_preferred):
mo.ui.table(
[
@@ -74,16 +92,16 @@ def __(index, mo, next_button, previous_button):
return
[email protected](hide_code=True)
def __(CHOICES_PATH, get_choices, index, mo, write_choices):
preference = get_choices()[index.value]
mo.stop(preference is None, mo.md("**Choose the better model**.").center())
write_choices(get_choices(), CHOICES_PATH)
mo.md(f"You prefer **model {preference}**.").center()
- return preference,
+ return (preference,)
[email protected](hide_code=True)
def __(annotate, mo):
mo.hstack(
[
@@ -95,7 +113,7 @@ def __(annotate, mo):
return
[email protected](hide_code=True)
def __(CHOICES_PATH, PARAGRAPHS, load_choices, mo):
get_choices, set_choices = mo.state(
load_choices(CHOICES_PATH, len(PARAGRAPHS))
@@ -103,7 +121,7 @@ def __(CHOICES_PATH, PARAGRAPHS, load_choices, mo):
return get_choices, set_choices
[email protected](hide_code=True)
def __(index, mo, set_choices):
model_A = mo.ui.button(
label="Model A",
@@ -122,7 +140,7 @@ def __(index, mo, set_choices):
return model_A, model_B
[email protected](hide_code=True)
def __(PARAGRAPHS, SPANS, annotate, index, mo):
model_A_prediction = mo.md(
annotate(
@@ -160,7 +178,7 @@ def __(get_choices):
@app.cell
def __():
CHOICES_PATH = "choices.json"
- return CHOICES_PATH,
+ return (CHOICES_PATH,)
@app.cell
@@ -209,7 +227,7 @@ def __(HAMLET, textwrap):
for block in HAMLET.split("\n\n")
if block
]
- return PARAGRAPHS,
+ return (PARAGRAPHS,)
@app.cell
@@ -223,13 +241,13 @@ def __():
+ "</mark>"
+ text[span[1] :]
)
- return annotate,
+ return (annotate,)
@app.cell
def __(PARAGRAPHS):
NUMBER_OF_EXAMPLES = len(PARAGRAPHS)
- return NUMBER_OF_EXAMPLES,
+ return (NUMBER_OF_EXAMPLES,)
@app.cell
@@ -244,7 +262,7 @@ def __(urllib):
@app.cell
def __():
import marimo as mo
- return mo,
+ return (mo,)
@app.cell
diff --git a/examples/ai/question-pdf.py b/examples/ai/pdf_question_answer.py
similarity index 91%
rename from examples/ai/question-pdf.py
rename to examples/ai/pdf_question_answer.py
index 22c44907c5..63801204e6 100644
--- a/examples/ai/question-pdf.py
+++ b/examples/ai/pdf_question_answer.py
@@ -1,22 +1,27 @@
+# /// script
+# requires-python = ">=3.9"
+# dependencies = [
+# "langchain==0.3.0",
+# "marimo",
+# "pypdf2==3.0.1",
+# ]
+# ///
+
import marimo
-__generated_with = "0.1.0"
+__generated_with = "0.8.19"
app = marimo.App()
@app.cell
def __(mo):
- mo.md("# PDF Q&A")
+ mo.md("""# PDF Q&A""")
return
[email protected](hide_code=True)
def __(mo):
- mo.md(
- """
- This app lets you upload a PDF and ask questions about it.
- """
- )
+ mo.md("""This app lets you upload a PDF and ask questions about it.""")
return
@@ -50,7 +55,7 @@ def __(mo, openaikey):
label="Upload PDF", filetypes=[".pdf"], multiple=False, kind="area"
)
pdf if openaikey.value else mo.md("👆 Add an Open AI Key").callout(kind="warn")
- return pdf,
+ return (pdf,)
@app.cell
@@ -103,7 +108,7 @@ def __(mo):
placeholder="💬 What are the 3 key points of the document?"
).form()
user_question
- return user_question,
+ return (user_question,)
@app.cell
diff --git a/examples/cloud/gcp/google_cloud_bigquery.py b/examples/cloud/gcp/google_cloud_bigquery.py
index ff43899d97..9b9c02ab82 100644
--- a/examples/cloud/gcp/google_cloud_bigquery.py
+++ b/examples/cloud/gcp/google_cloud_bigquery.py
@@ -1,61 +1,72 @@
+# /// script
+# requires-python = ">=3.9"
+# dependencies = [
+# "db-dtypes==1.3.0",
+# "google-cloud-bigquery==3.25.0",
+# "marimo",
+# "protobuf==5.28.2",
+# ]
+# ///
+
import marimo
-__generated_with = "0.1.43"
-app = marimo.App(width="full")
+__generated_with = "0.8.19"
+app = marimo.App(width="medium")
@app.cell
def __():
- # Imports
import marimo as mo
import os
from google.cloud import bigquery
return bigquery, mo, os
[email protected](hide_code=True)
+def __(mo):
+ mo.md("""# Google Cloud BigQuery""")
+ return
+
+
[email protected](hide_code=True)
def __(mo):
+ # Configuration
+ credentials = mo.ui.text(placeholder="path/to/creds.json")
mo.md(
f"""
- # Google Cloud BigQuery
+ ## **⚙ Configuration**
+
+ This app requires a Google Cloud Platform account and a bucket to access.
- Required dependencies:
- ```sh
- $ pip install google-cloud-bigquery db-dtypes
- ```
- """
+ Authenticate with `gcloud auth login`, or provide a path to a credentials
+ file: {credentials}
+ """
)
- return
+ return (credentials,)
[email protected](hide_code=True)
def __(mo):
- # Configuration
- credentials = mo.ui.text(label="(Optional) Path to credentials file").form()
- mo.accordion(
- {
- "⚙️ Configuration": mo.md(
- f"""
- This app requires a Google Cloud Platform account and a bucket to access. You will need to be authenticated with `gcloud auth login`,
- or provide a path to a credentials file.
-
- {credentials}
- """
- )
- }
- )
- return credentials,
+ project = mo.ui.text(label="gcloud project")
+ project
+ return (project,)
-def __(bigquery, credentials, os):
[email protected](hide_code=True)
+def __(bigquery, credentials, mo, os, project):
# Set up client
if credentials.value:
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = credentials.value
else:
os.environ.pop("GOOGLE_APPLICATION_CREDENTIALS", None)
- client = bigquery.Client()
+ if project.value is not None:
+ _project = project.value
+ else:
+ _project = os.env.get("GCLOUD_PROJECT")
+
+ mo.stop(not _project, mo.md("☝️ Provide a gcloud project."))
+ client = bigquery.Client(project=_project)
datasets = list(client.list_datasets())
return client, datasets
@@ -67,7 +78,7 @@ def __(datasets, mo):
label="Select dataset", options=[d.dataset_id for d in datasets]
)
selected_dataset
- return selected_dataset,
+ return (selected_dataset,)
@app.cell
@@ -75,7 +86,7 @@ def __(client, mo, selected_dataset):
mo.stop(not selected_dataset.value)
dataset = client.dataset(selected_dataset.value)
- return dataset,
+ return (dataset,)
@app.cell
@@ -93,7 +104,7 @@ def __(client, dataset, mo):
def __(client, dataset, mo, selected_table):
results = client.list_rows(dataset.table(selected_table.value), max_results=10)
mo.ui.table(results.to_dataframe(), selection=None)
- return results,
+ return (results,)
if __name__ == "__main__":
diff --git a/examples/cloud/gcp/google_cloud_storage.py b/examples/cloud/gcp/google_cloud_storage.py
index c806c93624..70f0ecbba2 100644
--- a/examples/cloud/gcp/google_cloud_storage.py
+++ b/examples/cloud/gcp/google_cloud_storage.py
@@ -1,6 +1,15 @@
+# /// script
+# requires-python = ">=3.9"
+# dependencies = [
+# "google-cloud-storage==2.18.2",
+# "marimo",
+# "protobuf==5.28.2",
+# ]
+# ///
+
import marimo
-__generated_with = "0.1.43"
+__generated_with = "0.8.19"
app = marimo.App(width="full")
@@ -13,49 +22,46 @@ def __():
return mo, os, storage
[email protected](hide_code=True)
def __(mo):
+ # Configuration
+ credentials = mo.ui.text(placeholder="path/to/creds.json")
mo.md(
f"""
- # Google Cloud Storage
+ ## **⚙ Configuration**
+
+ This app requires a Google Cloud Platform account and a bucket to access.
- Required dependencies:
- ```sh
- $ pip install google-cloud-storage
- ```
- """
+ Authenticate with `gcloud auth login`, or provide a path to a credentials
+ file: {credentials}
+ """
)
- return
+ return (credentials,)
[email protected](hide_code=True)
def __(mo):
- # Configuration
- credentials = mo.ui.text(label="(Optional) Path to credentials file").form()
- mo.accordion(
- {
- "⚙️ Configuration": mo.md(
- f"""
- This app requires a Google Cloud Platform account and a bucket to access. You will need to be authenticated with `gcloud auth login`,
- or provide a path to a credentials file.
-
- {credentials}
- """
- )
- }
- )
- return credentials,
+ project = mo.ui.text(label="gcloud project")
+ project
+ return (project,)
@app.cell
-def __(credentials, os, storage):
+def __(credentials, mo, os, project, storage):
# Set up client
if credentials.value:
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = credentials.value
else:
os.environ.pop("GOOGLE_APPLICATION_CREDENTIALS", None)
- client = storage.Client()
+ if project.value is not None:
+ _project = project.value
+ else:
+ _project = os.env.get("GCLOUD_PROJECT")
+
+ mo.stop(not _project, mo.md("☝️ Provide a gcloud project."))
+
+ client = storage.Client(project=_project)
buckets = client.list_buckets()
return buckets, client
@@ -67,7 +73,7 @@ def __(buckets, mo):
label="Select bucket", options=[bucket.name for bucket in buckets]
)
selected_bucket
- return selected_bucket,
+ return (selected_bucket,)
@app.cell
@@ -81,14 +87,14 @@ def __(client, mo, selected_bucket):
mo.stop(not selected_bucket.value)
bucket = client.get_bucket(selected_bucket.value)
- return bucket,
+ return (bucket,)
@app.cell
def __(bucket, get_prefix):
_prefix = get_prefix() or None
- blobs = list(bucket.list_blobs(max_results=20, prefix=_prefix))
- return blobs,
+ blobs = list(bucket.list_blobs(max_results=30, prefix=_prefix))
+ return (blobs,)
@app.cell
@@ -103,7 +109,7 @@ def __(get_prefix, mo, set_prefix):
]
)
output
- return output,
+ return (output,)
@app.cell
@@ -129,7 +135,7 @@ def __(blobs, bucket, mo, set_prefix):
]
file_table = mo.ui.table(_files, selection="single")
file_table if _files else mo.md("No files found").callout()
- return file_table,
+ return (file_table,)
@app.cell
diff --git a/examples/cloud/gcp/google_sheets.py b/examples/cloud/gcp/google_sheets.py
index 62712d1770..fdde00c14a 100644
--- a/examples/cloud/gcp/google_sheets.py
+++ b/examples/cloud/gcp/google_sheets.py
@@ -1,12 +1,21 @@
+# /// script
+# requires-python = ">=3.9"
+# dependencies = [
+# "gspread==6.1.2",
+# "marimo",
+# "oauth2client==4.1.3",
+# "pandas==2.2.3",
+# ]
+# ///
+
import marimo
-__generated_with = "0.1.43"
+__generated_with = "0.8.19"
app = marimo.App(width="full")
@app.cell
def __():
- # Imports
import marimo as mo
import pandas as pd
import os
@@ -18,36 +27,19 @@ def __():
@app.cell
def __(mo):
+ # Configuration
+ credentials = mo.ui.text(placeholder="path/to/creds.json")
mo.md(
f"""
- # Google Sheets
-
- Required dependencies:
- ```sh
- $ pip install gspread
- ```
- """
- )
- return
+ ## **⚙ Configuration**
+ This app requires a Google Cloud Platform account and a bucket to access.
-def __(mo):
- # Configuration
- credentials = mo.ui.text(label="(Optional) Path to credentials file").form()
- mo.accordion(
- {
- "⚙️ Configuration": mo.md(
- f"""
- This app requires a Google Cloud Platform account and a bucket to access. You will need to be authenticated with `gcloud auth login`,
- or provide a path to a credentials file.
-
- {credentials}
- """
- )
- }
+ Authenticate with `gcloud auth login`, or provide a path to a credentials
+ file: {credentials}
+ """
)
- return credentials,
+ return (credentials,)
@app.cell
@@ -79,9 +71,9 @@ def __(
@app.cell
def __(mo):
- spreadsheet_url = mo.ui.text_area(label="Spreadsheet URL").form()
+ spreadsheet_url = mo.ui.text(label="Spreadsheet URL", full_width=True)
spreadsheet_url
- return spreadsheet_url,
+ return (spreadsheet_url,)
@app.cell
@@ -91,7 +83,7 @@ def __(gc, mo, pd, spreadsheet_url):
# Get sheet records
wks = gc.open_by_url(spreadsheet_url.value).sheet1
mo.ui.table(pd.DataFrame(wks.get_all_records()), selection=None)
- return wks,
+ return (wks,)
if __name__ == "__main__":
diff --git a/examples/cloud/modal/README.md b/examples/cloud/modal/README.md
new file mode 100644
index 0000000000..033cb28ebd
--- /dev/null
+++ b/examples/cloud/modal/README.md
@@ -0,0 +1,4 @@
+# Deploying marimo on modal
+
+This folder contains an example of how to deploy a marimo notebook as an
+application on modal.
diff --git a/examples/modal/modal_example.py b/examples/cloud/modal/modal_app.py
similarity index 100%
rename from examples/modal/modal_example.py
rename to examples/cloud/modal/modal_app.py
diff --git a/examples/modal/nbs/home.py b/examples/cloud/modal/nbs/home.py
similarity index 100%
rename from examples/modal/nbs/home.py
rename to examples/cloud/modal/nbs/home.py
diff --git a/examples/marimo/character_count.py b/examples/marimo/character_count.py
deleted file mode 100644
index c11d8e4b34..0000000000
--- a/examples/marimo/character_count.py
+++ /dev/null
@@ -1,37 +0,0 @@
-import marimo
-
-__generated_with = "0.1.5"
-app = marimo.App()
-
-
-def __():
- import marimo as mo
- return mo,
-
-
-def __(mo):
- mo.md("# Character Count").left()
- return
-
-
-def __(mo):
- text = mo.ui.text_area(placeholder="Enter text ...", label="Character count")
- return text,
-
-
-def __(mo, text):
- mo.hstack(
- [text, mo.md(f"`{len(text.value)} characters`")],
- justify="start",
- align="end",
- gap=1,
- )
- return
-
-
-if __name__ == "__main__":
- app.run()
diff --git a/examples/probability/bayes_theorem.py b/examples/misc/bayes_theorem.py
similarity index 93%
rename from examples/probability/bayes_theorem.py
rename to examples/misc/bayes_theorem.py
index eb4ffb3ffe..f585625fa6 100644
--- a/examples/probability/bayes_theorem.py
+++ b/examples/misc/bayes_theorem.py
@@ -1,10 +1,17 @@
+# /// script
+# requires-python = ">=3.9"
+# dependencies = [
+# "marimo",
+# ]
+# ///
+
import marimo
-__generated_with = "0.2.5"
-app = marimo.App(width="full")
+__generated_with = "0.8.19"
+app = marimo.App(width="medium")
[email protected](hide_code=True)
def __(mo):
mo.md(
r"""
@@ -22,21 +29,21 @@ def __(mo):
**The numerator.** The numerator is the probability of events $E$ and $H$ happening
together; that is,
-
+
\[
P(H) P(E \mid H) = P(E \cap H).
\]
-
+
**The denominator.**
In most calculations, it is helpful to rewrite the denominator $P(E)$ as
-
+
\[
P(E) = P(H)P(E \mid H) + P(\neg H) P (E \mid \neg H),
\]
-
+
which in turn can also be written as
-
+
\[
P(E) = P(E \cap H) + P(E \cap \neg H).
\]
@@ -45,24 +52,7 @@ def __(mo):
return
-def __(mo):
- p_h = mo.ui.slider(0.0, 1, label="$P(H)$", value=0.1, step=0.1)
- p_e_given_h = mo.ui.slider(0.0, 1, label="$P(E \mid H)$", value=0.3, step=0.1)
- p_e_given_not_h = mo.ui.slider(
- 0.0, 1, label=r"$P(E \mid \neg H)$", value=0.3, step=0.1
- )
- return p_e_given_h, p_e_given_not_h, p_h
-
-
-def __(p_e_given_h, p_e_given_not_h, p_h):
- p_e = p_h.value*p_e_given_h.value + (1 - p_h.value)*p_e_given_not_h.value
- bayes_result = p_h.value * p_e_given_h.value / p_e
- return bayes_result, p_e
-
-
[email protected](hide_code=True)
def __(
bayes_result,
construct_probability_plot,
@@ -83,7 +73,7 @@ def __(
{mo.as_html([p_h, p_e_given_h, p_e_given_not_h])}
The plot on the right visualizes the probabilities of these events.
-
+
1. The yellow rectangle represents the event $H$, and its area is $P(H) = {p_h.value:0.2f}$.
2. The teal rectangle overlapping with the yellow one represents the event $E \cap H$, and
its area is $P(H) \cdot P(E \mid H) = {p_h.value * p_e_given_h.value:0.2f}$.
@@ -91,12 +81,12 @@ def __(
its area is $P(\neg H) \cdot P(E \mid \neg H) = {(1 - p_h.value) * p_e_given_not_h.value:0.2f}$.
Notice that the sum of the areas in $2$ and $3$ is the probability $P(E) = {p_e:0.2f}$.
-
+
One way to think about Bayes' Theorem is the following: the probability $P(H \mid E)$ is the probability
of $E$ and $H$ happening together (the area of the rectangle $2$), divided by the probability of $E$ happening
at all (the sum of the areas of $2$ and $3$).
In this case, Bayes' Theorem says
-
+
\[
P(H \mid E) = \frac{{P(H) P(E \mid H)}}{{P(E)}} = \frac{{{p_h.value} \cdot {p_e_given_h.value}}}{{{p_e:0.2f}}} = {bayes_result:0.2f}
\]
@@ -112,6 +102,23 @@ def __(
return
[email protected](hide_code=True)
+def __(mo):
+ p_h = mo.ui.slider(0.0, 1, label="$P(H)$", value=0.1, step=0.1)
+ p_e_given_h = mo.ui.slider(0.0, 1, label="$P(E \mid H)$", value=0.3, step=0.1)
+ p_e_given_not_h = mo.ui.slider(
+ 0.0, 1, label=r"$P(E \mid \neg H)$", value=0.3, step=0.1
+ )
+ return p_e_given_h, p_e_given_not_h, p_h
+
+
[email protected](hide_code=True)
+def __(p_e_given_h, p_e_given_not_h, p_h):
+ p_e = p_h.value*p_e_given_h.value + (1 - p_h.value)*p_e_given_not_h.value
+ bayes_result = p_h.value * p_e_given_h.value / p_e
+ return bayes_result, p_e
+
+
@app.cell
def __(p_e_given_h, p_e_given_not_h, p_h):
def construct_probability_plot():
@@ -141,13 +148,13 @@ def __(p_e_given_h, p_e_given_not_h, p_h):
plt.gca().add_patch(e_given_h)
plt.legend()
return plt.gca()
- return construct_probability_plot,
+ return (construct_probability_plot,)
@app.cell
def __():
import marimo as mo
- return mo,
+ return (mo,)
if __name__ == "__main__":
diff --git a/examples/personal_finance/compound_interest.py b/examples/misc/compound_interest.py
similarity index 93%
rename from examples/personal_finance/compound_interest.py
rename to examples/misc/compound_interest.py
index 31eb0a78c0..d5d7776e22 100644
--- a/examples/personal_finance/compound_interest.py
+++ b/examples/misc/compound_interest.py
@@ -1,16 +1,24 @@
+# /// script
+# requires-python = ">=3.9"
+# dependencies = [
+# "marimo",
+# "matplotlib==3.9.2",
+# ]
+# ///
+
import marimo
-__generated_with = "0.1.0"
+__generated_with = "0.8.19"
app = marimo.App()
[email protected](hide_code=True)
def __(mo):
- mo.md("# Compound Interest")
+ mo.md("""# Compound Interest""")
return
[email protected](hide_code=True)
def __(mo):
mo.md(
"""
@@ -21,7 +29,7 @@ def __(mo):
return
[email protected](hide_code=True)
def __(mo):
initial_investment = mo.ui.slider(0, 1000000, step=1e4, value=10000)
monthly_investment = mo.ui.slider(0, 50000, value=1000, step=1e3)
@@ -57,7 +65,7 @@ def __(mo):
mo.md(
f"""## Investment Parameters
-
+
{table}
""")
return (
@@ -70,7 +78,7 @@ def __(mo):
)
[email protected](hide_code=True)
def simulate(
annual_return,
capital_gains_tax_rate,
diff --git a/examples/personal_finance/mortgage_calculator.py b/examples/misc/mortgage_calculator.py
similarity index 96%
rename from examples/personal_finance/mortgage_calculator.py
rename to examples/misc/mortgage_calculator.py
index b036a6e9c0..1be9655331 100644
--- a/examples/personal_finance/mortgage_calculator.py
+++ b/examples/misc/mortgage_calculator.py
@@ -1,18 +1,28 @@
+# /// script
+# requires-python = ">=3.9"
+# dependencies = [
+# "marimo",
+# "matplotlib==3.9.2",
+# "mortgage==1.0.5",
+# "numpy==1.26.4",
+# ]
+# ///
+
import marimo
-__generated_with = "0.1.0"
+__generated_with = "0.8.19"
app = marimo.App()
[email protected](hide_code=True)
def __(mo):
- mo.md("# Mortgage Calculator")
+ mo.md("""# Mortgage Calculator""")
return
[email protected](hide_code=True)
def __(mo):
- mo.md("## Income")
+ mo.md("""## Income""")
return
@@ -24,7 +34,7 @@ def __(mo):
mo.md(
f"""
How much do you expect to make this year, **after taxes**?
-
+
{income.center()}
"""
)
@@ -37,10 +47,10 @@ def __(mo):
mo.md(
"""
**Heads-up!**
-
+
This calculator does not take taxes into account. Please make sure
that you provide **after-tax** income. Also exclude 401k contributions.
-
+
You can estimate your federal and state taxes using an online
calculator, such as the one
[linked here](https://smartasset.com/taxes/income-taxes).
@@ -200,13 +210,13 @@ def __(
f"""
You're purchasing a home worth **\${home_price.value * 1000:,}**, with a
down payment of **\${down_payment*1000:,.02f}**.
-
+
At a rate of **{rate.value}**%,
you will owe **\${annual_home_payment:,.02f}** per year on home expenses.
That's **\${monthly_home_payment:,.02f}** per month, which is
**{monthly_home_payment / (net_cash_per_month) * 100:,.02f}%** of
your take-home pay.
-
+
You'll have **\${cash_less_housing/12:,.02f}** left over per
month for expenses and saving.
"""
@@ -224,7 +234,7 @@ def __(
@app.cell
def __(mo):
- mo.md("## Monthly Expenses")
+ mo.md("""## Monthly Expenses""")
return
@@ -333,7 +343,7 @@ def __(
@app.cell
def __(loan):
schedule = loan.schedule()[1:]
- return schedule,
+ return (schedule,)
@app.cell
@@ -385,7 +395,7 @@ def __(interest_payments, mo, np, principal_payments, years):
The plots below visualize your mortgage payments, over the duration of the
entire mortgage. The left plot shows cumulative payments, and the right one
shows monthly payments.
-
+
{mo.as_html(fig)}
"""
)
diff --git a/examples/dashboards/movies.py b/examples/misc/movies_by_the_decade.py
similarity index 91%
rename from examples/dashboards/movies.py
rename to examples/misc/movies_by_the_decade.py
index 18047fbed1..c697ddaf20 100644
--- a/examples/dashboards/movies.py
+++ b/examples/misc/movies_by_the_decade.py
@@ -1,9 +1,31 @@
+# /// script
+# requires-python = ">=3.9"
+# dependencies = [
+# "altair==5.4.1",
+# "marimo",
+# "pandas==2.2.3",
+# "vega-datasets==0.9.0",
+# ]
+# ///
+
import marimo
-__generated_with = "0.1.33"
+__generated_with = "0.8.19"
app = marimo.App(width="full")
[email protected](hide_code=True)
+def __(mo):
+ mo.md(
+ r"""
+ !!! tip "This notebook is best viewed as an app."
+ If you're editing this notebook and see code cells, hit `Cmd/Ctrl+.` or
+ click the "app view" button in the bottom right.
+ """
+ )
+ return
+
+
@app.cell
def __(
button_00s,
@@ -49,7 +71,6 @@ def __(mo, pd, set_end_date, set_start_date):
on_click=handle_click,
)
-
button_80s = decade_button(1980)
button_90s = decade_button(1990)
button_00s = decade_button(2000)
@@ -187,8 +208,12 @@ def __(
def __(filtered_movies, mo):
mo.ui.tabs(
{
- "📑 Data": mo.ui.table(filtered_movies, selection=None, page_size=5),
- "📊 Summary": mo.ui.table(filtered_movies.describe(), selection=None),
+ "📑 Data": mo.ui.table(
+ filtered_movies, selection=None, page_size=5
+ ),
+ "📊 Summary": mo.ui.table(
+ filtered_movies.describe(), selection=None
+ ),
}
)
return
@@ -215,7 +240,7 @@ def __(alt, filtered_movies, mo):
)
chart = mo.ui.altair_chart(_chart)
chart
- return chart,
+ return (chart,)
@app.cell
@@ -259,7 +284,13 @@ def __(
)
mo.hstack(
- [_total_movies, _gross_stat, _budget_stat, _runtime_stat, _average_rating],
+ [
+ _total_movies,
+ _gross_stat,
+ _budget_stat,
+ _runtime_stat,
+ _average_rating,
+ ],
widths="equal",
gap=1,
)
@@ -282,7 +313,7 @@ def __(alt, filtered_movies, mo):
)
bar_chart = mo.ui.altair_chart(_bar_chart)
bar_chart
- return bar_chart,
+ return (bar_chart,)
@app.cell
@@ -293,28 +324,24 @@ def __(datetime):
rate = (current - previous) / previous
return (current, previous, rate)
-
def get_average_gross(df, previous):
current = df["Worldwide_Gross"].mean()
previous = previous["Worldwide_Gross"].mean()
rate = (current - previous) / previous
return (current, previous, rate)
-
def get_average_runtime(df, previous):
current = df["Running_Time_min"].mean()
previous = previous["Running_Time_min"].mean()
rate = (current - previous) / previous
return (current, previous, rate)
-
def get_average_rating(df, previous):
current = df["IMDB_Rating"].mean()
previous = previous["IMDB_Rating"].mean()
rate = (current - previous) / previous
return (current, previous, rate)
-
def get_previous_date_range(start_date, end_date):
delta = end_date - start_date
return (
@@ -322,7 +349,6 @@ def __(datetime):
(end_date - datetime.timedelta(days=delta.days)),
)
-
def format_date(date):
return date.strftime("%Y-%m-%d")
return (
@@ -352,7 +378,7 @@ def __(data, pd):
# convert to date
movies["Release_Date"] = pd.to_datetime(movies["Release_Date"])
- return movies,
+ return (movies,)
@app.cell
diff --git a/examples/dashboards/pokemon_stats/pokemon.py b/examples/misc/pokemon_stats.py
similarity index 91%
rename from examples/dashboards/pokemon_stats/pokemon.py
rename to examples/misc/pokemon_stats.py
index e01f3d560a..37951fdaaf 100644
--- a/examples/dashboards/pokemon_stats/pokemon.py
+++ b/examples/misc/pokemon_stats.py
@@ -1,16 +1,29 @@
+# /// script
+# requires-python = ">=3.9"
+# dependencies = [
+# "marimo",
+# "matplotlib==3.9.2",
+# "numpy==1.26.4",
+# "pandas==2.2.3",
+# "plotly==5.24.1",
+# "requests==2.32.3",
+# "seaborn==0.13.2",
+# ]
+# ///
+
import marimo
-__generated_with = "0.1.21"
+__generated_with = "0.8.19"
app = marimo.App(width="full")
[email protected](hide_code=True)
def __(mo):
- mo.md("# Pokémon Statistics 📊🔬")
+ mo.md("""# Pokémon Statistics 📊🔬""")
return
[email protected](hide_code=True)
def __(clear_selection, mo, pokemon_types):
mo.md(
f"""
@@ -34,14 +47,14 @@ def __(pokemon):
@app.cell
def __(mo):
clear_selection = mo.ui.button(label="_Clear selection_")
- return clear_selection,
+ return (clear_selection,)
@app.cell
def __(clear_selection, mo, types_name):
clear_selection
pokemon_types = mo.ui.multiselect(types_name)
- return pokemon_types,
+ return (pokemon_types,)
@app.cell
@@ -58,7 +71,7 @@ def __(mo):
"Sp. Attack / Sp. Defense": "Sp. Atk / Sp. Def",
}
)
- return attribute,
+ return (attribute,)
@app.cell
@@ -182,7 +195,7 @@ def __(pokemon):
]
ax.fill(angles, stats, alpha=0.2, label=name)
return ax
- return plot_single_pokemon,
+ return (plot_single_pokemon,)
@app.cell
@@ -202,7 +215,7 @@ def __(np, plot_single_pokemon, plt):
if names:
plt.legend(loc="upper left")
return ax
- return plot_pokemon,
+ return (plot_pokemon,)
@app.cell
@@ -246,13 +259,13 @@ def __():
"Steel": "#B7B7CE",
"Water": "#6390F0",
}
- return colors,
+ return (colors,)
@app.cell
def __():
import plotly.express as px
- return px,
+ return (px,)
if __name__ == "__main__":
diff --git a/examples/requirements.txt b/examples/requirements.txt
deleted file mode 100644
index ddbc5401c5..0000000000
--- a/examples/requirements.txt
+++ /dev/null
@@ -1,45 +0,0 @@
-cvxpy >= 1.2.0
-langchain >= 0.0.245
-marimo >= 0.1.0
-matplotlib >= 3.2.0
-mortgage >= 1.0.5
-vega-datasets >= 0.9.0
-altair >= 5.3.0
-numpy >= 1.22.0
-polars >= 0.20.0
-openai >= 0.27.8
-pandas >= 2.0.0
-pymde >= 0.1.18
-matplotlib >= 3.4.0
-pyarrow >= 6.0.0
-leafmap >= 0.3.0
-bokeh >= 3.0.0
-holoviews >= 1.14.0
-hvplot >= 0.7.0
-pypdf2 >= 3.0.1
-rich >= 11.0.0
-duckdb >= 0.9.0
-requests >= 2.26.0
-websocket >= 0.2.0
-seaborn >= 0.12.0
-scikit-image >= 0.23.2
-sig-decomp == 0.1.1
-gspread >= 6.0.0
-tiktoken >= 0.4.0
-pillow>=10.0.0 # not directly required, pinned by Snyk to avoid a vulnerability
-fonttools>=4.43.0 # not directly required, pinned by Snyk to avoid a vulnerability
-oauth2client >= 4.1.3
-google-cloud-bigquery
-plotly
-drawdata
-anywidget
-db-dtypes
-google-cloud-storage
-quak
-dask
-ibis-framework[duckdb]
-pygwalker
-maplibre
-mosaic_widget
-geopandas
-great_tables
diff --git a/examples/sql/duckdb_connections.py b/examples/sql/duckdb_connections.py
index f26ebe3002..c7a6fe1ad9 100644
--- a/examples/sql/duckdb_connections.py
+++ b/examples/sql/duckdb_connections.py
@@ -1,6 +1,14 @@
+# /// script
+# requires-python = ">=3.9"
+# dependencies = [
+# "duckdb==1.1.1",
+# "marimo",
+# ]
+# ///
+
import marimo
-__generated_with = "0.7.18"
+__generated_with = "0.8.19"
app = marimo.App(width="full")
@@ -11,7 +19,7 @@ def __():
return mo, os
[email protected](hide_code=True)
def __(mo):
mo.md(r"""## Create a connection""")
return
@@ -25,10 +33,10 @@ def __(mo, os):
value=os.environ.get("DATABASE_URL", ""),
)
database_url
- return database_url,
+ return (database_url,)
[email protected](hide_code=True)
def __(database_url):
import duckdb
@@ -42,7 +50,7 @@ def __(database_url):
ATTACH DATABASE '{database_url.value}' AS my_db (TYPE postgres, READ_ONLY);
"""
)
- return duckdb,
+ return (duckdb,)
@app.cell
@@ -105,7 +113,7 @@ def __():
"duckdb_views()", # views
"duckdb_temporary_files()", # the temporary files DuckDB has written to disk, to offload data from memory
]
- return FUNCTIONS,
+ return (FUNCTIONS,)
@app.cell
@@ -116,7 +124,7 @@ def __(FUNCTIONS, mo):
value=FUNCTIONS[0],
)
function
- return function,
+ return (function,)
@app.cell
@@ -170,7 +178,7 @@ def __(mo, table_names):
def __(mo, table_select):
mo.stop(not table_select.value)
table_select_value = table_select.value
- return table_select_value,
+ return (table_select_value,)
@app.cell
@@ -180,7 +188,7 @@ def __(limit, mo, table_select_value):
select * from my_db.{table_select_value} LIMIT {limit.value};
"""
)
- return selected_table,
+ return (selected_table,)
@app.cell
diff --git a/examples/sql/electric_vehicles.py b/examples/sql/electric_vehicles.py
index 7caf34ccc2..d3b450c4b4 100644
--- a/examples/sql/electric_vehicles.py
+++ b/examples/sql/electric_vehicles.py
@@ -1,10 +1,18 @@
+# /// script
+# requires-python = ">=3.9"
+# dependencies = [
+# "altair==5.4.1",
+# "marimo",
+# ]
+# ///
+
import marimo
-__generated_with = "0.7.0"
+__generated_with = "0.8.19"
app = marimo.App(width="medium")
[email protected](hide_code=True)
def __(mo):
mo.md(
r"""
@@ -17,7 +25,7 @@ def __(mo):
@app.cell
-def __(mo):
+def __(evs, mo):
evs = mo.sql(
f"""
create or replace table evs as
@@ -25,7 +33,7 @@ def __(mo):
select * from evs
"""
)
- return evs,
+ return (evs,)
@app.cell
@@ -68,7 +76,7 @@ def __(alt, grouped_by_city, mo):
.properties(title="Top 10 City", width="container")
)
chart1 = mo.ui.altair_chart(_chart, chart_selection=False)
- return chart1,
+ return (chart1,)
@app.cell
@@ -84,7 +92,7 @@ def __(alt, grouped_by_make, mo):
.properties(title="Top 10 Make", width="container")
)
chart2 = mo.ui.altair_chart(_chart, chart_selection=False)
- return chart2,
+ return (chart2,)
@app.cell
@@ -95,7 +103,7 @@ def __(chart1, chart2, mo):
@app.cell
def __(mo):
- mo.md(r"## Appendix")
+ mo.md(r"""## Appendix""")
return
@@ -106,7 +114,7 @@ def __(evs, mo):
SELECT DISTINCT CAST(evs."Model Year" AS VARCHAR) AS "Model Year" FROM evs;
"""
)
- return years,
+ return (years,)
@app.cell
@@ -116,7 +124,7 @@ def __(evs, mo):
SELECT DISTINCT CAST(evs."City" AS VARCHAR) AS "City" FROM evs WHERE "City" != 'null';
"""
)
- return cities,
+ return (cities,)
@app.cell
@@ -126,7 +134,7 @@ def __(evs, mo):
SELECT DISTINCT CAST(evs."Make" AS VARCHAR) AS "Make" FROM evs;
"""
)
- return makes,
+ return (makes,)
@app.cell
@@ -154,7 +162,7 @@ def __(
ORDER BY "count" DESC
"""
)
- return grouped_by_city,
+ return (grouped_by_city,)
@app.cell
@@ -182,7 +190,7 @@ def __(
ORDER BY "count" DESC
"""
)
- return grouped_by_make,
+ return (grouped_by_make,)
@app.cell
diff --git a/examples/sql/motherduck.py b/examples/sql/motherduck.py
index ac9a669ec7..10e8d13eb4 100644
--- a/examples/sql/motherduck.py
+++ b/examples/sql/motherduck.py
@@ -1,6 +1,16 @@
+# /// script
+# requires-python = ">=3.9"
+# dependencies = [
+# "altair==5.4.1",
+# "duckdb==1.1.0",
+# "marimo",
+# "pandas==2.2.3",
+# ]
+# ///
+
import marimo
-__generated_with = "0.7.20"
+__generated_with = "0.8.19"
app = marimo.App(width="medium")
@@ -10,7 +20,7 @@ def __(mo):
r"""
# MotherDuck 🧡 marimo
- Throughout this notebook, we will explore using MotherDuck inside marimo. If you’re new to marimo, check out our [GitHub](https://github.com/marimo-team/marimo) repo: marimo is free and open source.
+ Throughout this notebook, we will explore using [MotherDuck](https://motherduck.com) inside marimo. If you’re new to marimo, check out our [GitHub](https://github.com/marimo-team/marimo) repo: marimo is free and open source.
_You can expand the code of any cells to see how the output are being created._
"""
@@ -33,7 +43,7 @@ def __(__file__, md_token, mo):
mo.output.replace(
mo.accordion({"Tired of logging in to MotherDuck?": callout})
)
- return callout,
+ return (callout,)
@app.cell(hide_code=True)
@@ -101,11 +111,11 @@ def __(mo):
-- We've named the result of this dataframe to be `most_shared_websites`. Now we can use this in any downstream Python or SQL code.
"""
)
- return most_shared_websites,
+ return (most_shared_websites,)
@app.cell
-def __(hacker_news, mo):
+def __(hacker_news, mo, ranked_stories, sample_data):
most_commented_stories_each_month = mo.sql(
f"""
-- Most Commented Stories Each Month
@@ -141,7 +151,7 @@ def __(hacker_news, mo):
-- Which can be used in Python to create charts
"""
)
- return most_commented_stories_each_month,
+ return (most_commented_stories_each_month,)
@app.cell(hide_code=True)
@@ -220,11 +230,18 @@ def __(hn_type_select, mo, month_select):
hn_type_select,
],
).left()
- return month_list,
+ return (month_list,)
@app.cell(hide_code=True)
-def __(hacker_news, hn_type_select, mo, month_list):
+def __(
+ hacker_news,
+ hn_type_select,
+ mo,
+ month_list,
+ ranked_stories,
+ sample_data,
+):
most_monthly_voted = mo.sql(
f"""
-- Most monthly voted
@@ -265,7 +282,7 @@ def __(hacker_news, hn_type_select, mo, month_list):
ORDER BY year, month;
"""
)
- return most_monthly_voted,
+ return (most_monthly_voted,)
@app.cell(hide_code=True)
@@ -304,7 +321,7 @@ def __(mo):
def __(mo):
search_input = mo.ui.text(label="Search for keywords", value="duckdb")
search_input
- return search_input,
+ return (search_input,)
@app.cell
@@ -322,13 +339,13 @@ def __(mo, search_value):
ORDER BY year ASC, month ASC;
"""
)
- return keyword_results,
+ return (keyword_results,)
@app.cell(hide_code=True)
def __(search_input):
search_value = search_input.value
- return search_value,
+ return (search_value,)
@app.cell(hide_code=True)
@@ -383,7 +400,7 @@ def __():
"November": 11,
"December": 12,
}
- return MONTHS,
+ return (MONTHS,)
if __name__ == "__main__":
diff --git a/examples/sql/sql_cars.py b/examples/sql/sql_cars.py
index 844dcfa9a1..a185689770 100644
--- a/examples/sql/sql_cars.py
+++ b/examples/sql/sql_cars.py
@@ -1,3 +1,13 @@
+# /// script
+# requires-python = ">=3.9"
+# dependencies = [
+# "altair==5.4.1",
+# "duckdb==1.1.1",
+# "marimo",
+# "pandas==2.2.3",
+# "vega-datasets==0.9.0",
+# ]
+# ///
import marimo
__generated_with = "0.7.14"
diff --git a/examples/sql/sqlite.py b/examples/sql/sqlite.py
index 68565bceec..c8fea9cc43 100644
--- a/examples/sql/sqlite.py
+++ b/examples/sql/sqlite.py
@@ -1,3 +1,9 @@
+# /// script
+# requires-python = ">=3.9"
+# dependencies = [
+# "marimo",
+# ]
+# ///
import marimo
__generated_with = "0.7.18"
diff --git a/examples/third_party/anywidget/tldraw_colorpicker.py b/examples/third_party/anywidget/tldraw_colorpicker.py
index c04fe96819..90729fb0c8 100644
--- a/examples/third_party/anywidget/tldraw_colorpicker.py
+++ b/examples/third_party/anywidget/tldraw_colorpicker.py
@@ -1,6 +1,16 @@
+# /// script
+# requires-python = ">=3.9"
+# dependencies = [
+# "marimo",
+# "matplotlib==3.9.2",
+# "numpy==1.26.4",
+# "tldraw==3.0.0",
+# ]
+# ///
+
import marimo
-__generated_with = "0.7.17"
+__generated_with = "0.8.19"
app = marimo.App(width="medium")
diff --git a/examples/third_party/cvxpy/regularization_and_sparsity.py b/examples/third_party/cvxpy/regularization_and_sparsity.py
index bd0a78bf7c..4ff8a0e31f 100644
--- a/examples/third_party/cvxpy/regularization_and_sparsity.py
+++ b/examples/third_party/cvxpy/regularization_and_sparsity.py
@@ -1,16 +1,26 @@
+# /// script
+# requires-python = ">=3.9"
+# dependencies = [
+# "cvxpy==1.5.3",
+# "marimo",
+# "matplotlib==3.9.2",
+# "numpy==1.26.4",
+# ]
+# ///
+
import marimo
-__generated_with = "0.1.4"
+__generated_with = "0.8.19"
app = marimo.App()
[email protected](hide_code=True)
def __(mo):
- mo.md("# Regularization and Sparsity")
+ mo.md("""# Regularization and Sparsity""")
return
[email protected](hide_code=True)
def __(mo):
mo.md(
r"""
@@ -82,23 +92,23 @@ def __(functools, l1_solver, l2_solver, np, sparsity_parameter):
return solve, x_l1, x_l2, x_min_max
[email protected](hide_code=True)
def __(mo):
- mo.md("## Parameter selection")
+ mo.md("""## Parameter selection""")
return
[email protected](hide_code=True)
def __(mo):
sparsity_parameter = mo.ui.slider(0, 10, step=0.1)
mo.md(
f"""
Choose the regularization strength $\lambda$: {sparsity_parameter}
""")
- return sparsity_parameter,
+ return (sparsity_parameter,)
[email protected](hide_code=True)
def __(mo, n, number_of_zeros, sparsity_parameter, x_l1, x_l2):
(
mo.md(
@@ -159,7 +169,7 @@ def __(mo):
def __(np):
def number_of_zeros(x):
return np.isclose(x, 0).sum()
- return number_of_zeros,
+ return (number_of_zeros,)
@app.cell
@@ -176,7 +186,7 @@ def __(np, x_min_max):
ax.set_xlabel('$x_i$')
ax.set_ylabel('fraction of components')
return ax
- return cdf,
+ return (cdf,)
@app.cell
@@ -194,7 +204,7 @@ def __(cp):
problem.solve()
return x.value
return solve
- return sparse_solver,
+ return (sparse_solver,)
@app.cell
@@ -208,13 +218,13 @@ def __():
@app.cell
def __():
import functools
- return functools,
+ return (functools,)
@app.cell
def __():
import marimo as mo
- return mo,
+ return (mo,)
if __name__ == "__main__":
diff --git a/examples/third_party/cvxpy/smallest_enclosing_circle.py b/examples/third_party/cvxpy/smallest_enclosing_circle.py
index 4103d7497a..ded8bbaae4 100644
--- a/examples/third_party/cvxpy/smallest_enclosing_circle.py
+++ b/examples/third_party/cvxpy/smallest_enclosing_circle.py
@@ -1,10 +1,20 @@
+# /// script
+# requires-python = ">=3.9"
+# dependencies = [
+# "cvxpy==1.5.3",
+# "marimo",
+# "matplotlib==3.9.2",
+# "numpy==1.26.4",
+# ]
+# ///
+
import marimo
-__generated_with = "0.1.0"
+__generated_with = "0.8.19"
app = marimo.App()
[email protected](hide_code=True)
def __(mo):
mo.md(
"""
@@ -23,15 +33,15 @@ def __(mo):
return
[email protected](hide_code=True)
def __(mo):
number_of_circles = mo.ui.slider(
1, 15, value=3, label='Number of circles')
number_of_circles
- return number_of_circles,
+ return (number_of_circles,)
[email protected](hide_code=True)
def __(mo, number_of_circles):
resample_button = mo.ui.button(label='Click this button')
mo.md(
@@ -40,10 +50,10 @@ def __(mo, number_of_circles):
{number_of_circles.value} circles.
"""
)
- return resample_button,
+ return (resample_button,)
[email protected](hide_code=True)
def __(np):
def generate_circles(number_of_circles):
circles = []
@@ -52,15 +62,15 @@ def __(np):
r_i = np.abs(np.random.randn())
circles.append((c_i, r_i))
return circles
- return generate_circles,
+ return (generate_circles,)
[email protected](hide_code=True)
def __(generate_circles, number_of_circles, resample_button):
resample_button
circles = generate_circles(number_of_circles.value)
- return circles,
+ return (circles,)
@app.cell
@@ -88,12 +98,12 @@ def __(plt):
ax = plt.gca() if ax is None else ax
ax.add_patch(plt.Circle(center, radius, fill=False, **kwargs))
return ax
- return plot_circle,
+ return (plot_circle,)
@app.cell
def __(mo):
- mo.md("## The solution method")
+ mo.md("""## The solution method""")
return
@@ -153,7 +163,7 @@ def __(cp):
objective = cp.Minimize(radius)
cp.Problem(objective, constraints).solve()
return (center.value, radius.value)
- return smallest_enclosing_circle,
+ return (smallest_enclosing_circle,)
@app.cell
@@ -167,7 +177,7 @@ def __():
@app.cell
def __():
import marimo as mo
- return mo,
+ return (mo,)
if __name__ == "__main__":
diff --git a/examples/third_party/duckdb/duckdb_example.py b/examples/third_party/duckdb/duckdb_example.py
index 5e1569526a..3099fd68e7 100644
--- a/examples/third_party/duckdb/duckdb_example.py
+++ b/examples/third_party/duckdb/duckdb_example.py
@@ -1,6 +1,16 @@
+# /// script
+# requires-python = ">=3.9"
+# dependencies = [
+# "duckdb==1.1.1",
+# "marimo",
+# "pandas==2.2.3",
+# "requests==2.32.3",
+# ]
+# ///
+
import marimo
-__generated_with = "0.8.0"
+__generated_with = "0.8.19"
app = marimo.App(width="full")
@@ -26,7 +36,7 @@ def __(fetch_hugging_face_datasets, mo, pd):
datasets = fetch_hugging_face_datasets()
# Fix lastModified column to be a date from a str
datasets["lastModified"] = pd.to_datetime(datasets["lastModified"])
- return datasets,
+ return (datasets,)
@app.cell(hide_code=True)
@@ -66,7 +76,7 @@ def __(all_tags, dataset_date_range, dataset_length, mo):
),
]
)
- return stats,
+ return (stats,)
@app.cell
@@ -119,7 +129,7 @@ def __(datasets, duckdb, mo, search_filter, tag_filter):
pagination=True,
)
table
- return table,
+ return (table,)
@app.cell
@@ -129,7 +139,7 @@ def __(table):
if table.value is not None and len(table.value)
else None
)
- return selected_dataset,
+ return (selected_dataset,)
@app.cell
@@ -169,7 +179,7 @@ def __(load_hugging_face_dataset, mo, selected_dataset):
pagination=True,
)
selected_parquet
- return selected_parquet,
+ return (selected_parquet,)
@app.cell
@@ -218,7 +228,7 @@ def __(duckdb, mo, url):
],
widths=[1, 1, 2],
)
- return con,
+ return (con,)
@app.cell
@@ -242,7 +252,7 @@ def __(has_selected_file, mo, render_sql_editor):
sql_editor,
]
)
- return sql_editor,
+ return (sql_editor,)
@app.cell
@@ -271,7 +281,7 @@ def __(datasets, mo, render_dataframe_editor):
df_editor,
]
)
- return df_editor,
+ return (df_editor,)
@app.cell
@@ -313,7 +323,7 @@ def __():
def print_month_year(date):
return date.strftime("%b %Y")
- return print_month_year,
+ return (print_month_year,)
@app.cell
diff --git a/examples/third_party/great_tables/great_tables_example.py b/examples/third_party/great_tables/great_tables_example.py
index b6ef51264f..768fa830f2 100644
--- a/examples/third_party/great_tables/great_tables_example.py
+++ b/examples/third_party/great_tables/great_tables_example.py
@@ -1,6 +1,15 @@
+# /// script
+# requires-python = ">=3.9"
+# dependencies = [
+# "great-tables==0.11.1",
+# "marimo",
+# "polars==1.8.2",
+# ]
+# ///
+
import marimo
-__generated_with = "0.8.2"
+__generated_with = "0.8.19"
app = marimo.App(width="medium")
@@ -35,7 +44,7 @@ def __(__file__):
@app.cell
def __(coffee_sales, mo):
revenue = mo.ui.range_slider.from_series(coffee_sales["revenue_dollars"])
- return revenue,
+ return (revenue,)
@app.cell(hide_code=True)
diff --git a/examples/third_party/leafmap/leafmap_example.py b/examples/third_party/leafmap/leafmap_example.py
index a808391e92..f458a70f79 100644
--- a/examples/third_party/leafmap/leafmap_example.py
+++ b/examples/third_party/leafmap/leafmap_example.py
@@ -1,3 +1,10 @@
+# /// script
+# requires-python = ">=3.9"
+# dependencies = [
+# "leafmap==0.38.0",
+# "marimo",
+# ]
+# ///
import marimo
__generated_with = "0.1.59"
diff --git a/examples/third_party/matplotlib/mandelbrot.py b/examples/third_party/matplotlib/mandelbrot.py
index 07feab7508..a556ac3f45 100644
--- a/examples/third_party/matplotlib/mandelbrot.py
+++ b/examples/third_party/matplotlib/mandelbrot.py
@@ -1,16 +1,25 @@
+# /// script
+# requires-python = ">=3.9"
+# dependencies = [
+# "marimo",
+# "matplotlib==3.9.2",
+# "numpy==1.26.4",
+# ]
+# ///
+
import marimo
-__generated_with = "0.1.0"
+__generated_with = "0.8.19"
app = marimo.App()
[email protected](hide_code=True)
def __(mo):
- mo.md("# The Mandelbrot Set")
+ mo.md("""# The Mandelbrot Set""")
return
[email protected](hide_code=True)
def __(mo):
mo.md(
r"""
@@ -36,7 +45,7 @@ def __(mo):
return
[email protected](hide_code=True)
def __(mo, n_max):
mo.md(
f"""
@@ -49,7 +58,7 @@ def __(mo, n_max):
return
[email protected](hide_code=True)
def __(mo, reset_plot_scale, x_offset, y_offset, zoom):
mo.md(
f"""
@@ -77,13 +86,13 @@ def __(compute_mandelbrot, n_max, x_offset, y_offset, zoom):
@app.cell
def __(mo):
n_max = mo.ui.slider(2, 256, step=1, value=30)
- return n_max,
+ return (n_max,)
@app.cell
def __(mo):
reset_plot_scale = mo.ui.button(label="Click to reset")
- return reset_plot_scale,
+ return (reset_plot_scale,)
@app.cell
@@ -139,7 +148,7 @@ def __():
@app.cell
def __():
import marimo as mo
- return mo,
+ return (mo,)
if __name__ == "__main__":
diff --git a/examples/third_party/matplotlib/surfaces.py b/examples/third_party/matplotlib/surfaces.py
index 64e7883e59..673e545d0b 100644
--- a/examples/third_party/matplotlib/surfaces.py
+++ b/examples/third_party/matplotlib/surfaces.py
@@ -1,19 +1,28 @@
+# /// script
+# requires-python = ">=3.9"
+# dependencies = [
+# "marimo",
+# "matplotlib==3.9.2",
+# "numpy==1.26.4",
+# ]
+# ///
+
import marimo
-__generated_with = "0.1.0"
+__generated_with = "0.8.19"
app = marimo.App()
[email protected](hide_code=True)
def __(mo):
- mo.md("# Surfaces")
+ mo.md("""# Surfaces""")
return
@app.cell
def __(plot_3d_surface, selected_function):
ax = plot_3d_surface(selected_function)
- return ax,
+ return (ax,)
@app.cell
@@ -25,7 +34,7 @@ def __(ax, xlim, ylim, zlim):
return
[email protected](hide_code=True)
def __(
a,
b,
@@ -96,7 +105,7 @@ def __(
@app.cell
def __(function, function_options):
selected_function = function_options[function.value]
- return selected_function,
+ return (selected_function,)
@app.cell
@@ -107,7 +116,7 @@ def __(paraboloid, saddle, sphere, torus):
"sphere": sphere,
"torus": torus,
}
- return function_options,
+ return (function_options,)
@app.cell
@@ -120,7 +129,7 @@ def __(mo):
"torus"
], value='paraboloid'
)
- return function,
+ return (function,)
@app.cell
@@ -139,12 +148,12 @@ def __(plt):
fig.set_size_inches(7, 7)
return ax
- return plot_3d_surface,
+ return (plot_3d_surface,)
@app.cell
def __(mo):
- mo.md("### Controls")
+ mo.md("""### Controls""")
return
@@ -233,7 +242,7 @@ def __(grid, saddle_param_a, saddle_param_b):
def saddle():
x, y = grid(xlim=(-1, 1), ylim=(-1, 1))
return x, y, saddle_param_a.value*x**2 - saddle_param_b.value*y**4
- return saddle,
+ return (saddle,)
@app.cell
@@ -241,7 +250,7 @@ def __(a, b, grid):
def paraboloid():
x, y = grid(xlim=(-1, 1), ylim=(-1, 1))
return x, y, a.value*x**2 / 2 + b.value*y**2/ 2
- return paraboloid,
+ return (paraboloid,)
@app.cell
@@ -252,7 +261,7 @@ def __(grid, np, sphere_param_r):
y = np.sin(theta)*np.sin(phi)
z = np.cos(phi)
return sphere_param_r.value*x, sphere_param_r.value*y, sphere_param_r.value*z
- return sphere,
+ return (sphere,)
@app.cell
@@ -266,7 +275,7 @@ def __(grid, np, torus_param_a, torus_param_c):
y = (center_radius + tube_radius*np.cos(theta)) * np.sin(phi)
z = tube_radius*np.sin(theta)
return x, y, z
- return torus,
+ return (torus,)
@app.cell
@@ -277,7 +286,7 @@ def __(np):
x = np.linspace(xmin, xmax, 100)
y = np.linspace(ymin, ymax, 100)
return np.meshgrid(x, y)
- return grid,
+ return (grid,)
@app.cell
@@ -291,7 +300,7 @@ def __():
@app.cell
def __():
import marimo as mo
- return mo,
+ return (mo,)
if __name__ == "__main__":
diff --git a/examples/third_party/plotly/image_selection.py b/examples/third_party/plotly/image_selection.py
index b940474f3e..e42fe107c1 100644
--- a/examples/third_party/plotly/image_selection.py
+++ b/examples/third_party/plotly/image_selection.py
@@ -1,6 +1,16 @@
+# /// script
+# requires-python = ">=3.9"
+# dependencies = [
+# "marimo",
+# "pandas",
+# "plotly==5.24.1",
+# "scikit-image",
+# ]
+# ///
+
import marimo
-__generated_with = "0.1.60"
+__generated_with = "0.8.19"
app = marimo.App(width="full")
@@ -13,19 +23,9 @@ def __():
return go, io, mo, px
-def __(mo):
- mo.md(
- f"""
- Required dependencies: `pip install plotly scikit-image`
- """
- )
- return
-
-
[email protected](hide_code=True)
def __(mo):
- mo.md("#Example: Image with range selection")
+ mo.md("""#Example: Image with range selection""")
return
@@ -58,7 +58,7 @@ def __(mo, plot):
@app.cell
def __(mo):
- mo.md("#Example: Image with overlaid trace")
+ mo.md("""#Example: Image with overlaid trace""")
return
@@ -88,7 +88,7 @@ def __(go, mo):
# Set templates
_fig.update_layout(template="plotly_white")
plot2 = mo.ui.plotly(_fig)
- return plot2,
+ return (plot2,)
@app.cell
diff --git a/examples/third_party/plotly/mapbox.py b/examples/third_party/plotly/mapbox.py
index 04ef72fd04..4d7d95d9a3 100644
--- a/examples/third_party/plotly/mapbox.py
+++ b/examples/third_party/plotly/mapbox.py
@@ -1,32 +1,43 @@
+# /// script
+# requires-python = ">=3.9"
+# dependencies = [
+# "marimo",
+# "pandas==2.2.3",
+# "plotly==5.24.1",
+# ]
+# ///
+
import marimo
-__generated_with = "0.1.51"
+__generated_with = "0.8.19"
app = marimo.App()
[email protected](hide_code=True)
def __(mo):
mo.md(
- """# Mapping Example
+ """
+ # Mapping Example
- This example uses <a href="https://plotly.com/python/scattermapbox/" target="_blank">Mapbox</a> in `plotly.express` to build a scatter plot on a street map. The switch enables the satellite view.
- """
+ This example uses <a href="https://plotly.com/python/scattermapbox/" target="_blank">Mapbox</a> in `plotly.express` to build a scatter plot on a street map. The switch enables the satellite view.
+ """
)
return
[email protected](hide_code=True)
def __(mo):
view_button = mo.ui.switch(value=False)
mo.hstack([mo.md("Satellite view:"), view_button], justify="start")
- return view_button,
+ return (view_button,)
@app.cell
-def __(mo, get_map, view_button):
+def __(get_map, mo, view_button):
f = mo.ui.plotly(get_map(satellite=view_button.value))
f
- return f,
+ return (f,)
+
@app.cell
def __(f, mo):
@@ -66,7 +77,7 @@ def __(px, us_cities):
map.update_layout(mapbox_style="open-street-map")
map.update_layout(margin={"r": 0, "t": 0, "l": 0, "b": 0})
return map
- return get_map,
+ return (get_map,)
@app.cell
@@ -74,7 +85,7 @@ def __(pd):
us_cities = pd.read_csv(
"https://raw.githubusercontent.com/plotly/datasets/master/us-cities-top-1k.csv"
)
- return us_cities,
+ return (us_cities,)
@app.cell
diff --git a/examples/third_party/polars/polars_example.py b/examples/third_party/polars/polars_example.py
index d5ea606b9b..af869d92ed 100644
--- a/examples/third_party/polars/polars_example.py
+++ b/examples/third_party/polars/polars_example.py
@@ -1,28 +1,26 @@
# /// script
# requires-python = ">=3.10"
# dependencies = [
-# "altair",
+# "altair==5.4.1",
# "marimo",
-# "numpy",
-# "polars",
+# "numpy==2.0.2",
+# "polars==1.8.2",
# ]
# ///
import marimo
-__generated_with = "0.8.11"
+__generated_with = "0.8.19"
app = marimo.App(width="full")
[email protected](hide_code=True)
def __(mo):
mo.md(
f"""
# Using `Polars` in `marimo`
> Lightning-fast DataFrame library for Rust and Python
-
- `pip install polars`
"""
)
return
@@ -42,7 +40,7 @@ def __(pl):
df = pl.read_csv(
"https://gist.githubusercontent.com/ritchie46/cac6b337ea52281aa23c049250a4ff03/raw/89a957ff3919d90e6ef2d34235e6bf22304f3366/pokemon.csv"
)
- return df,
+ return (df,)
@app.cell
@@ -90,14 +88,14 @@ def __(df, pl, type_1_filter, type_2_filter):
filtered = filtered.filter(pl.col("Type 1") == type_1_filter.value)
if type_2_filter.value:
filtered = filtered.filter(pl.col("Type 2") == type_2_filter.value)
- return filtered,
+ return (filtered,)
@app.cell
def __(filtered, mo):
table = mo.ui.table(filtered)
table
- return table,
+ return (table,)
@app.cell
diff --git a/examples/third_party/pymde/complete_graph.py b/examples/third_party/pymde/complete_graph.py
index 557d41722d..bd99770266 100644
--- a/examples/third_party/pymde/complete_graph.py
+++ b/examples/third_party/pymde/complete_graph.py
@@ -1,12 +1,20 @@
+# /// script
+# requires-python = ">=3.9"
+# dependencies = [
+# "marimo",
+# "pymde==0.1.18",
+# ]
+# ///
+
import marimo
-__generated_with = "0.1.0"
+__generated_with = "0.8.19"
app = marimo.App()
[email protected](hide_code=True)
def __(mo):
- mo.md("# Visualizing Complete Graphs")
+ mo.md("""# Visualizing Complete Graphs""")
return
@@ -18,7 +26,7 @@ def __(mo):
Choose a number of items $n$: {n_items}
"""
)
- return n_items,
+ return (n_items,)
@app.cell
@@ -36,7 +44,7 @@ def __(mo, pymde):
Choose a penalty function: {penalty_function}
"""
)
- return penalty_function,
+ return (penalty_function,)
@app.cell
@@ -58,7 +66,7 @@ def __(complete_graph, mo, n_items, penalty_function):
{mo.as_html(plot)}
"""
)
- return plot,
+ return (plot,)
@app.cell
@@ -83,13 +91,13 @@ def __(pymde):
@app.cell
def __():
import pymde
- return pymde,
+ return (pymde,)
@app.cell
def __():
import marimo as mo
- return mo,
+ return (mo,)
if __name__ == "__main__":
diff --git a/examples/third_party/pymde/debugging_embeddings.py b/examples/third_party/pymde/debugging_embeddings.py
index f9f42a46a9..42e742e3e6 100644
--- a/examples/third_party/pymde/debugging_embeddings.py
+++ b/examples/third_party/pymde/debugging_embeddings.py
@@ -1,3 +1,9 @@
+# /// script
+# requires-python = ">=3.9"
+# dependencies = [
+# "pymde==0.1.18",
+# ]
+# ///
import marimo
__generated_with = "0.1.68"
diff --git a/examples/third_party/pymde/drawing_graphs.py b/examples/third_party/pymde/drawing_graphs.py
index b4049ce109..c559f56ef5 100644
--- a/examples/third_party/pymde/drawing_graphs.py
+++ b/examples/third_party/pymde/drawing_graphs.py
@@ -1,3 +1,9 @@
+# /// script
+# requires-python = ">=3.9"
+# dependencies = [
+# "pymde==0.1.18",
+# ]
+# ///
import marimo
__generated_with = "0.1.0"
diff --git a/examples/third_party/pymde/embedding_numbers.py b/examples/third_party/pymde/embedding_numbers.py
index 8e7ad8026b..ed10abb877 100644
--- a/examples/third_party/pymde/embedding_numbers.py
+++ b/examples/third_party/pymde/embedding_numbers.py
@@ -1,3 +1,9 @@
+# /// script
+# requires-python = ">=3.9"
+# dependencies = [
+# "pymde==0.1.18",
+# ]
+# ///
import marimo
__generated_with = "0.8.0"
diff --git a/examples/third_party/pymde/google_scholar.py b/examples/third_party/pymde/google_scholar.py
index 1f6ba07c88..1ce3492bd6 100644
--- a/examples/third_party/pymde/google_scholar.py
+++ b/examples/third_party/pymde/google_scholar.py
@@ -1,3 +1,9 @@
+# /// script
+# requires-python = ">=3.9"
+# dependencies = [
+# "pymde==0.1.18",
+# ]
+# ///
import marimo
__generated_with = "0.1.68"
diff --git a/examples/third_party/pymde/interactive_cluster_analysis.py b/examples/third_party/pymde/interactive_cluster_analysis.py
index 769048ec58..ffabdc64f1 100644
--- a/examples/third_party/pymde/interactive_cluster_analysis.py
+++ b/examples/third_party/pymde/interactive_cluster_analysis.py
@@ -1,3 +1,10 @@
+# /// script
+# requires-python = ">=3.9"
+# dependencies = [
+# "pandas",
+# "pymde==0.1.18",
+# ]
+# ///
import marimo
__generated_with = "0.8.0"
diff --git a/examples/third_party/pymde/rotational_invariance.py b/examples/third_party/pymde/rotational_invariance.py
index ecd504acdc..8be58071e0 100644
--- a/examples/third_party/pymde/rotational_invariance.py
+++ b/examples/third_party/pymde/rotational_invariance.py
@@ -1,3 +1,9 @@
+# /// script
+# requires-python = ">=3.9"
+# dependencies = [
+# "pymde==0.1.18",
+# ]
+# ///
import marimo
__generated_with = "0.1.56"
diff --git a/examples/third_party/pymde/tree.py b/examples/third_party/pymde/tree.py
index 05a7cc6825..6da64bfbb6 100644
--- a/examples/third_party/pymde/tree.py
+++ b/examples/third_party/pymde/tree.py
@@ -1,3 +1,9 @@
+# /// script
+# requires-python = ">=3.9"
+# dependencies = [
+# "pymde==0.1.18",
+# ]
+# ///
import marimo
__generated_with = "0.1.0"
diff --git a/examples/third_party/pymde/us_counties.py b/examples/third_party/pymde/us_counties.py
index d64c52d422..b37f946f11 100644
--- a/examples/third_party/pymde/us_counties.py
+++ b/examples/third_party/pymde/us_counties.py
@@ -1,3 +1,10 @@
+# /// script
+# requires-python = ">=3.9"
+# dependencies = [
+# "pandas",
+# "pymde==0.1.18",
+# ]
+# ///
import marimo
__generated_with = "0.1.56"
diff --git a/examples/third_party/substrate/video_generation.py b/examples/third_party/substrate/video_generation.py
index 6f3f01e6ff..9f78ff8ee2 100644
--- a/examples/third_party/substrate/video_generation.py
+++ b/examples/third_party/substrate/video_generation.py
@@ -1,13 +1,21 @@
+# /// script
+# requires-python = ">=3.9"
+# dependencies = [
+# "marimo",
+# "substrate==220240617.1.8",
+# ]
+# ///
+
import marimo
-__generated_with = "0.7.18"
+__generated_with = "0.8.19"
app = marimo.App(width="medium")
@app.cell
def __():
import marimo as mo
- return mo,
+ return (mo,)
@app.cell
@@ -17,7 +25,7 @@ def __(mo):
kind="password",
).form(bordered=False)
API_KEY
- return API_KEY,
+ return (API_KEY,)
@app.cell
@@ -55,7 +63,7 @@ def __(substrate):
def __(mo, res, video_node):
video = res.get(video_node)
mo.image(video.video_uri)
- return video,
+ return (video,)
@app.cell
diff --git a/examples/marimo/arrays_and_dicts.py b/examples/ui/arrays_and_dicts.py
similarity index 80%
rename from examples/marimo/arrays_and_dicts.py
rename to examples/ui/arrays_and_dicts.py
index b021e535bf..aaa2b72f65 100644
--- a/examples/marimo/arrays_and_dicts.py
+++ b/examples/ui/arrays_and_dicts.py
@@ -1,16 +1,23 @@
+# /// script
+# requires-python = ">=3.9"
+# dependencies = [
+# "marimo",
+# ]
+# ///
+
import marimo
-__generated_with = "0.1.0"
+__generated_with = "0.8.19"
app = marimo.App()
[email protected](hide_code=True)
def __(mo):
- mo.md("# Arrays and Dictionaries")
+ mo.md("""# Arrays and Dictionaries""")
return
[email protected](hide_code=True)
def __(mo):
mo.md(
"""
@@ -28,7 +35,7 @@ def __(mo):
@app.cell
def __(mo):
create = mo.ui.button(label="Create new collections")
- return create,
+ return (create,)
@app.cell
@@ -39,7 +46,7 @@ def __(create):
@app.cell
def __(mo):
- mo.md("UI Elements ...")
+ mo.md("""UI Elements ...""")
return
@@ -61,7 +68,7 @@ def __(create, mo, random):
@app.cell
def __(mo):
- mo.md(" ... and their values")
+ mo.md("""... and their values""")
return
diff --git a/examples/marimo/batch_and_form.py b/examples/ui/batch_and_form.py
similarity index 88%
rename from examples/marimo/batch_and_form.py
rename to examples/ui/batch_and_form.py
index 7747b55311..095cb61437 100644
--- a/examples/marimo/batch_and_form.py
+++ b/examples/ui/batch_and_form.py
@@ -1,6 +1,13 @@
+# /// script
+# requires-python = ">=3.9"
+# dependencies = [
+# "marimo",
+# ]
+# ///
+
import marimo
-__generated_with = "0.8.5"
+__generated_with = "0.8.19"
app = marimo.App()
@@ -43,7 +50,7 @@ def __(mo, reset):
)
variables
- return variables,
+ return (variables,)
@app.cell
@@ -74,19 +81,19 @@ def __(reset):
reset
submitted_values = {"x": set(), "y": set()}
- return submitted_values,
+ return (submitted_values,)
@app.cell
def __(mo):
reset = mo.ui.button(label="reset history")
- return reset,
+ return (reset,)
@app.cell
def __():
import marimo as mo
- return mo,
+ return (mo,)
if __name__ == "__main__":
diff --git a/examples/marimo/data_explorer.py b/examples/ui/data_explorer.py
similarity index 88%
rename from examples/marimo/data_explorer.py
rename to examples/ui/data_explorer.py
index 8634ab426f..92e44817de 100644
--- a/examples/marimo/data_explorer.py
+++ b/examples/ui/data_explorer.py
@@ -2,25 +2,25 @@
# requires-python = ">=3.11"
# dependencies = [
# "marimo",
-# "pandas",
-# "matplotlib",
-# "altair",
+# "pandas==2.2.3",
+# "matplotlib==3.9.2",
+# "altair==5.4.1",
# ]
# ///
import marimo
-__generated_with = "0.8.5"
+__generated_with = "0.8.19"
app = marimo.App(width="full")
[email protected](hide_code=True)
def __(mo):
mo.md("""# Data Explorer""")
return
[email protected](hide_code=True)
def __(mo):
sample = "https://github.com/vega/vega/blob/main/docs/data/stocks.csv"
@@ -31,28 +31,26 @@ def __(mo):
You can download a <a href="{sample}" target="_blank">sample CSV</a> if you'd like.
"""
)
- return sample,
+ return (sample,)
[email protected](hide_code=True)
def __(mo, uploaded_file):
- callout_kind = "alert" if (uploaded_file.name() is None) else "neutral"
-
mo.md(
f"""
{mo.hstack([mo.md("**Upload a CSV.**")], justify="center")}
{uploaded_file}
"""
- ).callout(kind=callout_kind)
- return callout_kind,
+ )
+ return
@app.cell
def __(io, mo, pd, uploaded_file):
mo.stop(not uploaded_file.name())
df = pd.read_csv(io.StringIO(uploaded_file.contents().decode()))
- return df,
+ return (df,)
@app.cell
@@ -100,13 +98,13 @@ def __(alt, color_column, df, mo, plot_type, x_column, y_column):
plot(x_column.value, y_column.value, color_column.value)
- return plot,
+ return (plot,)
@app.cell
def __(mo):
uploaded_file = mo.ui.file(filetypes=[".csv"], kind="area")
- return uploaded_file,
+ return (uploaded_file,)
@app.cell
diff --git a/examples/marimo/filterable_table.py b/examples/ui/filterable_table.py
similarity index 89%
rename from examples/marimo/filterable_table.py
rename to examples/ui/filterable_table.py
index 5d6e13950d..e735a7e360 100644
--- a/examples/marimo/filterable_table.py
+++ b/examples/ui/filterable_table.py
@@ -1,10 +1,18 @@
+# /// script
+# requires-python = ">=3.9"
+# dependencies = [
+# "marimo",
+# "pandas==2.2.3",
+# ]
+# ///
+
import marimo
-__generated_with = "0.8.5"
+__generated_with = "0.8.19"
app = marimo.App(width="medium")
[email protected](hide_code=True)
def __(mo):
mo.md(r"""# Filterable DataFrame""")
return
@@ -14,7 +22,7 @@ def __(mo):
def __(data_url, pd):
# Read the csv
df = pd.read_json(data_url("cars.json"))
- return df,
+ return (df,)
@app.cell
@@ -65,14 +73,14 @@ def __(cylinders, horse_power, manufacturer):
& (filtered_df["Horsepower"] <= right)
]
return filtered_df
- return filter_df,
+ return (filter_df,)
@app.cell
def __():
def data_url(file):
return f"https://cdn.jsdelivr.net/npm/[email protected]/data/{file}"
- return data_url,
+ return (data_url,)
@app.cell
diff --git a/examples/marimo/inputs.py b/examples/ui/inputs.py
similarity index 98%
rename from examples/marimo/inputs.py
rename to examples/ui/inputs.py
index 68bee2b2bf..dd04f074c7 100644
--- a/examples/marimo/inputs.py
+++ b/examples/ui/inputs.py
@@ -7,11 +7,11 @@
import marimo
-__generated_with = "0.8.7"
+__generated_with = "0.8.19"
app = marimo.App(width="medium")
[email protected](hide_code=True)
def __(mo):
mo.md(
r"""
@@ -190,7 +190,7 @@ def __(end_date, mo, start_date):
return
[email protected](hide_code=True)
def __(mo):
mo.md("""## Dropdowns""")
return
@@ -214,7 +214,7 @@ def __(mo):
@app.cell
def __():
import marimo as mo
- return mo,
+ return (mo,)
if __name__ == "__main__":
diff --git a/examples/marimo/layout.py b/examples/ui/layout.py
similarity index 80%
rename from examples/marimo/layout.py
rename to examples/ui/layout.py
index e3b1fddb09..e968e0ebae 100644
--- a/examples/marimo/layout.py
+++ b/examples/ui/layout.py
@@ -1,18 +1,25 @@
+# /// script
+# requires-python = ">=3.9"
+# dependencies = [
+# "marimo",
+# ]
+# ///
+
import marimo
-__generated_with = "0.1.0"
+__generated_with = "0.8.19"
app = marimo.App()
[email protected](hide_code=True)
def __(mo):
- mo.md("# Stacks")
+ mo.md("""# Stacks""")
return
[email protected](hide_code=True)
def __(mo):
- mo.md("Use `mo.hstack` and `mo.vstack` to layout outputs in rows and columns.")
+ mo.md("""Use `mo.hstack` and `mo.vstack` to layout outputs in rows and columns.""")
return
@@ -43,7 +50,7 @@ def __(mo):
@app.cell
def __(mo):
- mo.md("## Horizontal Stack: `hstack`")
+ mo.md("""## Horizontal Stack: `hstack`""")
return
@@ -61,7 +68,7 @@ def __(align, boxes, gap, justify, mo, wrap):
@app.cell
def __(mo):
- mo.md("## Vertical Stack: `vstack`")
+ mo.md("""## Vertical Stack: `vstack`""")
return
@@ -91,7 +98,7 @@ def __(mo, size):
@app.cell
def __():
import marimo as mo
- return mo,
+ return (mo,)
if __name__ == "__main__":
diff --git a/examples/marimo/mermaid.py b/examples/ui/mermaid.py
similarity index 93%
rename from examples/marimo/mermaid.py
rename to examples/ui/mermaid.py
index 44bf8eeb31..a9cddc5788 100644
--- a/examples/marimo/mermaid.py
+++ b/examples/ui/mermaid.py
@@ -4,16 +4,17 @@
# "marimo",
# ]
# ///
+
import marimo
-__generated_with = "0.1.76"
+__generated_with = "0.8.19"
app = marimo.App()
@app.cell
def __():
import marimo as mo
- return mo,
+ return (mo,)
@app.cell
@@ -44,7 +45,7 @@ def __(mo):
label="Mermaid editor",
)
graph
- return graph,
+ return (graph,)
@app.cell
diff --git a/examples/marimo/reactive_plots.py b/examples/ui/reactive_plots.py
similarity index 83%
rename from examples/marimo/reactive_plots.py
rename to examples/ui/reactive_plots.py
index 7c297b867c..e8287a6636 100644
--- a/examples/marimo/reactive_plots.py
+++ b/examples/ui/reactive_plots.py
@@ -1,12 +1,21 @@
+# /// script
+# requires-python = ">=3.9"
+# dependencies = [
+# "altair==5.4.1",
+# "marimo",
+# "vega-datasets==0.9.0",
+# ]
+# ///
+
import marimo
-__generated_with = "0.1.29"
+__generated_with = "0.8.19"
app = marimo.App(width="full")
[email protected](hide_code=True)
def __(mo):
- mo.md("# Welcome to marimo!")
+ mo.md("""# Welcome to marimo!""")
return
@@ -14,13 +23,13 @@ def __(mo):
def __(bars, mo, scatter):
chart = mo.ui.altair_chart(scatter & bars)
chart
- return chart,
+ return (chart,)
@app.cell
def __(chart, mo):
(filtered_data := mo.ui.table(chart.value))
- return filtered_data,
+ return (filtered_data,)
@app.cell
@@ -73,7 +82,7 @@ def __():
@app.cell
def __():
import marimo as mo
- return mo,
+ return (mo,)
if __name__ == "__main__":
diff --git a/examples/marimo/refresh.py b/examples/ui/refresh.py
similarity index 97%
rename from examples/marimo/refresh.py
rename to examples/ui/refresh.py
index d6c03e92ae..124b8d6d7d 100644
--- a/examples/marimo/refresh.py
+++ b/examples/ui/refresh.py
@@ -1,10 +1,10 @@
# /// script
# requires-python = ">=3.11"
# dependencies = [
-# "pandas",
-# "vega-datasets",
-# "requests",
-# "altair",
+# "pandas==2.2.3",
+# "vega-datasets==0.9.0",
+# "requests==2.32.3",
+# "altair==5.4.1",
# "marimo",
# ]
# ///
diff --git a/examples/marimo/table.py b/examples/ui/table.py
similarity index 96%
rename from examples/marimo/table.py
rename to examples/ui/table.py
index 829806f139..191b44311f 100644
--- a/examples/marimo/table.py
+++ b/examples/ui/table.py
@@ -7,11 +7,11 @@
import marimo
-__generated_with = "0.8.5"
+__generated_with = "0.8.19"
app = marimo.App()
[email protected](hide_code=True)
def __(mo):
mo.md(
"""
@@ -24,7 +24,7 @@ def __(mo):
return
[email protected](hide_code=True)
def __(mo):
mo.md("""_Create rich tables with selectable rows using_ `mo.ui.table`.""")
return
@@ -43,7 +43,7 @@ def __(mo, office_characters):
selection="single",
pagination=True,
)
- return single_select_table,
+ return (single_select_table,)
@app.cell
@@ -65,7 +65,7 @@ def __(mo, office_characters):
selection="multi",
pagination=True,
)
- return multi_select_table,
+ return (multi_select_table,)
@app.cell
@@ -89,7 +89,7 @@ def __(mo, office_characters):
)
table
- return table,
+ return (table,)
@app.cell
@@ -216,13 +216,13 @@ def __(mo):
"favorite place": mo.image(src="https://picsum.photos/100"),
},
]
- return office_characters,
+ return (office_characters,)
@app.cell
def __():
import marimo as mo
- return mo,
+ return (mo,)
if __name__ == "__main__":
diff --git a/examples/marimo/tabs.py b/examples/ui/tabs.py
similarity index 82%
rename from examples/marimo/tabs.py
rename to examples/ui/tabs.py
index d032e34235..003aa87e58 100644
--- a/examples/marimo/tabs.py
+++ b/examples/ui/tabs.py
@@ -1,18 +1,25 @@
+# /// script
+# requires-python = ">=3.9"
+# dependencies = [
+# "marimo",
+# ]
+# ///
+
import marimo
-__generated_with = "0.1.0"
+__generated_with = "0.8.19"
app = marimo.App()
[email protected](hide_code=True)
def __(mo):
- mo.md("# Tabs")
+ mo.md("""# Tabs""")
return
[email protected](hide_code=True)
def __(mo):
- mo.md("Use `mo.ui.tabs` to organize outputs.")
+ mo.md("""Use `mo.ui.tabs` to organize outputs.""")
return
@@ -61,7 +68,7 @@ def __(employees, first, last, mo, org):
@app.cell
def __():
import marimo as mo
- return mo,
+ return (mo,)
if __name__ == "__main__":
diff --git a/examples/marimo/task_list.py b/examples/ui/task_list.py
similarity index 92%
rename from examples/marimo/task_list.py
rename to examples/ui/task_list.py
index 4755c019d8..72fffe819c 100644
--- a/examples/marimo/task_list.py
+++ b/examples/ui/task_list.py
@@ -4,13 +4,14 @@
# "marimo",
# ]
# ///
+
import marimo
-__generated_with = "0.1.4"
+__generated_with = "0.8.19"
app = marimo.App()
[email protected](hide_code=True)
def __(mo):
mo.md("# Task List").left()
return
@@ -22,7 +23,7 @@ def __(dataclass):
class Task:
name: str
done: bool = False
- return Task,
+ return (Task,)
@app.cell
@@ -37,7 +38,7 @@ def __(mo, mutation_signal):
mutation_signal
task_entry_box = mo.ui.text(placeholder="a task ...")
- return task_entry_box,
+ return (task_entry_box,)
@app.cell
@@ -79,7 +80,7 @@ def __(Task, get_tasks, mo, set_tasks):
[Task(task.name, done=v[i]) for i, task in enumerate(get_tasks())]
),
)
- return task_list,
+ return (task_list,)
@app.cell
@@ -91,13 +92,13 @@ def __(mo, task_list):
@app.cell
def __():
import marimo as mo
- return mo,
+ return (mo,)
@app.cell
def __():
from dataclasses import dataclass
- return dataclass,
+ return (dataclass,)
if __name__ == "__main__":
diff --git a/marimo/_runtime/packages/module_name_to_pypi_name.py b/marimo/_runtime/packages/module_name_to_pypi_name.py
index 1eacceef64..f733fd1cd1 100644
--- a/marimo/_runtime/packages/module_name_to_pypi_name.py
+++ b/marimo/_runtime/packages/module_name_to_pypi_name.py
@@ -678,6 +678,7 @@ def module_name_to_pypi_name() -> dict[str, str]:
"sika": "ahonya-sika",
"singleton": "pysingleton",
"skbio": "scikit-bio",
+ "skimage": "scikit-image",
"sklearn": "scikit-learn",
"slack": "slackclient",
"slugify": "unicode-slugify",
diff --git a/tests/_smoke_tests/run_all.py b/tests/_smoke_tests/run_all.py
index c28a6160e2..111fea9f46 100644
--- a/tests/_smoke_tests/run_all.py
+++ b/tests/_smoke_tests/run_all.py
@@ -28,7 +28,7 @@ async def test_all_smoke_tests() -> None:
semaphore = asyncio.Semaphore(CONCURRENT_TESTS)
tasks = [
- _run_test(file, root, smoke_test_config, semaphore)
+ _run_test(file, root, smoke_test_config, semaphore, with_uv=False)
for file in all_py_paths
]
await asyncio.gather(*tasks)
@@ -46,7 +46,7 @@ async def test_all_examples() -> None:
semaphore = asyncio.Semaphore(CONCURRENT_TESTS)
tasks = [
- _run_test(file, root, smoke_test_config, semaphore)
+ _run_test(file, root, smoke_test_config, semaphore, with_uv=True)
for file in all_py_paths
]
await asyncio.gather(*tasks)
@@ -57,6 +57,7 @@ async def _run_test(
root: str,
smoke_test_config: Dict[str, Any],
semaphore: asyncio.Semaphore,
+ with_uv: bool,
) -> None:
async with semaphore:
relative_file = str(file.relative_to(root))
@@ -75,8 +76,9 @@ async def _run_test(
if "marimo.App(" not in content:
return
+ executable = "uv run" if with_uv else "python"
process, stdout, stderr = await Cmd(
- f"python {file}", timeout=15, input_data=input_data
+ f"{executable} {file}", timeout=15, input_data=input_data
).run()
if failed_reason: