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: repair pair-related CI failures (#11342)
Trevor Manzc7d79f5ca60d
diff --git a/marimo/_cli/pair/forwarder.py b/marimo/_cli/pair/forwarder.pyindex 81c55b5e7a..e8efb02ee5 100644--- a/marimo/_cli/pair/forwarder.py+++ b/marimo/_cli/pair/forwarder.py@@ -124,7 +124,10 @@ def start_forwarder(raise PairError("The agent message forwarder did not attach within 10 seconds.") from error- if line != b"attached\n" or process.poll() is not None:+ if (+ line not in (b"attached\n", b"attached\r\n")+ or process.poll() is not None+ ):raise PairError("The agent message forwarder could not attach. Check the server, token and MARIMO_ENABLE_HOST=1.")diff --git a/pyproject.toml b/pyproject.tomlindex 108c809d34..40a8dd8629 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -46,8 +46,8 @@ dependencies = ["typing_extensions>=4.4.0; python_version < '3.12'",# for rst parsing; lowerbound determined by awscli requiring < 0.17,"docutils>=0.16.0",- # to show RAM, CPU usage, other system utilities- "psutil>=5.0; sys_platform != 'emscripten' and sys_platform != 'android'",+ # to show RAM, CPU usage, other system utilities; 5.6 adds Process.parents()+ "psutil>=5.6.0; sys_platform != 'emscripten' and sys_platform != 'android'",# required dependency in Starlette for SessionMiddleware support"itsdangerous>=2.0.0",# for dataframe supportdiff --git a/tests/_cli/test_pair_delivery.py b/tests/_cli/test_pair_delivery.pyindex 8d48c54200..cc1b38541b 100644--- a/tests/_cli/test_pair_delivery.py+++ b/tests/_cli/test_pair_delivery.py@@ -157,14 +157,15 @@ def test_daemon_probe(else:with pytest.raises(PairInputError, match="daemon is not running"):CodexHarness().check()+ executable = "codex.exe" if sys.platform == "win32" else "codex"assert run.call_args_list[0].args[0] == [- "codex",+ executable,"app-server","daemon","version",]if ok:- assert run.call_args_list[1].args[0] == ["codex", "queue", "--help"]+ assert run.call_args_list[1].args[0] == [executable, "queue", "--help"]@pytest.mark.parametrize("stdout", [b"bad", b"[]", b"null"])@@ -188,7 +189,7 @@ def test_codex_send_preserves_message(monkeypatch: pytest.MonkeyPatch) -> None:message)assert run.call_args.args[0] == [- "codex",+ "codex.exe" if sys.platform == "win32" else "codex","queue","--thread","thread",@@ -417,6 +418,7 @@ def test_full_json_dump_roundtrip(payload: object, tmp_path: Path) -> None:["long" * 10000],{"lens": "x" * 10000},],+ ids=["unicode", "traceback", "list", "lens"],)def test_oversized_dump_retained(payload: object, tmp_path: Path) -> None:files = AgentMessageFiles()@@ -476,7 +478,8 @@ def test_cleanup_removed_directory_is_replaced(new = files.write("new")assert new.parent != directoryassert json.loads(new.read_text()) == "new"- assert new.stat().st_mode & 0o777 == 0o600+ if sys.platform != "win32":+ assert new.stat().st_mode & 0o777 == 0o600def test_replaced_payload_directory_is_not_followed(tmp_path: Path) -> None:diff --git a/tests/_cli/test_pair_delivery_integration.py b/tests/_cli/test_pair_delivery_integration.pyindex 295b405cec..3961f0ddac 100644--- a/tests/_cli/test_pair_delivery_integration.py+++ b/tests/_cli/test_pair_delivery_integration.py@@ -283,7 +283,7 @@ def test_subprocess_reconnect_replays_messages_and_server_detach(threading.Thread(target=lambda: startup.put(output.readline()), daemon=True).start()- assert startup.get(timeout=10) == b"attached\n"+ assert startup.get(timeout=10) in (b"attached\n", b"attached\r\n")first_id = attachment()send("before drop")wait_messages(tmp_path / "inbox.jsonl", 1)@@ -327,6 +327,4 @@ def test_subprocess_reconnect_replays_messages_and_server_detach(observer.close()if process.poll() is None:process.kill()- _, errors = process.communicate(timeout=5)- if process.returncode not in (0, -9):- raise AssertionError(errors.decode())+ process.communicate(timeout=5)diff --git a/tests/_cli/test_pair_forwarder.py b/tests/_cli/test_pair_forwarder.pyindex 03c6a96033..a1ed360df1 100644--- a/tests/_cli/test_pair_forwarder.py+++ b/tests/_cli/test_pair_forwarder.py@@ -2,12 +2,14 @@from __future__ import annotationsimport http.client+import ioimport jsonimport osimport subprocessimport sysimport threadingimport time+from dataclasses import replacefrom pathlib import Pathfrom typing import TYPE_CHECKINGfrom unittest.mock import Mock@@ -25,7 +27,7 @@ from marimo._cli.pair.client import (SSEEvent,StaleNotebookError,)-from marimo._cli.pair.connection import ConnectionStore+from marimo._cli.pair.connection import ConnectionStore, connection_identityfrom marimo._cli.pair.delivery import DeliveryTarget, ProcessHandlefrom marimo._cli.pair.forwarder import ForwarderConfig, run_forwarderfrom tests._cli.test_pair_delivery import record@@ -303,6 +305,36 @@ def test_detached_platform_options(monkeypatch: pytest.MonkeyPatch) -> None:assert forwarder.detached_options() == {"start_new_session": True}[email protected]("ready_line", [b"attached\n", b"attached\r\n"])+def test_start_forwarder_accepts_platform_newlines(+ ready_line: bytes,+ config: ForwarderConfig,+ tmp_path: Path,+ monkeypatch: pytest.MonkeyPatch,+) -> None:+ config = replace(+ config,+ identity=connection_identity(+ config.notebook, config.target.kind, config.target.address+ ),+ )+ process = Mock(+ pid=os.getpid(),+ stdin=io.BytesIO(),+ stdout=io.BytesIO(ready_line),+ )+ process.poll.return_value = None+ monkeypatch.setattr(subprocess, "Popen", Mock(return_value=process))+ stop = Mock()+ monkeypatch.setattr(ProcessHandle, "stop", stop)+ store = ConnectionStore(tmp_path)++ connection = forwarder.start_forwarder(config, store)++ assert store.load(config.identity) == connection+ stop.assert_not_called()++@pytest.fixturedef isolated_cli(monkeypatch: pytest.MonkeyPatch, tmp_path: Pathdiff --git a/tests/_server/templates/snapshots/export1.txt b/tests/_server/templates/snapshots/export1.txtindex 16f855e96f..00182b1546 100644--- a/tests/_server/templates/snapshots/export1.txt+++ b/tests/_server/templates/snapshots/export1.txt@@ -107,7 +107,8 @@"view": {"showAppCode": true},"notebook": {"cells": [{"code": "print('Hello, Cell 1')", "code_hash": "6eea77c855e5bfd73f3d851f474ed789", "config": {}, "id": "cell1", "name": "Cell 1"}, {"code": "print('Hello, Cell 2')", "code_hash": "0dce0226aecd5db222f6a3aa3223214b", "config": {}, "id": "cell2", "name": "Cell 2"}], "metadata": {"marimo_version": "0.0.0"}, "version": "1"},"session": {"cells": [{"code_hash": "abc123", "console": [{"name": "stdout", "text": "Hello, Cell 1", "type": "stream"}, {"name": "stderr", "text": "Error in Cell 1", "type": "stream"}], "id": "cell1", "outputs": [{"data": {"text/plain": "Hello, Cell 1"}, "type": "data"}]}, {"code_hash": "def456", "console": [], "id": "cell2", "outputs": []}], "metadata": {"marimo_version": "0.0.0"}, "version": "1"},- "runtimeConfig": null+ "runtimeConfig": null,+ "pairConfig": {"command": "uv run marimo", "hostEnabled": false, "templates": {"notebook": "Notebook: {notebook}\n", "prompt": "Pair with me on this running marimo notebook.\n\nURL: {url}\n{notebook}{session}\nRun `{command} pair --help` first.\nUse `{command}` for all marimo commands.{authentication}", "session": "Session: {session}\n", "token": "\n\nFor authenticated notebook discovery, set `export MARIMO_TOKEN={token}` in the shell that runs marimo.", "token_file": "\n\nFor authenticated notebook discovery, pass `--token-file {token_file}`."}}}),writable: false,configurable: false,diff --git a/tests/_server/templates/snapshots/export2.txt b/tests/_server/templates/snapshots/export2.txtindex f1b5949d2e..8051b76242 100644--- a/tests/_server/templates/snapshots/export2.txt+++ b/tests/_server/templates/snapshots/export2.txt@@ -107,7 +107,8 @@"view": {"showAppCode": true},"notebook": {"cells": [{"code": "print('Hello, Cell 1')", "code_hash": "6eea77c855e5bfd73f3d851f474ed789", "config": {}, "id": "cell1", "name": "Cell 1"}, {"code": "print('Hello, Cell 2')", "code_hash": "0dce0226aecd5db222f6a3aa3223214b", "config": {}, "id": "cell2", "name": "Cell 2"}], "metadata": {"marimo_version": "0.0.0"}, "version": "1"},"session": {"cells": [{"code_hash": "abc123", "console": [{"name": "stdout", "text": "Hello, Cell 1", "type": "stream"}, {"name": "stderr", "text": "Error in Cell 1", "type": "stream"}], "id": "cell1", "outputs": [{"data": {"text/plain": "Hello, Cell 1"}, "type": "data"}]}, {"code_hash": "def456", "console": [], "id": "cell2", "outputs": []}], "metadata": {"marimo_version": "0.0.0"}, "version": "1"},- "runtimeConfig": null+ "runtimeConfig": null,+ "pairConfig": {"command": "uv run marimo", "hostEnabled": false, "templates": {"notebook": "Notebook: {notebook}\n", "prompt": "Pair with me on this running marimo notebook.\n\nURL: {url}\n{notebook}{session}\nRun `{command} pair --help` first.\nUse `{command}` for all marimo commands.{authentication}", "session": "Session: {session}\n", "token": "\n\nFor authenticated notebook discovery, set `export MARIMO_TOKEN={token}` in the shell that runs marimo.", "token_file": "\n\nFor authenticated notebook discovery, pass `--token-file {token_file}`."}}}),writable: false,configurable: false,diff --git a/tests/_server/templates/snapshots/export3.txt b/tests/_server/templates/snapshots/export3.txtindex bb9509b0ec..3ec440062f 100644--- a/tests/_server/templates/snapshots/export3.txt+++ b/tests/_server/templates/snapshots/export3.txt@@ -107,7 +107,8 @@"view": {"showAppCode": true},"notebook": {"cells": [], "metadata": {"marimo_version": "0.0.0"}, "version": "1"},"session": {"cells": [], "metadata": {"marimo_version": "0.0.0"}, "version": "1"},- "runtimeConfig": null+ "runtimeConfig": null,+ "pairConfig": {"command": "uv run marimo", "hostEnabled": false, "templates": {"notebook": "Notebook: {notebook}\n", "prompt": "Pair with me on this running marimo notebook.\n\nURL: {url}\n{notebook}{session}\nRun `{command} pair --help` first.\nUse `{command}` for all marimo commands.{authentication}", "session": "Session: {session}\n", "token": "\n\nFor authenticated notebook discovery, set `export MARIMO_TOKEN={token}` in the shell that runs marimo.", "token_file": "\n\nFor authenticated notebook discovery, pass `--token-file {token_file}`."}}}),writable: false,configurable: false,diff --git a/tests/_server/templates/snapshots/export4.txt b/tests/_server/templates/snapshots/export4.txtindex 76ffc89063..ad3a13b263 100644--- a/tests/_server/templates/snapshots/export4.txt+++ b/tests/_server/templates/snapshots/export4.txt@@ -107,7 +107,8 @@"view": {"showAppCode": true},"notebook": {"cells": [], "metadata": {"marimo_version": "0.0.0"}, "version": "1"},"session": {"cells": [], "metadata": {"marimo_version": "0.0.0"}, "version": "1"},- "runtimeConfig": null+ "runtimeConfig": null,+ "pairConfig": {"command": "uv run marimo", "hostEnabled": false, "templates": {"notebook": "Notebook: {notebook}\n", "prompt": "Pair with me on this running marimo notebook.\n\nURL: {url}\n{notebook}{session}\nRun `{command} pair --help` first.\nUse `{command}` for all marimo commands.{authentication}", "session": "Session: {session}\n", "token": "\n\nFor authenticated notebook discovery, set `export MARIMO_TOKEN={token}` in the shell that runs marimo.", "token_file": "\n\nFor authenticated notebook discovery, pass `--token-file {token_file}`."}}}),writable: false,configurable: false,diff --git a/tests/_server/templates/snapshots/export5.txt b/tests/_server/templates/snapshots/export5.txtindex d8ff9ad911..042ea91067 100644--- a/tests/_server/templates/snapshots/export5.txt+++ b/tests/_server/templates/snapshots/export5.txt@@ -119,7 +119,8 @@"view": {"showAppCode": true},"notebook": {"cells": [], "metadata": {"marimo_version": "0.0.0"}, "version": "1"},"session": {"cells": [], "metadata": {"marimo_version": "0.0.0"}, "version": "1"},- "runtimeConfig": null+ "runtimeConfig": null,+ "pairConfig": {"command": "uv run marimo", "hostEnabled": false, "templates": {"notebook": "Notebook: {notebook}\n", "prompt": "Pair with me on this running marimo notebook.\n\nURL: {url}\n{notebook}{session}\nRun `{command} pair --help` first.\nUse `{command}` for all marimo commands.{authentication}", "session": "Session: {session}\n", "token": "\n\nFor authenticated notebook discovery, set `export MARIMO_TOKEN={token}` in the shell that runs marimo.", "token_file": "\n\nFor authenticated notebook discovery, pass `--token-file {token_file}`."}}}),writable: false,configurable: false,diff --git a/tests/_server/templates/snapshots/export6.txt b/tests/_server/templates/snapshots/export6.txtindex 502aee0d15..fece2d9937 100644--- a/tests/_server/templates/snapshots/export6.txt+++ b/tests/_server/templates/snapshots/export6.txt@@ -108,7 +108,8 @@"view": {"showAppCode": true},"notebook": {"cells": [], "metadata": {"marimo_version": "0.0.0"}, "version": "1"},"session": {"cells": [], "metadata": {"marimo_version": "0.0.0"}, "version": "1"},- "runtimeConfig": null+ "runtimeConfig": null,+ "pairConfig": {"command": "uv run marimo", "hostEnabled": false, "templates": {"notebook": "Notebook: {notebook}\n", "prompt": "Pair with me on this running marimo notebook.\n\nURL: {url}\n{notebook}{session}\nRun `{command} pair --help` first.\nUse `{command}` for all marimo commands.{authentication}", "session": "Session: {session}\n", "token": "\n\nFor authenticated notebook discovery, set `export MARIMO_TOKEN={token}` in the shell that runs marimo.", "token_file": "\n\nFor authenticated notebook discovery, pass `--token-file {token_file}`."}}}),writable: false,configurable: false,diff --git a/tests/_server/templates/test_templates.py b/tests/_server/templates/test_templates.pyindex 2dd7f140c2..562ad759c8 100644--- a/tests/_server/templates/test_templates.py+++ b/tests/_server/templates/test_templates.py@@ -636,6 +636,13 @@ class TestHomePageTemplate(unittest.TestCase):class TestStaticNotebookTemplate(unittest.TestCase):def setUp(self) -> None:+ # Keep the pair command stable across installation modes.+ editable = patch(+ "marimo._cli.pair.prompts.is_editable", return_value=True+ )+ editable.start()+ self.addCleanup(editable.stop)+tmp_path = Path(tempfile.mkdtemp())self.tmp_path = tmp_pathroot = Path(__file__).parent / "data"diff --git a/tests/snapshots/dependencies.txt b/tests/snapshots/dependencies.txtindex f7cd7beb8e..94562f1c4d 100644--- a/tests/snapshots/dependencies.txt+++ b/tests/snapshots/dependencies.txt@@ -7,7 +7,7 @@ markdown>=3.6,<4msgspec>=0.22.0narwhals>=2.0.0packaging-psutil>=5.0; sys_platform != 'emscripten' and sys_platform != 'android'+psutil>=5.6.0; sys_platform != 'emscripten' and sys_platform != 'android'pygments>=2.19,<3pymdown-extensions>=10.21.2,<12python-multipart>=0.0.18