Skip to content

Commit

Permalink
update arg names + readme
Browse files Browse the repository at this point in the history
  • Loading branch information
nkshaw23 committed Oct 2, 2024
1 parent e112df8 commit fcf6eb2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,7 @@ body = b"I'm a byte encoded document"
writer = S3Writer(client)

# Submit a file to AWS S3

object_bytes = reader.read(bucket="my-bucket", key="Path/to/file", body=body)
writer.wite(bucket="my-bucket", key="Path/to/file", body=body)
```

#### Reading/Writing Combo Class
Expand Down
8 changes: 4 additions & 4 deletions src/driutils/io/aws.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ def __init__(self, s3_client: S3Client) -> None:
class S3Reader(S3Base, ReaderInterface):
"""Class for handling file reads using the AWS S3 client"""

def read(self, bucket_name: str, s3_key: str) -> bytes:
def read(self, bucket_name: str, key: str) -> bytes:
"""
Retrieves an object from an S3 bucket.
If any step fails, it logs an error and re-raises the exception.
Args:
bucket_name: The name of the S3 bucket.
s3_key: The key (path) of the object within the bucket.
key: The key (path) of the object within the bucket.
Returns:
bytes: raw bytes of the S3 object
Expand All @@ -48,10 +48,10 @@ def read(self, bucket_name: str, s3_key: str) -> bytes:
Exception: If there's any error in retrieving or parsing the object.
"""
try:
data = self._connection.get_object(Bucket=bucket_name, Key=s3_key)
data = self._connection.get_object(Bucket=bucket_name, Key=key)
return data["Body"].read()
except (RuntimeError, ClientError) as e:
logger.error(f"Failed to get {s3_key} from {bucket_name}")
logger.error(f"Failed to get {key} from {bucket_name}")
logger.exception(e)
raise e

Expand Down

0 comments on commit fcf6eb2

Please sign in to comment.