in src/sagemaker_core/helper/session_helper.py [0:0]
def create_bucket_for_not_exist_error(self, bucket_name, region, s3):
"""Creates the S3 bucket in the given region
Args:
bucket_name (str): Name of the S3 bucket
s3 (str): S3 object from boto session
region (str): The region in which to create the bucket.
"""
# bucket does not exist, create one
try:
if region == "us-east-1":
# 'us-east-1' cannot be specified because it is the default region:
# https://github.com/boto/boto3/issues/125
s3.create_bucket(Bucket=bucket_name)
else:
s3.create_bucket(
Bucket=bucket_name,
CreateBucketConfiguration={"LocationConstraint": region},
)
logger.info("Created S3 bucket: %s", bucket_name)
except ClientError as e:
error_code = e.response["Error"]["Code"]
message = e.response["Error"]["Message"]
if error_code == "OperationAborted" and "conflicting conditional operation" in message:
# If this bucket is already being concurrently created,
# we don't need to create it again.
pass
else:
raise