Skip to content

Commit 5201360

Browse files
authored
fix: forward storage_options as kwargs in CloudParquetDir (#836)
Signed-off-by: Sai Asish Y <say.apm35@gmail.com>
1 parent 82a9c3c commit 5201360

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

src/litdata/utilities/parquet.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ def __init__(
150150
for provider in _CLOUD_PROVIDER:
151151
if self.dir.url.startswith(provider):
152152
# Initialize the cloud filesystem
153-
self.fs = fsspec.filesystem(provider, *self.storage_options)
153+
self.fs = fsspec.filesystem(provider, **self.storage_options)
154154
print(f"using provider: {provider}")
155155
break
156156

tests/streaming/test_parquet.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,20 @@ def test_get_parquet_indexer_cls(pq_url, tmp_path, cls, expectation, monkeypatch
129129
assert isinstance(indexer_obj, cls)
130130

131131

132+
@pytest.mark.skipif(condition=sys.platform == "win32", reason="Fails on windows bcoz of urllib.parse")
133+
def test_cloud_parquet_dir_forwards_storage_options(tmp_path, monkeypatch, fsspec_mock):
134+
fsspec_fs_mock = Mock()
135+
fsspec_fs_mock.ls = Mock(return_value=[])
136+
fsspec_mock.filesystem = Mock(return_value=fsspec_fs_mock)
137+
138+
monkeypatch.setattr("litdata.utilities.parquet._FSSPEC_AVAILABLE", True)
139+
140+
storage_options = {"key": "ACCESS_KEY", "secret": "SECRET_KEY", "endpoint_url": "https://s3.example.com"}
141+
CloudParquetDir("s3://some_bucket/some_path", tmp_path, storage_options=storage_options)
142+
143+
fsspec_mock.filesystem.assert_called_once_with("s3", **storage_options)
144+
145+
132146
@pytest.mark.usefixtures("clean_pq_index_cache")
133147
@patch("litdata.utilities.parquet._HF_HUB_AVAILABLE", True)
134148
@patch("litdata.streaming.downloader._HF_HUB_AVAILABLE", True)

0 commit comments

Comments
 (0)