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: flush empty outputs (#364)
Akshay Agrawal8cb60c4cf999
diff --git a/marimo/_runtime/output/_output.py b/marimo/_runtime/output/_output.pyindex c2d44beb55..c5a62933a1 100644--- a/marimo/_runtime/output/_output.py+++ b/marimo/_runtime/output/_output.py@@ -81,10 +81,10 @@ def flush() -> None:returnif ctx.kernel.execution_context.output is not None:- write_internal(- cell_id=ctx.kernel.execution_context.cell_id,- value=vstack(ctx.kernel.execution_context.output),- )+ value = vstack(ctx.kernel.execution_context.output)+ else:+ value = None+ write_internal(cell_id=ctx.kernel.execution_context.cell_id, value=value)def remove(value: object) -> None:diff --git a/marimo/_runtime/output/test_output.py b/marimo/_runtime/output/test_output.pynew file mode 100644index 0000000000..644b54f8f2--- /dev/null+++ b/marimo/_runtime/output/test_output.py@@ -0,0 +1,37 @@+# Copyright 2023 Marimo. All rights reserved.+from __future__ import annotations++from marimo._runtime.conftest import ExecReqProvider, MockedKernel+++def test_spinner_removed(+ mocked_kernel: MockedKernel, exec_req: ExecReqProvider+) -> None:+ mocked_kernel.k.run(+ [+ exec_req.get(+ """+ import marimo as mo++ with mo.status.spinner():+ ...+ 123+ """+ )+ ]+ )+ found_progress = False+ for i, msg in enumerate(mocked_kernel.stream.messages):+ if (+ msg[0] == "cell-op"+ and msg[1]["output"] is not None+ and "marimo-progress" in msg[1]["output"]["data"]+ ):+ # the spinner should be cleared immediately after the context+ # manager exits+ found_progress = True+ # kernel uses text/plain + empty string to denote empty output+ assert (+ mocked_kernel.stream.messages[i + 1][1]["output"]["data"] == ""+ )+ assert found_progress