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.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
fix: ignore mo.stop() 'errors' in marimo export (#3099)
Myles Scolnickbbfa77783372
diff --git a/marimo/_server/export/__init__.py b/marimo/_server/export/__init__.pyindex ed17bdeba2..eeb426d467 100644--- a/marimo/_server/export/__init__.py+++ b/marimo/_server/export/__init__.py@@ -196,11 +196,16 @@ async def run_app_until_completion(for err in errors:parsed = parse_raw({"error": err}, Container)- echo(- f"{parsed.error.__class__.__name__}: {parsed.error.describe()}",- file=sys.stderr,- )- self.did_error = True+ # Not all errors are fatal+ if parsed.error.type not in [+ "ancestor-prevented",+ "ancestor-stopped",+ ]:+ echo(+ f"{parsed.error.__class__.__name__}: {parsed.error.describe()}",+ file=sys.stderr,+ )+ self.did_error = Trueif message[0] == "completed-run":instantiated_event.set()diff --git a/tests/_server/export/snapshots/run_until_completion_with_stop.txt b/tests/_server/export/snapshots/run_until_completion_with_stop.txtnew file mode 100644index 0000000000..ab296d9de4--- /dev/null+++ b/tests/_server/export/snapshots/run_until_completion_with_stop.txt@@ -0,0 +1 @@+["", "", [{"msg": "This cell wasn't run because an ancestor was stopped with `mo.stop`: ", "raising_cell": "MJUe", "type": "ancestor-stopped"}]]\ No newline at end of filediff --git a/tests/_server/export/test_exporter.py b/tests/_server/export/test_exporter.pyindex b8c0f8c59c..0ace132020 100644--- a/tests/_server/export/test_exporter.py+++ b/tests/_server/export/test_exporter.py@@ -1,9 +1,12 @@from __future__ import annotations+import json+import pytestfrom marimo._ast.app import App, InternalAppfrom marimo._dependencies.dependencies import DependencyManager+from marimo._messaging.ops import CellOpfrom marimo._output.hypertext import patch_html_for_non_interactive_outputfrom marimo._server.export import run_app_until_completionfrom marimo._server.export.exporter import Exporter@@ -220,3 +223,39 @@ async def test_export_ipynb_with_outputs():assert not did_errorassert filename == "notebook.ipynb"snapshot("notebook_with_outputs.ipynb.txt", content)+++async def test_run_until_completion_with_stop():+ app = App()++ @app.cell()+ def cell_1():+ import marimo as mo++ return (mo,)++ @app.cell()+ def cell_2(mo):+ mo.stop(True)+ x = 10+ return (x,)++ @app.cell()+ def cell_3(x):+ y = x + 1+ y+ return (y,)++ file_manager = AppFileManager.from_app(InternalApp(app))++ session_view, did_error = await run_app_until_completion(+ file_manager, cli_args={}+ )+ assert did_error is False+ output_data = [+ op for op in session_view.operations if isinstance(op, CellOp)+ ]+ serialized_out = json.dumps(+ [op.output.data for op in output_data if op.output is not None]+ )+ snapshot("run_until_completion_with_stop.txt", serialized_out)