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: set config before registering cell (#126)
Akshay Agrawal6f98966e2ab6
diff --git a/marimo/_runtime/runtime.py b/marimo/_runtime/runtime.pyindex 46c4bf952f..9083f8900c 100644--- a/marimo/_runtime/runtime.py+++ b/marimo/_runtime/runtime.py@@ -14,7 +14,6 @@ import threadingimport timeimport tracebackfrom collections.abc import Iterable, Sequence-from queue import Empty as QueueEmptyfrom typing import Any, Iterator, Optionalfrom marimo import _loggers@@ -737,6 +736,10 @@ class Kernel:# Stale cells that are enabled will need to be run.cells_to_run: set[CellId_t] = set()for cell_id, config in request.configs.items():+ # store the config, regardless of whether we've seen the cell yet+ self.cell_metadata[cell_id] = CellMetadata(+ config=CellConfig.from_dict(config)+ )cell = self.graph.cells.get(cell_id)if cell is None:continue@@ -749,10 +752,6 @@ class Kernel:for cid in self.graph.disable_cell(cell_id):write_disabled_transitively(cid)- # store the config, regardless of whether we've seen the cell yet- self.cell_metadata[cell_id] = CellMetadata(- config=CellConfig.from_dict(config)- )if cells_to_run:self._run_cells(dataflow.transitive_closure(self.graph, cells_to_run)@@ -925,17 +924,11 @@ def launch_kernel(register_formatters()def interrupt_handler(signum: int, frame: Any) -> None:- """Clears the execution queue and tries to interrupt the kernel."""+ """Tries to interrupt the kernel."""del signumdel frameLOGGER.debug("interrupt request received")- while not execution_queue.empty():- try:- execution_queue.get_nowait()- except QueueEmpty:- break-# TODO(akshayka): if kernel is in `run` but not executing,# it won't be interrupted, which isn't right ... but the# probability of that happening is low.diff --git a/marimo/_runtime/test_runtime.py b/marimo/_runtime/test_runtime.pyindex 9e876fcd4a..ac28260a02 100644--- a/marimo/_runtime/test_runtime.py+++ b/marimo/_runtime/test_runtime.py@@ -573,3 +573,13 @@ def test_enable_cycle_incremental()assert not k.graph.cells[er_1.cell_id].config.disabledassert k.graph.cells[er_2.cell_id].status == "idle"+++def test_set_config_before_registering_cell(+ k: Kernel, exec_req: ExecReqProvider+) -> None:+ er_1 = exec_req.get("x = 0")+ k.set_cell_config(SetCellConfigRequest({er_1.cell_id: {"disabled": True}}))+ k.run([er_1])+ assert k.graph.cells[er_1.cell_id].config.disabled+ assert "x" not in k.globals