in src/sagemaker_tensorflow_container/s3_utils.py [0:0]
def _s3_region(job_region, model_dir):
if model_dir and model_dir.startswith("s3://"):
s3 = boto3.client("s3", region_name=job_region)
# We get the AWS region of the checkpoint bucket, which may be different from
# the region this container is currently running in.
parsed_url = urlparse(model_dir)
bucket_name = parsed_url.netloc
bucket_location = s3.get_bucket_location(Bucket=bucket_name)["LocationConstraint"]
return bucket_location or job_region
else:
return job_region