Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: kirkrodrigues <[email protected]>
  • Loading branch information
haiqi96 and kirkrodrigues authored Dec 18, 2024
1 parent 3b870a4 commit 214ae3f
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions components/clp-py-utils/clp_py_utils/s3_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,19 @@ def s3_put(
s3_config: S3Config, src_file: Path, dest_file_name: str, total_max_attempts: int = 3
) -> Result[bool, str]:
"""
Upload a local file to S3 bucket using AWS's PutObject operation.
:param s3_config: S3 configuration specifies the upload destination and credentials.
:param src_file: local file to upload.
:param dest_file_name: The name for uploaded file in the S3 bucket.
:param total_max_attempts: Maximum number of retry attempts for the upload. Defaults to 3.
:return: Result.OK(bool) on success.
Result.Err(str) with the error message if put operation fails.
Uploads a local file to an S3 bucket using AWS's PutObject operation.
:param s3_config: S3 configuration specifying the upload destination and credentials.
:param src_file: Local file to upload.
:param dest_file_name: The name for the uploaded file in the S3 bucket.
:param total_max_attempts: Maximum number of retry attempts for the upload.
:return: Result.OK(bool) on success, or Result.Err(str) with the error message otherwise.
"""
if not src_file.exists():
return Err(f"{src_file} doesn't exist")
if not src_file.is_file():
return Err(f"{src_file} is not a file")
if src_file.stat().st_size > 5 * 1024 * 1024 * 1024:
return Err("File size exceeds 5GB limit for single put_object operation")
return Err(f"{src_file} is larger than the limit (5GiB) for a single PutObject operation.")

config = Config(retries=dict(total_max_attempts=total_max_attempts, mode="adaptive"))

Expand Down

0 comments on commit 214ae3f

Please sign in to comment.