-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 52da7f8
Showing
15 changed files
with
1,247 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
name: Export Notebooks | ||
|
||
on: | ||
# Trigger on new releases from marimo-team/marimo | ||
repository_dispatch: | ||
types: [marimo-release] | ||
|
||
# Trigger on push to main | ||
push: | ||
branches: [main] | ||
|
||
# Trigger nightly | ||
schedule: | ||
- cron: '0 0 * * *' # Run at midnight UTC | ||
|
||
# Allow manual trigger | ||
workflow_dispatch: {} | ||
|
||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
export-notebooks: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: 🚀 Install uv | ||
uses: astral-sh/setup-uv@v4 | ||
with: | ||
enable-cache: true | ||
|
||
- name: 🐍 Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: 3.12 | ||
|
||
- name: 📦 Install marimo | ||
run: | | ||
uv pip install marimo | ||
- name: 📂 Clone marimo examples | ||
run: | | ||
git clone --depth 1 --filter=blob:none --sparse https://github.com/marimo-team/marimo.git | ||
cd marimo | ||
git sparse-checkout set examples | ||
cd .. | ||
mv marimo/examples . | ||
rm -rf marimo | ||
- name: 🛠️ Run export script | ||
run: | | ||
uv run scripts/export_notebooks.py | ||
- name: 🔄 Create Pull Request | ||
uses: peter-evans/create-pull-request@v7 | ||
with: | ||
commit-message: 'Update exported notebooks' | ||
branch: update-exported-notebooks | ||
title: 'Update exported notebooks' | ||
body: 'This PR updates the exported notebooks.' | ||
labels: | | ||
automated | ||
assignees: | | ||
mscolnick | ||
path: 'generated/*' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
# marimo | ||
/examples | ||
|
||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Distribution / packaging | ||
.Python | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
wheels/ | ||
share/python-wheels/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
MANIFEST | ||
|
||
# PyInstaller | ||
# Usually these files are written by a python script from a template | ||
# before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
*.manifest | ||
*.spec | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.nox/ | ||
.coverage | ||
.coverage.* | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
*.cover | ||
*.py,cover | ||
.hypothesis/ | ||
.pytest_cache/ | ||
cover/ | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Django stuff: | ||
*.log | ||
local_settings.py | ||
db.sqlite3 | ||
db.sqlite3-journal | ||
|
||
# Flask stuff: | ||
instance/ | ||
.webassets-cache | ||
|
||
# Scrapy stuff: | ||
.scrapy | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
|
||
# PyBuilder | ||
target/ | ||
|
||
# Jupyter Notebook | ||
.ipynb_checkpoints | ||
|
||
# IPython | ||
profile_default/ | ||
ipython_config.py | ||
|
||
# pyenv | ||
.python-version | ||
|
||
# pipenv | ||
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. | ||
# However, in case you do not want to do that, uncomment the following line to ignore it. | ||
# Pipfile.lock | ||
|
||
# PEP 582; used by e.g. github.com/David-OConnor/pyflow | ||
__pypackages__/ | ||
|
||
# Celery stuff | ||
celerybeat-schedule | ||
celerybeat.pid | ||
|
||
# SageMath parsed files | ||
*.sage.py | ||
|
||
# Environments | ||
.env | ||
.venv | ||
env/ | ||
venv/ | ||
ENV/ | ||
env.bak/ | ||
venv.bak/ | ||
|
||
# Spyder project settings | ||
.spyderproject | ||
.spyderworkspace | ||
|
||
# Rope project settings | ||
.ropeproject | ||
|
||
# mkdocs documentation | ||
/site | ||
|
||
# mypy | ||
.mypy_cache/ | ||
.dmypy.json | ||
dmypy.json | ||
|
||
# Pyre type checker | ||
.pyre/ | ||
|
||
# pytype static type analyzer | ||
.pytype/ | ||
|
||
# Cython debug symbols | ||
cython_debug/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Marimo Integration CI | ||
|
||
Automated CI pipeline for validating and exporting [marimo](https://github.com/marimo-team/marimo) example notebooks. | ||
|
||
## Features | ||
|
||
- Automatically exports whitelisted marimo notebooks to markdown | ||
- Triggers on: | ||
- New marimo releases | ||
- Pushes to main | ||
- Nightly builds | ||
- Manual triggers | ||
|
||
## Setup | ||
|
||
1. Add notebooks to whitelist in `scripts/export_notebooks.py` | ||
2. Configure repository dispatch webhook from marimo-team/marimo for release events | ||
3. Ensure repository has proper write permissions for GitHub Actions | ||
|
||
## Usage | ||
|
||
The pipeline runs automatically on configured triggers. To run manually: | ||
|
||
1. Go to Actions tab | ||
2. Select "Export Notebooks" workflow | ||
3. Click "Run workflow" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
--- | ||
title: Batch And Form | ||
marimo-version: 0.9.29 | ||
--- | ||
|
||
# Batch and Form | ||
<!----> | ||
Make custom UI elements using `batch()`, and turn any UI element | ||
into a form with `form()`. | ||
|
||
```{.python.marimo} | ||
reset | ||
variables = ( | ||
mo.md( | ||
""" | ||
Choose your variable values | ||
{x} | ||
{y} | ||
""" | ||
) | ||
.batch( | ||
x=mo.ui.slider(start=1, stop=10, step=1, label="$x =$"), | ||
y=mo.ui.slider(start=1, stop=10, step=1, label="$y =$"), | ||
) | ||
.form(show_clear_button=True, bordered=False) | ||
) | ||
variables | ||
``` | ||
|
||
```{.python.marimo} | ||
if variables.value is not None: | ||
submitted_values["x"].add(variables.value["x"]) | ||
submitted_values["y"].add(variables.value["y"]) | ||
x = variables.value["x"] if variables.value else "\ldots" | ||
y = variables.value["y"] if variables.value else "\ldots" | ||
mo.md( | ||
f""" | ||
At the moment, | ||
$x = {x}$ and $y = {y}$ | ||
All values ever assumed by $x$ and $y$ are | ||
{mo.hstack([mo.tree(submitted_values), reset], align="center", gap=4)} | ||
""" | ||
).callout() | ||
``` | ||
|
||
```{.python.marimo} | ||
reset | ||
submitted_values = {"x": set(), "y": set()} | ||
``` | ||
|
||
```{.python.marimo} | ||
reset = mo.ui.button(label="reset history") | ||
``` | ||
|
||
```{.python.marimo} | ||
import marimo as mo | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
--- | ||
title: Data Explorer | ||
marimo-version: 0.9.29 | ||
width: full | ||
--- | ||
|
||
# Data Explorer | ||
|
||
```{.python.marimo hide_code="true"} | ||
sample = "https://github.com/vega/vega/blob/main/docs/data/stocks.csv" | ||
mo.md( | ||
f""" | ||
This notebook lets you upload a CSV and plot its columns. | ||
You can download a <a href="{sample}" target="_blank">sample CSV</a> if you'd like. | ||
""" | ||
) | ||
``` | ||
|
||
```{.python.marimo hide_code="true"} | ||
mo.md( | ||
f""" | ||
{mo.hstack([mo.md("**Upload a CSV.**")], justify="center")} | ||
{uploaded_file} | ||
""" | ||
) | ||
``` | ||
|
||
```{.python.marimo} | ||
mo.stop(not uploaded_file.name()) | ||
df = pd.read_csv(io.StringIO(uploaded_file.contents().decode())) | ||
``` | ||
|
||
```{.python.marimo} | ||
mo.ui.table(df, page_size=5, selection=None) | ||
``` | ||
|
||
```{.python.marimo} | ||
plot_type = mo.ui.dropdown( | ||
["line", "hist"], value="line", label="Choose a plot type: " | ||
) | ||
x_column = mo.ui.dropdown(df.columns, label="Choose x-axis: ") | ||
y_column = mo.ui.dropdown(df.columns, label="Choose y-axis: ") | ||
color_column = mo.ui.dropdown(df.columns, label="Choose color-axis: ") | ||
``` | ||
|
||
```{.python.marimo} | ||
mo.hstack( | ||
[x_column, y_column, color_column, plot_type], justify="space-around" | ||
).callout(kind="warn" if not x_column.value else "neutral") | ||
``` | ||
|
||
```{.python.marimo} | ||
mo.stop(not x_column.value) | ||
def plot(x_column, y_column, color_column): | ||
y_column = y_column or "count()" | ||
title = f"{y_column} by {x_column}" | ||
encoding = {"x": x_column, "y": y_column} | ||
if color_column: | ||
encoding["color"] = color_column | ||
if plot_type.value == "line": | ||
chart = alt.Chart(df).mark_line() | ||
else: | ||
chart = alt.Chart(df).mark_bar().encode(x=alt.X(x_column, bin=True)) | ||
return chart.encode(**encoding).properties(title=title, width="container") | ||
plot(x_column.value, y_column.value, color_column.value) | ||
``` | ||
|
||
```{.python.marimo} | ||
uploaded_file = mo.ui.file(filetypes=[".csv"], kind="area") | ||
``` | ||
|
||
```{.python.marimo} | ||
import marimo as mo | ||
import altair as alt | ||
import io | ||
import matplotlib.pyplot as plt | ||
import pandas as pd | ||
``` |
Oops, something went wrong.