A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
internal: remove whitespace in tutorials (#6588)
Myles Scolnick0e58683fd50b
diff --git a/marimo/_tutorials/intro.py b/marimo/_tutorials/intro.pyindex 335420f5d6..c44f975e3d 100644--- a/marimo/_tutorials/intro.py+++ b/marimo/_tutorials/intro.py@@ -2,7 +2,7 @@import marimo-__generated_with = "0.15.5"+__generated_with = "0.16.2"app = marimo.App()@@ -24,14 +24,14 @@ def _(mo):def _(mo, slider):mo.md(f"""- marimo is a **reactive** Python notebook.+ marimo is a **reactive** Python notebook.- This means that unlike traditional notebooks, marimo notebooks **run- automatically** when you modify them or- interact with UI elements, like this slider: {slider}.+ This means that unlike traditional notebooks, marimo notebooks **run+ automatically** when you modify them or+ interact with UI elements, like this slider: {slider}.- {"##" + "🍃" * slider.value}- """+ {"##" + "🍃" * slider.value}+ """)return@@ -73,19 +73,19 @@ def _(mo):def _(mo):mo.md("""- ## 1. Reactive execution+ ## 1. Reactive execution- A marimo notebook is made up of small blocks of Python code called- cells.+ A marimo notebook is made up of small blocks of Python code called+ cells.- marimo reads your cells and models the dependencies among them: whenever- a cell that defines a global variable is run, marimo- **automatically runs** all cells that reference that variable.+ marimo reads your cells and models the dependencies among them: whenever+ a cell that defines a global variable is run, marimo+ **automatically runs** all cells that reference that variable.- Reactivity keeps your program state and outputs in sync with your code,- making for a dynamic programming environment that prevents bugs before they- happen.- """+ Reactivity keeps your program state and outputs in sync with your code,+ making for a dynamic programming environment that prevents bugs before they+ happen.+ """)return@@ -145,10 +145,10 @@ def _(mo):def _(mo):mo.md("""- **Global names must be unique.** To enable reactivity, marimo imposes a- constraint on how names appear in cells: no two cells may define the same- variable.- """+ **Global names must be unique.** To enable reactivity, marimo imposes a+ constraint on how names appear in cells: no two cells may define the same+ variable.+ """)return@@ -187,16 +187,16 @@ def _(mo):def _(mo):mo.md("""- ## 2. UI elements+ ## 2. UI elements- Cells can output interactive UI elements. Interacting with a UI- element **automatically triggers notebook execution**: when- you interact with a UI element, its value is sent back to Python, and- every cell that references that element is re-run.+ Cells can output interactive UI elements. Interacting with a UI+ element **automatically triggers notebook execution**: when+ you interact with a UI element, its value is sent back to Python, and+ every cell that references that element is re-run.- marimo provides a library of UI elements to choose from under- `marimo.ui`.- """+ marimo provides a library of UI elements to choose from under+ `marimo.ui`.+ """)return@@ -235,21 +235,21 @@ def _(icon, mo, repetitions):def _(mo):mo.md("""- ## 3. marimo is just Python+ ## 3. marimo is just Python- marimo cells parse Python (and only Python), and marimo notebooks are- stored as pure Python files — outputs are _not_ included. There's no- magical syntax.+ marimo cells parse Python (and only Python), and marimo notebooks are+ stored as pure Python files — outputs are _not_ included. There's no+ magical syntax.- The Python files generated by marimo are:+ The Python files generated by marimo are:- - easily versioned with git, yielding minimal diffs- - legible for both humans and machines- - formattable using your tool of choice,- - usable as Python scripts, with UI elements taking their default- values, and- - importable by other modules (more on that in the future).- """+ - easily versioned with git, yielding minimal diffs+ - legible for both humans and machines+ - formattable using your tool of choice,+ - usable as Python scripts, with UI elements taking their default+ values, and+ - importable by other modules (more on that in the future).+ """)return@@ -258,15 +258,15 @@ def _(mo):def _(mo):mo.md("""- ## 4. Running notebooks as apps+ ## 4. Running notebooks as apps- marimo notebooks can double as apps. Click the app window icon in the- bottom-right to see this notebook in "app view."+ marimo notebooks can double as apps. Click the app window icon in the+ bottom-right to see this notebook in "app view."- Serve a notebook as an app with `marimo run` at the command-line.- Of course, you can use marimo just to level-up your- notebooking, without ever making apps.- """+ Serve a notebook as an app with `marimo run` at the command-line.+ Of course, you can use marimo just to level-up your+ notebooking, without ever making apps.+ """)return@@ -275,56 +275,56 @@ def _(mo):def _(mo):mo.md("""- ## 5. The `marimo` command-line tool+ ## 5. The `marimo` command-line tool- **Creating and editing notebooks.** Use+ **Creating and editing notebooks.** Use- ```- marimo edit- ```+ ```+ marimo edit+ ```- in a terminal to start the marimo notebook server. From here- you can create a new notebook or edit existing ones.+ in a terminal to start the marimo notebook server. From here+ you can create a new notebook or edit existing ones.- **Running as apps.** Use+ **Running as apps.** Use- ```- marimo run notebook.py- ```+ ```+ marimo run notebook.py+ ```- to start a webserver that serves your notebook as an app in read-only mode,- with code cells hidden.+ to start a webserver that serves your notebook as an app in read-only mode,+ with code cells hidden.- **Convert a Jupyter notebook.** Convert a Jupyter notebook to a marimo- notebook using `marimo convert`:+ **Convert a Jupyter notebook.** Convert a Jupyter notebook to a marimo+ notebook using `marimo convert`:- ```- marimo convert your_notebook.ipynb > your_app.py- ```+ ```+ marimo convert your_notebook.ipynb > your_app.py+ ```- **Tutorials.** marimo comes packaged with tutorials:+ **Tutorials.** marimo comes packaged with tutorials:- - `dataflow`: more on marimo's automatic execution- - `ui`: how to use UI elements- - `markdown`: how to write markdown, with interpolated values and- LaTeX- - `plots`: how plotting works in marimo- - `sql`: how to use SQL- - `layout`: layout elements in marimo- - `fileformat`: how marimo's file format works- - `markdown-format`: for using `.md` files in marimo- - `for-jupyter-users`: if you are coming from Jupyter+ - `dataflow`: more on marimo's automatic execution+ - `ui`: how to use UI elements+ - `markdown`: how to write markdown, with interpolated values and+ LaTeX+ - `plots`: how plotting works in marimo+ - `sql`: how to use SQL+ - `layout`: layout elements in marimo+ - `fileformat`: how marimo's file format works+ - `markdown-format`: for using `.md` files in marimo+ - `for-jupyter-users`: if you are coming from Jupyter- Start a tutorial with `marimo tutorial`; for example,+ Start a tutorial with `marimo tutorial`; for example,- ```- marimo tutorial dataflow- ```+ ```+ marimo tutorial dataflow+ ```- In addition to tutorials, we have examples in our- [our GitHub repo](https://www.github.com/marimo-team/marimo/tree/main/examples).- """+ In addition to tutorials, we have examples in our+ [our GitHub repo](https://www.github.com/marimo-team/marimo/tree/main/examples).+ """)return@@ -333,10 +333,10 @@ def _(mo):def _(mo):mo.md("""- ## 6. The marimo editor+ ## 6. The marimo editor- Here are some tips to help you get started with the marimo editor.- """+ Here are some tips to help you get started with the marimo editor.+ """)return@@ -357,11 +357,11 @@ def _(mo):def _(mo):mo.md("""- The name "marimo" is a reference to a type of algae that, under- the right conditions, clumps together to form a small sphere- called a "marimo moss ball". Made of just strands of algae, these- beloved assemblages are greater than the sum of their parts.- """+ The name "marimo" is a reference to a type of algae that, under+ the right conditions, clumps together to form a small sphere+ called a "marimo moss ball". Made of just strands of algae, these+ beloved assemblages are greater than the sum of their parts.+ """)returndiff --git a/marimo/_tutorials/markdown.py b/marimo/_tutorials/markdown.pyindex 2ebf7bcdae..bb9a1b85ad 100644--- a/marimo/_tutorials/markdown.py+++ b/marimo/_tutorials/markdown.py@@ -11,7 +11,7 @@import marimo-__generated_with = "0.15.5"+__generated_with = "0.16.2"app = marimo.App()@@ -19,25 +19,25 @@ app = marimo.App()def _(mo):mo.md("""- # Hello, Markdown!+ # Hello, Markdown!- Use marimo's "`md`" function to write markdown. This function compiles Markdown into HTML that marimo can display.+ Use marimo's "`md`" function to write markdown. This function compiles Markdown into HTML that marimo can display.- For example, here's the code that rendered the above title and- paragraph:+ For example, here's the code that rendered the above title and+ paragraph:- ```python3- mo.md(- '''- # Hello, Markdown!-- Use marimo's "`md`" function to embed rich text into your marimo- apps. This function compiles your Markdown into HTML that marimo- can display.- '''- )- ```- """+ ```python3+ mo.md(+ '''+ # Hello, Markdown!++ Use marimo's "`md`" function to embed rich text into your marimo+ apps. This function compiles your Markdown into HTML that marimo+ can display.+ '''+ )+ ```+ """)return@@ -46,20 +46,20 @@ def _(mo):def _(mo):mo.md(r"""- **Tip: toggling between the Markdown and Python editor**+ **Tip: toggling between the Markdown and Python editor**- Although markdown is written with `mo.md`, marimo provides a markdown editor- that hides this boilerplate from you, for cells that only contain `mo.md(...)`.+ Although markdown is written with `mo.md`, marimo provides a markdown editor+ that hides this boilerplate from you, for cells that only contain `mo.md(...)`.- Toggle between the Markdown and Python- editors by clicking the blue icon in the top-right of the editor,- entering `Ctrl/Cmd+Shift+M`, or using the "cell actions menu". You can- also **hide** the markdown editor through the cell actions menu.+ Toggle between the Markdown and Python+ editors by clicking the blue icon in the top-right of the editor,+ entering `Ctrl/Cmd+Shift+M`, or using the "cell actions menu". You can+ also **hide** the markdown editor through the cell actions menu.- **Tip:** To interpolate Python values into markdown strings, you'll need to use- a Python f-string; do this by checking the `f` box in the bottom-right corner of the- markdown editor, or with `mo.md(f"...")` in the Python view.- """+ **Tip:** To interpolate Python values into markdown strings, you'll need to use+ a Python f-string; do this by checking the `f` box in the bottom-right corner of the+ markdown editor, or with `mo.md(f"...")` in the Python view.+ """)return@@ -68,33 +68,33 @@ def _(mo):def _(mo):mo.md(r"""- ## LaTeX- You can embed LaTeX in Markdown.-- For example,+ ## LaTeX+ You can embed LaTeX in Markdown.- ```python3- mo.md(r'$f : \mathbf{R} \to \mathbf{R}$')- ```+ For example,- renders $f : \mathbf{R} \to \mathbf{R}$, while-- ```python3- mo.md(- r'''- \[- f: \mathbf{R} \to \mathbf{R}- \]- '''- )- ```+ ```python3+ mo.md(r'$f : \mathbf{R} \to \mathbf{R}$')+ ```- renders the display math+ renders $f : \mathbf{R} \to \mathbf{R}$, while+ ```python3+ mo.md(+ r'''\[- f: \mathbf{R} \to \mathbf{R}.+ f: \mathbf{R} \to \mathbf{R}\]- """+ '''+ )+ ```++ renders the display math++ \[+ f: \mathbf{R} \to \mathbf{R}.+ \]+ """)return@@ -133,14 +133,14 @@ def _(mo):def _(mo):mo.md("""- ## Interpolating Python values+ ## Interpolating Python values- You can interpolate Python values into markdown using- `f-strings` and marimo's ` as_html` function. This lets you create- markdown whose contents depend on data that changes at runtime.+ You can interpolate Python values into markdown using+ `f-strings` and marimo's ` as_html` function. This lets you create+ markdown whose contents depend on data that changes at runtime.- Here are some examples.- """+ Here are some examples.+ """)return@@ -152,6 +152,7 @@ def _(mo, np, plt):plt.plot(_x, np.sin(_x))return plt.gca()+mo.md(f"""### Plots@@ -195,7 +196,7 @@ def _(mo):@app.celldef _(leaves, mo):- mo.md(f"""Your leaves: {'🍃' * leaves.value}""")+ mo.md(f"""Your leaves: {"🍃" * leaves.value}""")return@@ -216,11 +217,13 @@ def _(mo):def _(mo, np):import polars as pl+def make_dataframe():x = np.linspace(0, 2 * np.pi, 10)y = np.sin(x)return pl.DataFrame({"x": x, "sin(x)": y})+mo.md(f"""### Other objects@@ -260,12 +263,12 @@ def _(mo):def _(mo):mo.md("""- ## Putting it all together+ ## Putting it all together- Here's a more interesting example that puts together- everything we've learned: rendering markdown with LaTeX that depends on- the values of Python objects.- """+ Here's a more interesting example that puts together+ everything we've learned: rendering markdown with LaTeX that depends on+ the values of Python objects.+ """)return@@ -298,11 +301,11 @@ def _(mo, np, plt):def _(amplitude, mo, period):mo.md(f"""- **A sin curve.**+ **A sin curve.**- - {amplitude}- - {period}- """+ - {amplitude}+ - {period}+ """)return@@ -311,15 +314,15 @@ def _(amplitude, mo, period):def _(amplitude, mo, period, plotsin):mo.md(rf"""- You're viewing the graph of+ You're viewing the graph of- \[- f(x) = {amplitude.value}\sin((2\pi/{period.value:0.2f})x),- \]+ \[+ f(x) = {amplitude.value}\sin((2\pi/{period.value:0.2f})x),+ \]- with $x$ ranging from $0$ to $2\pi$.- {mo.as_html(plotsin(amplitude.value, period.value))}- """+ with $x$ ranging from $0$ to $2\pi$.+ {mo.as_html(plotsin(amplitude.value, period.value))}+ """)return