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
don't override auto-save by when in --watch mode (#6535)
Myles Scolnick36549d62ed1c
diff --git a/marimo/_config/manager.py b/marimo/_config/manager.pyindex 87fa9bd115..4c03525a32 100644--- a/marimo/_config/manager.py+++ b/marimo/_config/manager.py@@ -107,6 +107,10 @@ class MarimoConfigReader:return self._config["language_servers"]return {}+ @property+ def is_auto_save_enabled(self) -> bool:+ return self._config["save"]["autosave"] == "after_delay"+@propertydef experimental(self) -> ExperimentalConfigType:if "experimental" in self._config:diff --git a/marimo/_server/start.py b/marimo/_server/start.pyindex d8dc807f08..6bd169b361 100644--- a/marimo/_server/start.py+++ b/marimo/_server/start.py@@ -196,19 +196,8 @@ def start(min_port=DEFAULT_PORT + 400,)- # If watch is true, disable auto-save and format-on-save,- # watch is enabled when they are editing in another editor- if watch:- config_reader = config_reader.with_overrides(- {- "save": {- "autosave": "off",- "format_on_save": False,- "autosave_delay": 1000,- }- }- )- LOGGER.info("Watch mode enabled, auto-save is disabled")+ if watch and config_reader.is_auto_save_enabled:+ LOGGER.warning("Enabling watch mode may interfere with auto-save.")if GLOBAL_SETTINGS.MANAGE_SCRIPT_METADATA:config_reader = config_reader.with_overrides(diff --git a/tests/_server/test_sessions.py b/tests/_server/test_sessions.pyindex 1da8296618..93b1a24b44 100644--- a/tests/_server/test_sessions.py+++ b/tests/_server/test_sessions.py@@ -604,23 +604,14 @@ def __():@save_and_restore_main-def test_watch_mode_config_override(tmp_path: Path) -> None:- """Test that watch mode properly overrides config settings."""+def test_watch_mode_does_not_override_config(tmp_path: Path) -> None:+ """Test that watch mode does not override config settings."""# Create a temporary filetmp_file = tmp_path / "test_watch_mode_config_override.py"tmp_file.write_text("import marimo as mo")- # Create a config with autosave enabled+ # Create a default config (autosave enabled by default)config_reader = get_default_config_manager(current_path=None)- config_reader_watch = config_reader.with_overrides(- {- "save": {- "autosave": "off",- "format_on_save": False,- "autosave_delay": 2000,- }- }- )# Create a session manager with watch mode enabledfile_router = AppFileRouter.from_filename(MarimoPath(str(tmp_file)))@@ -631,7 +622,7 @@ def test_watch_mode_config_override(tmp_path: Path) -> None:quiet=True,include_code=True,lsp_server=MagicMock(),- config_manager=config_reader_watch,+ config_manager=config_reader,cli_args={},argv=None,auth_token=None,@@ -657,13 +648,8 @@ def test_watch_mode_config_override(tmp_path: Path) -> None:)try:- # Verify that the config was overridden+ # Verify that the config was not overridden for watch modeconfig = session_manager._config_manager.get_config()- assert config["save"]["autosave"] == "off"- assert config["save"]["format_on_save"] is False-- # Verify that the config was not overridden- config = session_manager_no_watch._config_manager.get_config()assert config["save"]["autosave"] == "after_delay"assert config["save"]["format_on_save"] is True