Coming from Papermill¶
If you’re familiar with Papermill and looking to transition to marimo, this guide will help you understand how to achieve similar functionality using marimo’s features.
Parameterizing Notebooks¶
Papermill
Papermill allows you to parameterize notebooks by defining a “parameters” cell and injecting values at runtime.
marimo
marimo offers two main ways to parameterize notebooks:
Command Line Arguments: Use
mo.cli_args
to access command-line arguments passed to your notebook.import marimo as mo # Access CLI args args = mo.cli_args param1 = args.get("param1", "default_value")
Run your notebook as a script with:
python notebook.py -- --param1 value1
Run your notebook as an app with:
marimo run notebook.py -- --param1 value1
Query Parameters: For web apps, use
mo.query_params
to access URL query parameters.import marimo as mo # Access query params params = mo.query_params() param1 = params.get("param1", "default_value")
Access your app with:
marimo run notebook.py
Then visit:
http://your-app-url/?param1=value1
Executing Notebooks¶
Papermill
Papermill allows you to execute notebooks programmatically and pass parameters.
marimo
marimo notebooks are pure Python files, making them easy to execute programmatically:
As a module:
import notebook notebook.app.run()
Using subprocess:
import subprocess subprocess.run(["python", "notebook.py", "--", "--param1", "value1"])
Storing or Sharing Artifacts¶
Papermill
Papermill can store executed notebooks with output.
marimo
marimo offers several options for storing and sharing outputs:
Export to HTML:
marimo export html notebook.py -o notebook.html
Deploy as Web App:
marimo run notebook.py
Auto-export HTML: You can configure marimo to automatically export to HTML during the editing process. This is configured in the marimo application settings directly in the editor. This way, after changes are made to your notebook, an HTML snapshot is generated, and placed in a
.marimo/
directory in the same location as your notebook.
Workflow Integration¶
Papermill
Papermill is often used in data pipelines and workflow systems.
marimo
marimo notebooks can be easily integrated into workflows:
As Python Scripts: marimo notebooks are Python files, so they can be executed directly in most workflow systems. See our examples for integrating with popular tools.
Programmatic Execution: Importing notebook as Python modules or executing via subprocess allows for chaining together multiple notebooks in a workflow.