Skip to content

Commit f6207ea

Browse files
author
Luca Moschella
committed
Add fsspec storage options
1 parent ccc83e7 commit f6207ea

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

pytorch_lightning/utilities/cloud_io.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,23 @@ def load(
2727
map_location: Optional[
2828
Union[str, Callable, torch.device, Dict[Union[str, torch.device], Union[str, torch.device]]]
2929
] = None,
30+
**storage_options
3031
) -> Any:
3132
if not isinstance(path_or_url, (str, Path)):
3233
# any sort of BytesIO or similiar
3334
return torch.load(path_or_url, map_location=map_location)
3435
if str(path_or_url).startswith("http"):
3536
return torch.hub.load_state_dict_from_url(str(path_or_url), map_location=map_location)
36-
fs = get_filesystem(path_or_url)
37+
fs = get_filesystem(path_or_url, **storage_options)
3738
with fs.open(path_or_url, "rb") as f:
3839
return torch.load(f, map_location=map_location)
3940

4041

41-
def get_filesystem(path: Union[str, Path]) -> AbstractFileSystem:
42+
def get_filesystem(path: Union[str, Path], **storage_options) -> AbstractFileSystem:
4243
path = str(path)
4344
if "://" in path:
4445
# use the fileystem from the protocol specified
45-
return fsspec.filesystem(path.split(":", 1)[0])
46+
return fsspec.filesystem(path.split(":", 1)[0], **storage_options)
4647
# use local filesystem
4748
return LocalFileSystem()
4849

0 commit comments

Comments
 (0)