Skip to content

Commit

Permalink
feat: Support ftp when using FlyteFile (#2409)
Browse files Browse the repository at this point in the history
* feat: Support ftp when using FlyteFile

Signed-off-by: ggydush <greggydush@gmail.com>

* fix: Use optional instead

Signed-off-by: ggydush <greggydush@gmail.com>

---------

Signed-off-by: ggydush <greggydush@gmail.com>
  • Loading branch information
ggydush committed May 11, 2024
1 parent 0d4981b commit c36f322
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions flytekit/core/data_persistence.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,11 @@ def raw_output_fs(self) -> fsspec.AbstractFileSystem:
return self._default_remote

def get_filesystem(
self, protocol: typing.Optional[str] = None, anonymous: bool = False, **kwargs
self,
protocol: typing.Optional[str] = None,
anonymous: bool = False,
path: typing.Optional[str] = None,
**kwargs,
) -> fsspec.AbstractFileSystem:
if not protocol:
return self._default_remote
Expand All @@ -195,6 +199,9 @@ def get_filesystem(
if anonymous:
kwargs["token"] = _ANON
return fsspec.filesystem(protocol, **kwargs) # type: ignore
elif protocol == "ftp":
kwargs.update(fsspec.implementations.ftp.FTPFileSystem._get_kwargs_from_urls(path))
return fsspec.filesystem(protocol, **kwargs)

storage_options = get_fsspec_storage_options(
protocol=protocol, anonymous=anonymous, data_config=self._data_config, **kwargs
Expand All @@ -204,7 +211,7 @@ def get_filesystem(

def get_filesystem_for_path(self, path: str = "", anonymous: bool = False, **kwargs) -> fsspec.AbstractFileSystem:
protocol = get_protocol(path)
return self.get_filesystem(protocol, anonymous=anonymous, **kwargs)
return self.get_filesystem(protocol, anonymous=anonymous, path=path, **kwargs)

@staticmethod
def is_remote(path: Union[str, os.PathLike]) -> bool:
Expand Down

0 comments on commit c36f322

Please sign in to comment.