From 721fdfa32dd7af640d980e744ca0f43d73b3baa7 Mon Sep 17 00:00:00 2001 From: Ankita George Date: Tue, 6 May 2025 01:02:09 +0000 Subject: [PATCH] [ez] Fsspec Filesystem ls details should be false (#152693) Summary: The default action for ls for the local filesystem is with details=False, but this isn't the case for all filesystems (eg. huggingface), so setting details=False explicitly so that the return type of ls is a list of strings, and not a list of dictionaries, which is what it would be with details=True. Test Plan: tested in notebook Differential Revision: D74080572 Pull Request resolved: https://github.com/pytorch/pytorch/pull/152693 Approved by: https://github.com/joecummings --- torch/distributed/checkpoint/_fsspec_filesystem.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/torch/distributed/checkpoint/_fsspec_filesystem.py b/torch/distributed/checkpoint/_fsspec_filesystem.py index 3bd508f4c2c9..ef8f5823fdb2 100644 --- a/torch/distributed/checkpoint/_fsspec_filesystem.py +++ b/torch/distributed/checkpoint/_fsspec_filesystem.py @@ -92,7 +92,9 @@ class FileSystem(FileSystemBase): self.fs.rm(path) def ls(self, path: Union[str, os.PathLike]) -> list[str]: - return self.fs.ls(path) + # setting detail to False explictly to keep the list[str] return type, + # instead of the list[Dict] return type when detail=True + return self.fs.ls(path, detail=False) # TODO: add the dcp.async_save mixin