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: disable pdb patch in marimo run (#932)
Akshay Agrawalc53396d68a06
diff --git a/marimo/_pyodide/pyodide_session.py b/marimo/_pyodide/pyodide_session.pyindex 2926220b17..6aaec97601 100644--- a/marimo/_pyodide/pyodide_session.py+++ b/marimo/_pyodide/pyodide_session.py@@ -20,6 +20,7 @@ from marimo._pyodide.streams import (from marimo._runtime import handlers, requestsfrom marimo._runtime.context import initialize_contextfrom marimo._runtime.input_override import input_override+from marimo._runtime.marimo_pdb import MarimoPdbfrom marimo._runtime.requests import (AppMetadata,CompletionRequest,@@ -302,6 +303,7 @@ def launch_pyodide_kernel(stdout = PyodideStdout(stream)stderr = PyodideStderr(stream)stdin = PyodideStdin(stream) if is_edit_mode else None+ debugger = MarimoPdb(stdout=stdout, stdin=stdin) if is_edit_mode else Nonekernel = Kernel(cell_configs=configs,@@ -311,6 +313,7 @@ def launch_pyodide_kernel(stderr=stderr,stdin=stdin,input_override=input_override,+ debugger_override=debugger,)initialize_context(kernel=kernel,diff --git a/marimo/_runtime/cell_runner.py b/marimo/_runtime/cell_runner.pyindex 7e070fb93c..541b3399c5 100644--- a/marimo/_runtime/cell_runner.py+++ b/marimo/_runtime/cell_runner.py@@ -48,7 +48,7 @@ class Runner:cell_ids: set[CellId_t],graph: dataflow.DirectedGraph,glbls: dict[Any, Any],- debugger: MarimoPdb,+ debugger: MarimoPdb | None,):self.graph = graphself.debugger = debugger@@ -257,7 +257,8 @@ class Runner:# Bdb defines the botframe attribute and sets it to non-None# when it starts upif (- hasattr(self.debugger, "botframe")+ self.debugger is not None+ and hasattr(self.debugger, "botframe")and self.debugger.botframe is not None):self.debugger.set_continue()diff --git a/marimo/_runtime/runtime.py b/marimo/_runtime/runtime.pyindex ecb380ad04..c7156bf7e4 100644--- a/marimo/_runtime/runtime.py+++ b/marimo/_runtime/runtime.py@@ -188,6 +188,7 @@ class Kernel:- stderr: replacement for sys.stderr- stdin: replacement for sys.stdin- input_override: a function that overrides the builtin input() function+ - debugger_override: a replacement for the built-in Pdb"""def __init__(@@ -199,16 +200,18 @@ class Kernel:stderr: Stderr | None,stdin: Stdin | None,input_override: Callable[[Any], str] = input_override,+ debugger_override: marimo_pdb.MarimoPdb | None = None,) -> None:self.app_metadata = app_metadataself.stream = streamself.stdout = stdoutself.stderr = stderrself.stdin = stdin- self.debugger = marimo_pdb.MarimoPdb(- stdout=self.stdout, stdin=self.stdin- )- patches.patch_pdb(self.debugger)++ self.debugger = debugger_override+ if self.debugger is not None:+ patches.patch_pdb(self.debugger)+self._module = patches.patch_main_module(file=self.app_metadata.filename, input_override=input_override)@@ -1178,6 +1181,11 @@ def launch_kernel(# TODO(akshayka): stdin in run mode? input(prompt) uses stdout, which# isn't currently available in run mode.stdin = ThreadSafeStdin(stream) if is_edit_mode else None+ debugger = (+ marimo_pdb.MarimoPdb(stdout=stdout, stdin=stdin)+ if is_edit_mode+ else None+ )kernel = Kernel(cell_configs=configs,@@ -1187,6 +1195,7 @@ def launch_kernel(stderr=stderr,stdin=stdin,input_override=input_override,+ debugger_override=debugger,)initialize_context(kernel=kernel,diff --git a/tests/conftest.py b/tests/conftest.pyindex 150b7c7d58..b0cb535b52 100644--- a/tests/conftest.py+++ b/tests/conftest.py@@ -17,6 +17,7 @@ from marimo._messaging.streams import (ThreadSafeStream,)from marimo._runtime.context import initialize_context, teardown_context+from marimo._runtime.marimo_pdb import MarimoPdbfrom marimo._runtime.requests import AppMetadata, ExecutionRequestfrom marimo._runtime.runtime import Kernel@@ -91,6 +92,7 @@ class MockedKernel:app_metadata=AppMetadata(filename=None,),+ debugger_override=MarimoPdb(stdout=self.stdout, stdin=self.stdin),)initialize_context(