Loading...
Loading...
Compare original and translation side by side
.py.py@app.cell@app.celldef _(deps):return var,@app.cell@app.celldef _(deps):return var,marimo check notebook.pymarimo export ipynb notebook.py -o __marimo__/notebook.ipynb --include-outputsmarimo check notebook.pymarimo export ipynb notebook.py -o __marimo__/notebook.ipynb --include-outputs| Excuse | Reality | Do Instead |
|---|---|---|
| "marimo check passed, so it works" | Syntax check ≠ runtime correctness | EXECUTE with --include-outputs and inspect |
| "Just a small change, can't break anything" | Reactivity means small changes propagate everywhere | VERIFY with full execution |
| "I'll let marimo handle the dependency tracking" | Verification of correct behavior is still required | CHECK outputs match expectations |
| "The function signature looks right" | Wrong deps/returns break reactivity silently | VALIDATE all vars are in params AND returns |
| "I can modify the function signature" | Breaks marimo's dependency detection | ONLY edit inside function bodies |
| "Variables can be used without returning them" | Will cause NameError in dependent cells | RETURN all created variables |
| "I can skip the trailing comma for single returns" | Python treats | USE |
| 借口 | 实际情况 | 正确做法 |
|---|---|---|
| "marimo check通过了,所以肯定能运行" | 语法检查 ≠ 运行时正确性 | 加上--include-outputs参数执行并核查输出 |
| "只是小修改,不会破坏任何功能" | 响应式特性意味着小修改会全局传播 | 完整执行验证 |
| "我让marimo自己处理依赖追踪就行" | 仍需要验证行为正确性 | 检查输出是否符合预期 |
| "函数签名看起来没问题" | 错误的依赖/返回值会静默破坏响应式特性 | 验证所有变量都在参数和返回值中 |
| "我可以修改函数签名" | 会破坏marimo的依赖检测 | 仅编辑函数体内部内容 |
| "变量不用返回也能使用" | 会在依赖单元格中触发NameError | 返回所有创建的变量 |
| "单个返回值可以省略末尾的逗号" | Python会将 | 单个返回值使用 |
@app.cellmarimo check notebook.pymarimo export ipynb notebook.py -o __marimo__/notebook.ipynb --include-outputs@app.cellmarimo check notebook.pymarimo export ipynb notebook.py -o __marimo__/notebook.ipynb --include-outputs1. EDIT → Modify code inside @app.cell function bodies only
2. CHECK → marimo check notebook.py
3. EXECUTE → marimo export ipynb notebook.py -o __marimo__/notebook.ipynb --include-outputs
4. INSPECT → Use notebook-debug verification
5. VERIFY → Outputs match expectations
6. CLAIM → "Notebook works" only after all gates passed1. 编辑 → 仅修改@app.cell函数体内部代码
2. 检查 → marimo check notebook.py
3. 执行 → marimo export ipynb notebook.py -o __marimo__/notebook.ipynb --include-outputs
4. 核查 → 使用notebook-debug验证
5. 确认 → 输出符合预期
6. 声明 → 仅在所有关卡通过后声明「笔记本可正常运行」.py@app.cell.py@app.cellimport marimo
app = marimo.App()
@app.cell
def _(pl): # Dependencies as parameters
df = pl.read_csv("data.csv")
return df, # Trailing comma required for single return
@app.cell
def _(df, pl):
summary = df.describe()
filtered = df.filter(pl.col("value") > 0)
return summary, filtered # Multiple returnsimport marimo
app = marimo.App()
@app.cell
def _(pl): # 依赖作为参数传入
df = pl.read_csv("data.csv")
return df, # 单个返回值要求末尾带逗号
@app.cell
def _(df, pl):
summary = df.describe()
filtered = df.filter(pl.col("value") > 0)
return summary, filtered # 多个返回值@app.cell$mo.md("Cost: ")mo.md("Cost: $50")@app.cell$mo.md("Cost: ")mo.md("Cost: $50")| Command | Purpose |
|---|---|
| marimo: Open notebook in browser editor for interactive development |
| marimo: Run notebook as executable app |
| marimo: Validate notebook structure and syntax without execution |
| marimo: Convert Jupyter notebook to marimo format |
| 命令 | 用途 |
|---|---|
| marimo:在浏览器编辑器中打开笔记本用于交互式开发 |
| marimo:将笔记本作为可执行应用运行 |
| marimo:无需执行即可验证笔记本结构和语法 |
| marimo:将Jupyter笔记本转换为marimo格式 |
undefinedundefined
**Key difference:** HTML export runs the notebook by default. ipynb export does NOT - use `--include-outputs` to run and capture outputs.
**Tip:** Use `__marimo__/` folder for all exports (ipynb, html). The editor can auto-save there.
**核心差异:** HTML导出默认会运行笔记本,ipynb导出不会 - 使用`--include-outputs`运行并捕获输出。
**提示:** 所有导出文件(ipynb、html)都存放在`__marimo__/`文件夹下,编辑器可自动保存到该位置。mo.uimo.sql(df, "SELECT * FROM df")mo.md("# Heading")mo.uimo.sql(df, "SELECT * FROM df")mo.md("# 标题")undefinedundefinedRuns syntax check, marimo validation, and cell structure overview in one command.
**2. Runtime errors:** Export with outputs, then use `notebook-debug` skill:
```bash一条命令即可运行语法检查、marimo验证和单元格结构概览。
**2. 运行时错误:** 导出包含输出的文件,然后使用`notebook-debug`技能:
```bashundefinedundefined| Issue | Fix |
|---|---|
| Variable redefinition | Rename one variable or merge cells |
| Circular dependency | Break cycle by merging or restructuring |
| Missing return | Add |
| Import not available | Ensure import cell returns the module |
| 问题 | 修复方案 |
|---|---|
| 变量重定义 | 重命名其中一个变量或合并单元格 |
| 循环依赖 | 通过合并或重构打破循环 |
| 缺少返回值 | 添加带末尾逗号的 |
| 导入不可用 | 确保导入单元格返回该模块 |
references/reactivity.mdreferences/debugging.mdreferences/widgets.mdreferences/sql.mdreferences/reactivity.mdreferences/debugging.mdreferences/widgets.mdreferences/sql.mdexamples/examples/basic_notebook.pyexamples/data_analysis.pyexamples/interactive_widgets.pyexamples/examples/basic_notebook.pyexamples/data_analysis.pyexamples/interactive_widgets.pyscripts/scripts/check_notebook.shscripts/get_cell_map.pyscripts/scripts/check_notebook.shscripts/get_cell_map.pynotebook-debugnotebook-debug