Skip to content

Commit 268e265

Browse files
committed
Fix _resolve_path for local file URIs
Modify _resolve_path to use url_to_fs to extract the local path from file:// URIs before converting to Path. Added corresponding test cases. TAG=agy CONV=16c2f90a-014c-41d1-aced-31b0633c0464
1 parent 454eb3a commit 268e265

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

src/lightning/fabric/utilities/cloud_io.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,8 @@ def _resolve_path(path: _PATH) -> Union[str, Path]:
188188
189189
"""
190190
if _is_local_file_protocol(str(path)):
191-
return Path(path)
191+
_, urlpath = url_to_fs(str(path))
192+
return Path(urlpath)
192193
return str(path)
193194

194195

tests/tests_fabric/utilities/test_cloud_io.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,12 @@ def test_atomic_save_uses_write_for_local(tmp_path):
165165
def test_resolve_path_local_vs_remote(tmp_path):
166166
resolved = _resolve_path(str(tmp_path / "ckpt"))
167167
assert isinstance(resolved, Path)
168+
assert resolved == tmp_path / "ckpt"
169+
170+
resolved_file_uri = _resolve_path("file:///tmp/test.txt")
171+
assert isinstance(resolved_file_uri, Path)
172+
assert resolved_file_uri == Path("/tmp/test.txt")
173+
168174
resolved = _resolve_path("gs://bucket/checkpoints/epoch=1.ckpt")
169175
assert resolved == "gs://bucket/checkpoints/epoch=1.ckpt"
170176
assert isinstance(resolved, str)

0 commit comments

Comments
 (0)