You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
marimo has direct support for pdb, the Python debugger. You can set breakpoints
8
-
in your code using the built-in `breakpoint()` function. When the code
9
-
execution reaches a breakpoint, it will pause, and you can inspect variables,
10
-
step through the code, and evaluate expressions.
7
+
marimo supports pdb, the Python debugger. Set breakpoints in your code using
8
+
the built-in `breakpoint()` function. When the code execution reaches a
9
+
breakpoint, it will pause, and you can inspect variables, step through the
10
+
code, and evaluate expressions.
11
11
12
-
Here's an example of how to use `breakpoint()` in a marimo notebook cell.
13
-
14
-

15
-
16
-
Type `help` in the debugger for a list of commands:
17
-
18
-
```txt
19
-
Documented commands (type help <topic>):
20
-
========================================
21
-
EOF cl disable ignore n return u where
22
-
a clear display interact next retval unalias
23
-
alias commands down j p run undisplay
24
-
args condition enable jump pp rv unt
25
-
b cont exceptions l q s until
26
-
break continue exit list quit source up
27
-
bt d h ll r step w
28
-
c debug help longlist restart tbreak whatis
29
-
30
-
Miscellaneous help topics:
31
-
==========================
32
-
exec pdb
33
-
```
34
-
35
-
!!! note
36
-
Since this block is runnable, you can test the debugger directly
12
+
Here's a live example of how to use `breakpoint()` in a marimo notebook cell. Type
13
+
`help` in the debugger for a list of commands.
37
14
38
15
/// marimo-embed
39
16
@@ -52,11 +29,18 @@ def _():
52
29
return
53
30
```
54
31
32
+
55
33
///
56
34
57
-
!!! tip
35
+
!!! warning "The debugger blocks execution"
36
+
37
+
When the debugger is active, you cannot execute cells. Remember to continue
38
+
or quit the debugger to avoid hanging the notebook!
39
+
40
+
??? note "Adding breakpoints in the stack trace"
58
41
Click the little bug icon in the stack trace to add breakpoints.
59
-
<videoautoplaymutedloopplaysinlinewidth="100%"align="center"src="/_static/docs-pdb-breakpoint.webm"alt="Animation showing how to click the bug icon to add PDB breakpoints">
42
+
43
+
<video muted controls playsinline width="100%" align="center" src="/_static/docs-pdb-breakpoint.webm" alt="Animation showing how to click the bug icon to add PDB breakpoints">
60
44
</video>
61
45
Clicking on the cell link will also take you to the cell where the error occurred.
62
46
@@ -66,25 +50,24 @@ If your code raises an exception, you can use postmortem debugging to inspect
66
50
the state of the program at the point where the exception occurred. Click on
67
51
the "Launch debugger" button as shown below:
68
52
69
-
<videoautoplaymutedloopplaysinlinewidth="100%"align="center"src="/_static/docs-postmortem-debugging.webm"alt="Video demonstrating postmortem debugging with the Launch debugger button">
53
+
<videomutedcontrolsplaysinlinewidth="100%"align="center"src="/_static/docs-postmortem-debugging.webm"alt="Video demonstrating postmortem debugging with the Launch debugger button">
70
54
</video>
71
55
56
+
## Debugging notebooks as scripts
72
57
73
-
!!! note
74
-
Other tools like the following will also work in marimo notebooks:
75
-
76
-
```python
77
-
import code
78
-
code.interact()
79
-
return
80
-
```
58
+
Since marimo notebooks are standard Python files, you can run them as scripts
59
+
from the command line. The following command will run your marimo notebook and
60
+
drop you into the pdb debugger if an exception occurs, or if you hit a
61
+
breakpoint.
81
62
82
-
!!! danger
83
-
Remember to continue or quit the debugger to avoid hanging the notebook!
63
+
```bash
64
+
python -m pdb your_script.py
65
+
```
84
66
85
-
## Tips for debugging marimo notebooks with AI
67
+
## Debugging with AI
86
68
87
-
marimo provides built-in integration with AI assistants to help debug your notebooks more effectively.
69
+
marimo provides built-in integration with AI assistants to help you debug your
70
+
notebooks.
88
71
89
72
### Ask about notebook errors
90
73
@@ -117,26 +100,17 @@ advice.
117
100
concepts like reactive execution, cell dependencies, and the differences
118
101
between marimo notebooks and traditional Jupyter notebooks.
119
102
120
-
## Debugging notebooks as a script
121
-
Since marimo notebooks are standard Python files, you can run them as scripts
122
-
from the command line. The following command will run your marimo notebook and
123
-
drop you into the pdb debugger if an exception occurs, or if you hit a
124
-
breakpoint.
125
-
126
-
```bash
127
-
python -m pdb your_script.py
128
-
```
129
-
130
-
## External IDE debugging with `debugpy`
103
+
## Integrating with external IDEs
131
104
132
-
marimo supports debugging with IDEs, like VSCode, which natively support the
105
+
marimo supports debugging with IDEs, like VS Code, which natively support the
133
106
`debugpy` library. This allows you to set breakpoints, step through code, and
134
107
inspect variables directly from your IDE.
135
108
136
-
### Script mode
137
-
You can debug marimo notebooks in VSCode using the following `launch.json`.
138
-
This launch configuration will debug a marimo notebook in [script
139
-
mode](./scripts.md).
109
+
### Running as scripts
110
+
111
+
You can debug marimo notebooks in VS Code using the following `launch.json`.
112
+
This launch configuration will debug a marimo notebook executing it as a
113
+
[script](./scripts.md).
140
114
141
115
```json
142
116
{
@@ -155,9 +129,10 @@ mode](./scripts.md).
155
129
}
156
130
```
157
131
158
-
### Edit mode
132
+
### Interactive development
133
+
159
134
Edit mode debugging allows the marimo editor to trigger breakpoints set in an
160
-
IDE like VSCode. Running in this mode will automatically start your notebook in
135
+
IDE like VS Code. Running in this mode will automatically start your notebook in
161
136
[watch mode](./editor_features/watching.md). Note that the file state and
162
137
editor must be consistent for break points to correctly work. If debugging is
163
138
not acting as expected, force a notebook save and toggle the relevant
@@ -185,18 +160,12 @@ Use the following `launch.json` configuration to enable edit mode debugging:
Copy file name to clipboardExpand all lines: docs/guides/lint_rules/index.md
+5-3Lines changed: 5 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,12 @@
1
1
# Lint Rules
2
2
3
-
marimo includes a comprehensive linting system that helps you write better, more reliable notebooks. The linter checks for various issues that could prevent your notebook from running correctly or cause confusion.
3
+
marimo includes a linter that helps you write better notebooks. The linter
4
+
checks for various issues that could prevent your notebook from running
Copy file name to clipboardExpand all lines: docs/guides/publishing/embedding.md
+1-4Lines changed: 1 addition & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,12 +7,9 @@ are the main approaches:
7
7
* Host on [GitHub Pages](github_pages.md) or [self-host WASM HTML](self_host_wasm.md),
8
8
and `<iframe>` the published notebook.
9
9
*`<iframe>` a [playground](playground.md) notebook, and [customize the embedding](playground.md#embedding-in-other-web-pages) with query params.
10
-
(This is what we do throughout docs.marimo.io.)
10
+
(This is what we do throughout https://docs.marimo.io.)
11
11
* Use the [marimo snippets](from_code_snippets.md) plugin to replace code snippets in HTML or markdown with interactive notebooks.
12
12
13
-
We plan to provide more turn-key solutions for static site generation with
14
-
marimo notebooks in the future.
15
-
16
13
## Iframe Sandbox Configuration
17
14
18
15
When embedding marimo notebooks in sandboxed iframes, proper configuration is essential for full functionality. marimo is designed to gracefully degrade when certain features are restricted, but understanding these requirements will help you provide the best experience.
0 commit comments