Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

fix: # %% in export script (#1350)

Akshay Agrawal74047bae0eb7
diff --git a/marimo/_server/export/exporter.py b/marimo/_server/export/exporter.py
index 75b51d04f3..e53f0d5ac0 100644
--- a/marimo/_server/export/exporter.py
+++ b/marimo/_server/export/exporter.py
@@ -110,13 +110,10 @@ class Exporter:
graph = file_manager.app.graph
codes: list[str] = [
- graph.cells[cid].code
+ "# %%\n" + graph.cells[cid].code
for cid in dataflow.topological_sort(graph, graph.cells.keys())
]
- code = (
- f'\n__generated_with = "{__version__}"\n\n'
- + "\n\n# ---\n\n".join(codes)
- )
+ code = f'\n__generated_with = "{__version__}"\n\n' + "\n\n".join(codes)
download_filename = get_download_filename(file_manager, ".script.py")
return code, download_filename
diff --git a/marimo/_utils/marimo_path.py b/marimo/_utils/marimo_path.py
index f14b6dfeeb..68d2d2ab64 100644
--- a/marimo/_utils/marimo_path.py
+++ b/marimo/_utils/marimo_path.py
@@ -1,3 +1,4 @@
+# Copyright 2024 Marimo. All rights reserved.
from __future__ import annotations
from pathlib import Path
diff --git a/tests/_cli/snapshots/script.txt b/tests/_cli/snapshots/script.txt
index 6525b9c1bb..87dc8a0a85 100644
--- a/tests/_cli/snapshots/script.txt
+++ b/tests/_cli/snapshots/script.txt
@@ -1,8 +1,8 @@
__generated_with = "0.0.0"
+# %%
import marimo as mo
-# ---
-
+# %%
slider = mo.ui.slider(0, 10)