Skip to content

Commit

Permalink
Provide more granular methods to configure the embedded S3 client. (#325
Browse files Browse the repository at this point in the history
)
  • Loading branch information
mitchklusty authored Mar 13, 2024
1 parent e637d89 commit e7ccc63
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions server/lorax_server/utils/sources/s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,21 @@ def _get_bucket_resource(bucket_name: str) -> "Bucket":
)
)

S3_ENDPOINT_URL = os.environ.get("S3_ENDPOINT_URL", None)
R2_ACCOUNT_ID = os.environ.get("R2_ACCOUNT_ID", None)

if R2_ACCOUNT_ID:
s3 = boto3.resource('s3',
endpoint_url = f'https://{R2_ACCOUNT_ID}.r2.cloudflarestorage.com',
config=config
)
return s3.Bucket(bucket_name)
elif S3_ENDPOINT_URL:
s3 = boto3.resource('s3',
endpoint_url = f'{S3_ENDPOINT_URL}',
config=config
)
return s3.Bucket(bucket_name)
else:
s3 = boto3.resource('s3', config=config)
return s3.Bucket(bucket_name)
Expand Down

0 comments on commit e7ccc63

Please sign in to comment.