Skip to content

Commit 9b07530

Browse files
authored
adding s3 session function instead of client function (#302)
1 parent 14baa29 commit 9b07530

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

model-engine/model_engine_server/infra/gateways/s3_llm_artifact_gateway.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,10 @@ def list_files(self, path: str, **kwargs) -> List[str]:
2323
parsed_remote = parse_attachment_url(path)
2424
bucket = parsed_remote.bucket
2525
key = parsed_remote.key
26-
# From here: https://dev.to/aws-builders/how-to-list-contents-of-s3-bucket-using-boto3-python-47mm
27-
files = [
28-
bucket_object["Key"]
29-
for bucket_object in s3.list_objects_v2(Bucket=bucket, Prefix=key)["Contents"]
30-
]
26+
27+
# Using resource's bucket object to get its objects with specific prefix
28+
s3_bucket = s3.Bucket(bucket)
29+
files = [obj.key for obj in s3_bucket.objects.filter(Prefix=key)]
3130
return files
3231

3332
def get_model_weights_urls(self, owner: str, model_name: str, **kwargs) -> List[str]:

0 commit comments

Comments
 (0)