Skip to content

Commit 907b993

Browse files
authored
Allow local deployments of public models without requiring AWS creds (#1589)
1 parent 5de83c7 commit 907b993

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

pkg/workloads/cortex/lib/api/predictor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ def model_downloader(
523523
f"downloading from bucket {bucket_name}/{model_path}, model {model_name} of version {model_version}, temporarily to {temp_dir} and then finally to {model_dir}"
524524
)
525525

526-
s3_client = S3(bucket_name, client_config={})
526+
s3_client = S3(bucket_name)
527527

528528
# validate upstream S3 model
529529
sub_paths, ts = s3_client.search(model_path)

pkg/workloads/cortex/lib/model/cron.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ def find_all_s3_models(
144144
# validate models stored in S3 that were specified with predictor:models:dir field
145145
if is_dir_used:
146146
bucket_name, models_path = S3.deconstruct_s3_path(models_dir)
147-
s3_client = S3(bucket_name, client_config={})
147+
s3_client = S3(bucket_name)
148148
sub_paths, timestamps = s3_client.search(models_path)
149149
model_paths, ooa_ids = validate_models_dir_paths(sub_paths, predictor_type, models_path)
150150
model_names = [os.path.basename(model_path) for model_path in model_paths]
@@ -171,7 +171,7 @@ def find_all_s3_models(
171171
for idx, path in enumerate(s3_paths):
172172
if S3.is_valid_s3_path(path):
173173
bucket_name, model_path = S3.deconstruct_s3_path(path)
174-
s3_client = S3(bucket_name, client_config={})
174+
s3_client = S3(bucket_name)
175175
sb, model_path_ts = s3_client.search(model_path)
176176
try:
177177
ooa_ids.append(validate_model_paths(sb, predictor_type, model_path))
@@ -451,7 +451,7 @@ def _refresh_model(
451451
sub_paths: List[str],
452452
bucket_name: str,
453453
) -> None:
454-
s3_client = S3(bucket_name, client_config={})
454+
s3_client = S3(bucket_name)
455455

456456
ondisk_model_path = os.path.join(self._download_dir, model_name)
457457
for version, model_ts in zip(versions, timestamps):
@@ -1059,7 +1059,7 @@ def _refresh_model(
10591059
sub_paths: List[str],
10601060
bucket_name: str,
10611061
) -> None:
1062-
s3_client = S3(bucket_name, client_config={})
1062+
s3_client = S3(bucket_name)
10631063

10641064
ondisk_model_path = os.path.join(self._download_dir, model_name)
10651065
for version, model_ts in zip(versions, timestamps):

pkg/workloads/cortex/lib/storage/s3.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ def __init__(self, bucket=None, region=None, client_config={}):
3737
if region is not None:
3838
client_config["region_name"] = region
3939

40+
if not (os.getenv("AWS_ACCESS_KEY_ID") and os.getenv("AWS_SECRET_ACCESS_KEY")):
41+
client_config["config"] = botocore.client.Config(signature_version=botocore.UNSIGNED)
42+
4043
self.s3 = boto3.client("s3", **client_config)
4144

4245
@staticmethod

0 commit comments

Comments
 (0)