Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added optional bucket argument to s3_utils.read_s3 function. #318

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ dcicutils
Change Log
----------

8.15.0
======
* 2024-10-04 (dmichaels)
* Added optional bucket argument to s3_utils.read_s3 (initially for Andy).


8.14.3
======

Expand Down
6 changes: 4 additions & 2 deletions dcicutils/s3_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,10 @@ def get_key(self, keyfile_name: str = 'access_key_admin'
# maybe its not json after all
return auth_text

def read_s3(self, filename: str):
response = self.s3.get_object(Bucket=self.outfile_bucket, Key=filename)
def read_s3(self, filename: str, bucket: Optional[str] = None):
if (not isinstance(bucket, str)) or (not bucket):
bucket = self.outfile_bucket
response = self.s3.get_object(Bucket=bucket, Key=filename)
logger.info(str(response))
return response['Body'].read()

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "dcicutils"
version = "8.14.3"
version = "8.14.3.1b1" # TODO: To become 8.15.0
description = "Utility package for interacting with the 4DN Data Portal and other 4DN resources"
authors = ["4DN-DCIC Team <[email protected]>"]
license = "MIT"
Expand Down
Loading