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(tests): loosen dataframe preview memory threshold for macOS CI (#10506)
Shahmir Varqhaff71408f3e56
diff --git a/tests/_messaging/test_variables.py b/tests/_messaging/test_variables.pyindex 88c975b700..ef42c775cb 100644--- a/tests/_messaging/test_variables.py+++ b/tests/_messaging/test_variables.py@@ -1,7 +1,9 @@from __future__ import annotations+import gcimport osfrom typing import Any+from unittest.mock import MagicMock, patchimport pytest@@ -218,22 +220,41 @@ def test_get_variable_preview_bytesarray() -> None:create_dataframes({"A": list(range(1000000)), "B": ["x"] * 1000000}),)def test_get_variable_preview_dataframe(df: Any) -> None:+ from marimo._plugins.ui._impl.tables.narwhals_table import (+ NarwhalsTableManager,+ )++ with patch.object(+ NarwhalsTableManager, "as_frame", MagicMock()+ ) as mock_as_frame:+ preview = get_variable_preview(df)+ mock_as_frame.assert_not_called()+ assert "2 columns" in preview++ # RSS guard is pandas-only: Python ints are large enough to detect copies+ # above macOS arm64 allocator noise (~18MB).+ if not DependencyManager.pandas.has():+ return++ import pandas as pd++ if not isinstance(df, pd.DataFrame):+ return+import psutilprocess = psutil.Process(os.getpid())+ gc.collect()mem_before = process.memory_info().rss- preview = get_variable_preview(df)+ get_variable_preview(df)mem_after = process.memory_info().rssmem_diff_mb = (mem_after - mem_before) / (1024 * 1024)- # Threshold is well under copying the 1M-row frame but loose enough to- # absorb allocator noise on macOS arm64 runners.- assert mem_diff_mb < 15, (+ assert mem_diff_mb < 25, (f"Memory increased by {mem_diff_mb}MB during preview")- assert "2 columns" in previewclass TestStringifyVariableValue: