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
Set status to idle after formatters run, not before (#1868)
Akshay Agrawal7b639049cddf
diff --git a/marimo/_runtime/runner/hooks_post_execution.py b/marimo/_runtime/runner/hooks_post_execution.pyindex 2aef14b8b0..c6eaa346b8 100644--- a/marimo/_runtime/runner/hooks_post_execution.py+++ b/marimo/_runtime/runner/hooks_post_execution.py@@ -170,6 +170,7 @@ def _broadcast_outputs(formatted_output = format_output()else:formatted_output = format_output()+CellOp.broadcast_output(channel=CellChannel.OUTPUT,mimetype=formatted_output.mimetype,@@ -237,11 +238,14 @@ def _reset_matplotlib_context(POST_EXECUTION_HOOKS: list[PostExecutionHookType] = [- _set_status_idle,_store_reference_to_output,_broadcast_variables,_broadcast_datasets,_broadcast_duckdb_tables,_broadcast_outputs,_reset_matplotlib_context,+ # set status to idle after all post-processing is done, in case the+ # other hooks take a long time (broadcast outputs can take a long time+ # if a formatter is slow).+ _set_status_idle,]diff --git a/tests/_runtime/test_runtime.py b/tests/_runtime/test_runtime.pyindex b743479c41..f169d63e45 100644--- a/tests/_runtime/test_runtime.py+++ b/tests/_runtime/test_runtime.py@@ -881,11 +881,11 @@ class TestExecution:assert all(m[1]["cell_id"] == SCRATCH_CELL_ID for m in messages)assert m1[1]["status"] == "queued"assert m2[1]["status"] == "running"- assert m3[1]["status"] == "idle"- assert m4[1]["status"] is None+ assert m3[1]["status"] is Noneassert (- m4[1]["output"]["data"] == "<pre style='font-size: 12px'>1</pre>"+ m3[1]["output"]["data"] == "<pre style='font-size: 12px'>1</pre>")+ assert m4[1]["status"] == "idle"# Does not pollute globalsassert "x" not in k.globals@@ -908,9 +908,9 @@ class TestExecution:# Has no errorsassert not k.errorsmessages = mocked_kernel.stream.messages- last_message = messages[-1]+ output_message = messages[-2]assert (- last_message[1]["output"]["data"]+ output_message[1]["output"]["data"]== "<pre style='font-size: 12px'>20</pre>")assert "z" in k.globals@@ -936,9 +936,9 @@ class TestExecution:# Has no errorsassert not k.errorsmessages = mocked_kernel.stream.messages- last_message = messages[-1]+ output_message = messages[-2]assert (- last_message[1]["output"]["data"]+ output_message[1]["output"]["data"]== "<pre style='font-size: 12px'>20</pre>")assert "z" in k.globals