Skip to content

Commit 0ef7c05

Browse files
committed
fix: wrong file path for get_filesystem_for_path
Signed-off-by: machichima <[email protected]>
1 parent 7ba66e2 commit 0ef7c05

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

flytekit/core/data_persistence.py

+12-7
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
from fsspec.asyn import AsyncFileSystem
3434
from fsspec.utils import get_protocol
3535
from obstore.fsspec import AsyncFsspecStore
36-
from obstore.store import GCSStore, S3Store, AzureStore
36+
from obstore.store import AzureStore, GCSStore, S3Store
3737
from typing_extensions import Unpack
3838

3939
from flytekit import configuration
@@ -86,6 +86,7 @@ def s3_setup_args(s3_cfg: configuration.S3Config, bucket: str = "", anonymous: b
8686

8787
return kwargs
8888

89+
8990
def gs_setup_args(gcs_cfg: configuration.GCSConfig, bucket: str = "", anonymous: bool = False) -> Dict[str, Any]:
9091
kwargs: Dict[str, Any] = {}
9192

@@ -140,7 +141,9 @@ def split_path(path: str) -> Tuple[str, str]:
140141
return bucket, path
141142

142143

143-
def azure_setup_args(azure_cfg: configuration.AzureBlobStorageConfig, container: str = "", anonymous: bool = False) -> Dict[str, Any]:
144+
def azure_setup_args(
145+
azure_cfg: configuration.AzureBlobStorageConfig, container: str = "", anonymous: bool = False
146+
) -> Dict[str, Any]:
144147
kwargs: Dict[str, Any] = {}
145148
store_kwargs: Dict[str, Any] = {}
146149

@@ -311,7 +314,9 @@ async def get_async_filesystem_for_path(
311314
protocol, anonymous=anonymous, path=path, bucket=bucket, asynchronous=True, loop=loop, **kwargs
312315
)
313316

314-
def get_filesystem_for_path(self, path: str = "", bucket: str = "", anonymous: bool = False, **kwargs) -> fsspec.AbstractFileSystem:
317+
def get_filesystem_for_path(
318+
self, path: str = "", bucket: str = "", anonymous: bool = False, **kwargs
319+
) -> fsspec.AbstractFileSystem:
315320
protocol = get_protocol(path)
316321
return self.get_filesystem(protocol, anonymous=anonymous, path=path, bucket=bucket, **kwargs)
317322

@@ -513,13 +518,13 @@ async def async_put_raw_data(
513518
r = await self._put(from_path, to_path, **kwargs)
514519
return r or to_path
515520

516-
bucket, to_path_file_only = split_path(to_path)
521+
bucket, _ = split_path(to_path)
517522

518523
# See https://github.com/fsspec/s3fs/issues/871 for more background and pending work on the fsspec side to
519524
# support effectively async open(). For now these use-cases below will revert to sync calls.
520525
# raw bytes
521526
if isinstance(lpath, bytes):
522-
fs = self.get_filesystem_for_path(to_path_file_only, bucket)
527+
fs = self.get_filesystem_for_path(to_path, bucket)
523528
with fs.open(to_path, "wb", **kwargs) as s:
524529
s.write(lpath)
525530
return to_path
@@ -528,7 +533,7 @@ async def async_put_raw_data(
528533
if isinstance(lpath, io.BufferedReader) or isinstance(lpath, io.BytesIO):
529534
if not lpath.readable():
530535
raise FlyteAssertion("Buffered reader must be readable")
531-
fs = self.get_filesystem_for_path(to_path_file_only, bucket)
536+
fs = self.get_filesystem_for_path(to_path, bucket)
532537
lpath.seek(0)
533538
with fs.open(to_path, "wb", **kwargs) as s:
534539
while data := lpath.read(read_chunk_size_bytes):
@@ -538,7 +543,7 @@ async def async_put_raw_data(
538543
if isinstance(lpath, io.StringIO):
539544
if not lpath.readable():
540545
raise FlyteAssertion("Buffered reader must be readable")
541-
fs = self.get_filesystem_for_path(to_path_file_only, bucket)
546+
fs = self.get_filesystem_for_path(to_path, bucket)
542547
lpath.seek(0)
543548
with fs.open(to_path, "wb", **kwargs) as s:
544549
while data_str := lpath.read(read_chunk_size_bytes):

0 commit comments

Comments
 (0)