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: skip normalization for cloudpath (#7904)
Myles Scolnick4b43c0a0a4ca
diff --git a/marimo/_utils/paths.py b/marimo/_utils/paths.pyindex d98a27041c..136c3f5b20 100644--- a/marimo/_utils/paths.py+++ b/marimo/_utils/paths.py@@ -58,6 +58,8 @@ def normalize_path(path: Path) -> Path:- Converts relative paths to absolute paths- Normalizes .. and . components- Does NOT resolve symlinks (unlike Path.resolve())+ - Skips normalization for cloud paths (e.g., S3Path, GCSPath, AzurePath)+ to avoid corrupting URI schemes like s3://Args:path: The path to normalize@@ -69,6 +71,11 @@ def normalize_path(path: Path) -> Path:>>> normalize_path(Path("foo/../bar"))Path("/current/working/dir/bar")"""+ # Skip normalization for cloud paths (e.g., S3Path, GCSPath, AzurePath)+ # os.path.normpath corrupts URI schemes like s3:// by reducing them to s3:/+ if path.__class__.__module__.startswith("cloudpathlib"):+ return path+# Make absolute if relative (relative to current working directory)if not path.is_absolute():path = Path.cwd() / pathdiff --git a/pixi.lock b/pixi.lockindex ff53d9429f..25740b47de 100644--- a/pixi.lock+++ b/pixi.lock@@ -1133,7 +1133,7 @@ packages:- pypi: ./name: marimoversion: 0.19.4- sha256: 33d1fdf0428c4fa081a538af862209731fd8e27af5ac43041d232d6918ede2e4+ sha256: b8269f90d1490e837a501cbe0ef11c21a96842e7b52ad2430d0a5a9122bde661requires_dist:- click>=8.0,<9- jedi>=0.18.0diff --git a/pyproject.toml b/pyproject.tomlindex 039a0b8295..45fc26cd99 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -170,6 +170,7 @@ test-optional = ["sqlglot[rs]>=26.2.0","sqlalchemy>=2.0.40","pyiceberg>=0.9.0",+ "cloudpathlib>=0.23.0",# For testing clickhouse"chdb>=3; platform_system != 'Windows'", # there is no suitable wheel for windows"clickhouse-connect>=0.8.18",diff --git a/tests/_utils/test_paths.py b/tests/_utils/test_paths.pyindex 046c8004b4..b49b37b2ca 100644--- a/tests/_utils/test_paths.py+++ b/tests/_utils/test_paths.py@@ -82,6 +82,38 @@ def test_normalize_path_does_not_resolve_symlinks() -> None:assert normalized != resolved+def test_normalize_path_skips_cloudpathlib_paths() -> None:+ """Test that cloud paths from cloudpathlib are returned unchanged.++ os.path.normpath corrupts URI schemes like s3:// by reducing them to s3:/+ This test verifies that cloudpathlib paths bypass normalization.+ """+ from unittest.mock import MagicMock++ # Create a mock cloud path that simulates cloudpathlib.S3Path+ # We can't inherit from PurePosixPath because it normalizes on construction+ mock_path = MagicMock()+ mock_path.__class__.__module__ = "cloudpathlib.s3.s3path"++ # normalize_path should return the path unchanged+ result = normalize_path(mock_path)++ # Should be the exact same object, returned unchanged+ assert result is mock_path+++def test_normalize_path_does_not_skip_regular_paths() -> None:+ """Test that regular Path objects are still normalized properly."""+ # Ensure the cloudpathlib check doesn't affect regular paths+ relative_path = Path("foo") / "bar"+ result = normalize_path(relative_path)++ # Should be converted to absolute+ assert result.is_absolute()+ # Module should be pathlib, not cloudpathlib+ assert result.__class__.__module__.startswith("pathlib")++class TestPrettyPath:"""Tests for pretty_path function."""