-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathgetting-started.py
More file actions
87 lines (62 loc) · 1.96 KB
/
Copy pathgetting-started.py
File metadata and controls
87 lines (62 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# /// script
# dependencies = ["marimo"]
#
# [tool.marimo.k8s]
# storage = "1Gi"
# ///
import marimo
__generated_with = "0.18.4"
app = marimo.App()
@app.cell(hide_code=True)
def _(mo):
mo.md("""
# Welcome to marimo on Kubernetes!
This notebook introduces marimo's **reactive execution model** — if you're
coming from Jupyter, this is the key difference to understand.
""")
@app.cell
def _(mo):
slider = mo.ui.slider(1, 10, value=5, label="Pick a number")
slider
return (slider,)
@app.cell(hide_code=True)
def _(mo, slider):
mo.md(
f"""
## Reactive execution
You picked **{slider.value}**. Try moving the slider above!
Unlike Jupyter, marimo automatically re-runs cells when their dependencies
change. When you moved that slider, this cell re-ran instantly — no need
to manually execute anything.
**Key differences from Jupyter:**
1. **No hidden state** — The notebook state always matches what you see
2. **Cells run in dependency order** — Not top-to-bottom, but based on
which variables each cell uses
3. **No cell numbers** — Order on the page doesn't determine execution order
"""
)
@app.cell
def _(mo, slider):
result = slider.value**2
mo.md(f"""
## Automatic updates
The square of {slider.value} is **{result}**.
This cell depends on `slider.value`, so it updates automatically when you
interact with the slider. marimo tracks these dependencies for you.
""")
@app.cell(hide_code=True)
def _(mo):
mo.md("""
## Next steps
- **Edit this notebook** — Your changes persist to storage
- **Try more UI elements** — `mo.ui.dropdown()`, `mo.ui.text()`,
`mo.ui.checkbox()`, and [more](https://docs.marimo.io/api/inputs/)
- **Run as an app** — Use `kubectl marimo run` to serve as a read-only
dashboard
""")
@app.cell
def _():
import marimo as mo
return (mo,)
if __name__ == "__main__":
app.run()