Jupyter To Marimo

marimo-team/skills/skills/jupyter-to-marimo

作者 marimo-team6454470960d3无许可证174 个星标收录于 2026年10月8日更新于 2026年10月8日仓库7周前更新

Convert a Jupyter notebook (.ipynb) to a marimo notebook (.py).

AI 生成的概览

将 Jupyter 笔记本(.ipynb)转换为 marimo 笔记本(.py)并审查结果。

功能
指导智能体使用 marimo convert 命令把 Jupyter 笔记本转换为 marimo 笔记本,然后审查并验证生成的 Python 文件。内容涵盖依赖包元数据、单元格编排、魔法命令、界面控件、耗时操作的拦截以及密钥处理,并提供关于控件和 LaTeX 的参考文件。最终产出是整理好的 marimo 笔记本,并通过 marimo check 进行验证。
适用场景
当需要把 Jupyter 笔记本迁移或移植到 marimo 时使用。也适用于审查或修正已转换的 marimo 笔记本,检查其正确性、呈现方式和交互行为。
运行要求
需要 uv/uvx 工具来运行 marimo convert 和 marimo check,并能访问源 .ipynb 文件。不附带脚本,仅为说明文档,另有两份关于控件和 LaTeX 的参考文档。

Converting Jupyter Notebooks to Marimo

Convert first

Important: Run the converter before you read the source notebook:

bash
uvx marimo convert <notebook.ipynb> -o <notebook.py>

Read the .ipynb file only if conversion fails or the generated file omits required information. Treat the generated file as a first draft.

Run this command after conversion and after substantial edits:

bash
uvx marimo check <notebook.py>

Review the conversion

  • Verify all required packages in the PEP 723 metadata. The converter can miss some package-installation forms.
  • Remove residual installation cells and stale installation prose. Add version constraints only when required.
  • Use --sandbox when a notebook uses PEP 723 metadata.
  • Preserve the purpose and intended workflow of the source notebook.
  • Arrange cells for presentation. marimo determines execution order from variable definitions and references.
  • A cell can appear before a cell that defines its input.
  • Merge or split cells when the current boundaries reduce clarity.
  • Remove redundant Jupyter artifacts, such as unnecessary display() calls.
  • Review converted magic commands. Keep valid conversions, and resolve comments that report unsupported magics.
  • Put the value to render in the final expression of each cell.
  • Keep added UI and helper functions proportional to the notebook purpose.
  • Replace interactive input methods that wait for terminal input or do not work in the target interface. Use suitable UI controls, script parameters, or environment values.
  • Do not print, log, or save secrets. Consider EnvConfig for multiple environment values.
  • Identify expensive work and external side effects. If work must wait, gate it with mo.stop() and a suitable UI element.
  • Use a form if the user must submit multiple values together.
  • Define downstream values after the gate so the dependency graph defers dependent cells.
  • Present useful results with simple native components. Add live refresh only when the intended workflow requires it.
  • For ipywidgets, read references/widgets.md [blocked].
  • For LaTeX and MathJax, read references/latex.md [blocked].

Validate the result

  • Run marimo check again after all edits.
  • Run the notebook in each intended mode. Confirm that it has the intended behavior.
  • When practical, open the source and converted notebooks side by side and invite the user to review.
  • Compare content, controls, outputs, and workflow. Cell order and layout can differ.
  • Inspect changed files for secrets, generated data, caches, logs, and other runtime files.

来源与署名

来源:marimo-team/skills位于skills/jupyter-to-marimo提交6454470

许可证: 无许可证

内容归原作者所有。SourceWeft 从公开仓库中收录这些内容。

举报或申请下架