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

Cloudflare R2 Source #198

Merged
merged 2 commits into from
Jan 22, 2024
Merged
Changes from all commits
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
15 changes: 12 additions & 3 deletions server/lorax_server/utils/sources/s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,17 @@ def _get_bucket_resource(bucket_name: str) -> "Bucket":
mode="standard",
)
)
s3 = boto3.resource('s3', config=config)
return s3.Bucket(bucket_name)

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)
else:
s3 = boto3.resource('s3', config=config)
return s3.Bucket(bucket_name)


def get_s3_model_local_dir(model_id: str):
Expand Down Expand Up @@ -222,4 +231,4 @@ def download_model_assets(self):
return download_model_from_s3(self.bucket, self.model_id, self.extension)

def get_local_path(self, model_id: str):
return get_s3_model_local_dir(model_id)
return get_s3_model_local_dir(model_id)
Loading