Skip to content

What is marimo-export?

marimo-export runs selected states of a marimo notebook and writes their named results to a portable directory. Python, TypeScript, agents, and custom clients can read that directory after the producer stops.

Suppose report.py derives a summary and chart from a days slider. This ExportSpec publishes weekly and monthly results:

yaml
schema: marimo-export.spec.v2
default_state: weekly
states:
  weekly: {}
  monthly:
    days: 30
outputs:
  summary:
    source: { kind: json, selector: summary }
  chart:
    source: { kind: output, selector: chart }

The weekly state row keeps the slider's initial value. The monthly row sets it to 30. Planning fills omitted inputs from the captured input baseline, so every row becomes a complete input vector.

summary and chart are outputs. An output is a stable consumer-facing name available in every exported state. Its source selects a notebook result. Its representation, a codec and media type, tells readers how that result is stored and decoded.

Together, the complete input vectors and named outputs form the export's finite state-output relation:

Exported stateComplete inputssummarychart
weekly{"days": 7}JSON recordRendered-output snapshot
monthly{"days": 30}JSON recordRendered-output snapshot

From notebook to consumer

Each public operation owns one transition:

OperationWhat it doesResult
planInspects the producer, completes state rows, and finds reusable and missing workExportPlan
prepareStarts a saved notebook and prepares missing statesLeased PreparedExport
captureBorrows a named live session and prepares missing statesLeased PreparedExport
writeCopies one prepared export to a destination and verifies itNotebook export directory
buildRuns prepare, then write, for a saved notebookNotebook export directory
openValidates canonical index.json and creates an immutable readerNotebookExport reader
resolveSelects an exported state by alias or input valuesExportState
loadVerifies and decodes one output representationLoaded value
mountAttaches a loaded interactive value to a document elementDisposable mounted view

The written notebook export has one entry point:

text
dist/report/
  index.json
  assets/
    <content-addressed files>

index.json records notebook and producer provenance, state aliases, complete input vectors, output descriptors, and asset references. An output descriptor records the representation, provenance, and either an inline value or a content-addressed asset reference.

Preparation and reuse

marimo-export keeps reusable producer results in an export repository. A prepared state belongs to one producer identity, output plan, and complete input fingerprint. A prepared export is a lease-protected export generation for one exact ExportSpec.

The export repository and marimo's computation cache solve different problems:

StorageReuses
marimo computation cacheNotebook cell results during producer execution
marimo-export repositoryPrepared states and complete export generations

An exact repository match can satisfy a request before a notebook starts. When one state changes, preparation can reuse matching prepared states and execute the missing state. Preparation and reuse explains the identity and lease model.

Reading and publishing

A reader opens one immutable notebook export. A prepared manifest is a small JSON record that points to one export and selects one exported state. A browser can follow a changing manifest through a prepared publication, preserving the last committed view while a replacement loads.

Opening validates the index. Loading verifies one selected asset. Complete verification checks the full export closure. Mounting a chart, widget, or custom interactive result grants its code the browser page's authority.

The finite boundary

A consumer can resolve input vectors already present in the state-output relation. Another Python-derived input vector requires another preparation run or a live Python service. This makes marimo-export a fit for reports, dashboards, static applications, and agent inputs whose supported states can be declared before consumption.

Continue with Why export notebook states? to evaluate that boundary, or build your first notebook export to run the complete two-state example.

Released under the Apache 2.0 License.