Skip to content

Commit 8abecfe

Browse files
authored
fix: Fix async s3fs to handle latest changes to FlyteFile (#3223)
* fix: Fix async s3fs to handle latest changes to FlyteFile * docs: Add to docstring * fix: Add one more docstring Signed-off-by: ggydush <[email protected]> * style: Fix lint issues * fix: Commit pydoclint file --------- Signed-off-by: ggydush <[email protected]>
1 parent 2e2d2c2 commit 8abecfe

File tree

2 files changed

+23
-26
lines changed

2 files changed

+23
-26
lines changed

plugins/flytekit-async-fsspec/flytekitplugins/async_fsspec/s3fs/s3fs.py

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import asyncio
22
import mimetypes
33
import os
4+
from typing import Any, Callable, Optional
45

56
from fsspec.callbacks import _DEFAULT_CALLBACK
67
from s3fs import S3FileSystem
@@ -22,21 +23,22 @@ def __init__(self, **s3kwargs):
2223

2324
async def _put_file(
2425
self,
25-
lpath,
26-
rpath,
27-
callback=_DEFAULT_CALLBACK,
28-
chunksize=DEFAULT_UPLOAD_CHUNK_SIZE,
29-
concurrent_upload=DEFAULT_CONCURRENT_UPLOAD,
30-
**kwargs,
26+
lpath: str,
27+
rpath: str,
28+
callback: Callable = _DEFAULT_CALLBACK,
29+
chunksize: int = DEFAULT_UPLOAD_CHUNK_SIZE,
30+
concurrent_upload: int = DEFAULT_CONCURRENT_UPLOAD,
31+
**kwargs: Any,
3132
):
3233
"""
3334
Put a file from lpath to rpath.
3435
Args:
3536
lpath (str): The local path of the file to be uploaded.
3637
rpath (str): The remote path which the file should be uploaded to.
37-
callback (function, optional): The callback function.
38-
chunksize (int, optional): Upload chunksize. Defaults to 50 * 2**20 (50MB).
39-
concurrent_upload (int, optional): The number of concurrent upload when using multipart upload. Defaults to 4.
38+
callback (Callable): The callback function.
39+
chunksize (int): Upload chunksize. Defaults to 50 * 2**20 (50MB).
40+
concurrent_upload (int): The number of concurrent upload when using multipart upload. Defaults to 4.
41+
**kwargs (Any): Additional arguments passed to S3 calls.
4042
"""
4143
bucket, key, _ = self.split_path(rpath)
4244
if os.path.isdir(lpath):
@@ -107,21 +109,24 @@ async def upload_chunk(chunk, part_number):
107109

108110
async def _get_file(
109111
self,
110-
rpath,
111-
lpath,
112-
callback=_DEFAULT_CALLBACK,
113-
version_id=None,
114-
chunksize=DEFAULT_DOWNLOAD_CHUNK_SIZE,
115-
concurrent_download=DEFAULT_CONCURRENT_DOWNLOAD,
112+
rpath: str,
113+
lpath: str,
114+
callback: Callable = _DEFAULT_CALLBACK,
115+
version_id: Optional[str] = None,
116+
chunksize: int = DEFAULT_DOWNLOAD_CHUNK_SIZE,
117+
concurrent_download: int = DEFAULT_CONCURRENT_DOWNLOAD,
118+
**kwargs: Any, # noqa Used for extensibility or future arguments
116119
):
117120
"""
118121
Get a file from rpath to lpath.
119122
Args:
120123
rpath (str): The remote path of the file to be downloaded.
121124
lpath (str): The local path which the file should be downloaded to.
122-
callback (function, optional): The callback function.
123-
chunksize (int, optional): Download chunksize. Defaults to 50 * 2**20 (50MB).
124-
version_id (str, optional): The version id of the file. Defaults to None.
125+
callback (Callable): The callback function.
126+
version_id (Optional[str]): The version id of the file. Defaults to None.
127+
chunksize (int): Download chunksize. Defaults to 50 * 2**20 (50MB).
128+
concurrent_download (int): The number of concurrent threads when using multipart download. Defaults to 4.
129+
**kwargs (Any): Additional arguments for extensibility or future use.
125130
"""
126131
if os.path.isdir(lpath):
127132
return

pydoclint-errors-baseline.txt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -428,15 +428,7 @@ flytekit/types/structured/structured_dataset.py
428428
DOC301: Class `StructuredDatasetDecoder`: __init__() should not have a docstring; please combine it with the docstring of the class
429429
--------------------
430430
plugins/flytekit-async-fsspec/flytekitplugins/async_fsspec/s3fs/s3fs.py
431-
DOC101: Method `AsyncS3FileSystem._put_file`: Docstring contains fewer arguments than in function signature.
432-
DOC106: Method `AsyncS3FileSystem._put_file`: The option `--arg-type-hints-in-signature` is `True` but there are no argument type hints in the signature
433-
DOC107: Method `AsyncS3FileSystem._put_file`: The option `--arg-type-hints-in-signature` is `True` but not all args in the signature have type hints
434-
DOC103: Method `AsyncS3FileSystem._put_file`: Docstring arguments are different from function arguments. (Or could be other formatting issues: https://jsh9.github.io/pydoclint/violation_codes.html#notes-on-doc103 ). Arguments in the function signature but not in the docstring: [**kwargs: ].
435431
DOC201: Method `AsyncS3FileSystem._put_file` does not have a return section in docstring
436-
DOC101: Method `AsyncS3FileSystem._get_file`: Docstring contains fewer arguments than in function signature.
437-
DOC106: Method `AsyncS3FileSystem._get_file`: The option `--arg-type-hints-in-signature` is `True` but there are no argument type hints in the signature
438-
DOC107: Method `AsyncS3FileSystem._get_file`: The option `--arg-type-hints-in-signature` is `True` but not all args in the signature have type hints
439-
DOC103: Method `AsyncS3FileSystem._get_file`: Docstring arguments are different from function arguments. (Or could be other formatting issues: https://jsh9.github.io/pydoclint/violation_codes.html#notes-on-doc103 ). Arguments in the function signature but not in the docstring: [concurrent_download: ].
440432
DOC201: Method `AsyncS3FileSystem._get_file` does not have a return section in docstring
441433
--------------------
442434
plugins/flytekit-aws-athena/flytekitplugins/athena/task.py

0 commit comments

Comments
 (0)