Skip to content

Commit 1ec0563

Browse files
Balaji SankarRuban Hussain
authored andcommitted
fix: bubble up exceptions from S3 while fetching the Config
1 parent ada7ddc commit 1ec0563

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

src/sagemaker/config/config.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -181,16 +181,11 @@ def _get_inferred_s3_uri(s3_uri, s3_resource_for_config):
181181
"""Placeholder docstring"""
182182
parsed_url = urlparse(s3_uri)
183183
bucket, key_prefix = parsed_url.netloc, parsed_url.path.lstrip("/")
184-
try:
185-
s3_bucket = s3_resource_for_config.Bucket(name=bucket)
186-
s3_objects = s3_bucket.objects.filter(Prefix=key_prefix).all()
187-
s3_files_with_same_prefix = [
188-
"{}{}/{}".format(S3_PREFIX, bucket, s3_object.key) for s3_object in s3_objects
189-
]
190-
except Exception as e: # pylint: disable=W0703
191-
# if customers didn't provide us with a valid S3 File/insufficient read permission,
192-
# We will fail hard.
193-
raise RuntimeError(f"Unable to read from S3 with URI: {s3_uri} due to {e}")
184+
s3_bucket = s3_resource_for_config.Bucket(name=bucket)
185+
s3_objects = s3_bucket.objects.filter(Prefix=key_prefix).all()
186+
s3_files_with_same_prefix = [
187+
"{}{}/{}".format(S3_PREFIX, bucket, s3_object.key) for s3_object in s3_objects
188+
]
194189
if len(s3_files_with_same_prefix) == 0:
195190
# Customer provided us with an incorrect s3 path.
196191
raise ValueError("Provide a valid S3 path instead of {}".format(s3_uri))

0 commit comments

Comments
 (0)