in docker/build_artifacts/sagemaker/serve.py [0:0]
def _download_scripts(self, bucket, prefix):
log.info("checking boto session region ...")
boto_session = boto3.session.Session()
boto_region = boto_session.region_name
if boto_region in ("us-iso-east-1", "us-gov-west-1"):
raise ValueError("Universal scripts is not supported in us-iso-east-1 or us-gov-west-1")
log.info("downloading universal scripts ...")
client = boto3.client("s3")
resource = boto3.resource("s3")
# download files
paginator = client.get_paginator("list_objects")
for result in paginator.paginate(Bucket=bucket, Delimiter="/", Prefix=prefix):
for file in result.get("Contents", []):
destination = os.path.join(CODE_DIR, file.get("Key"))
if not os.path.exists(os.path.dirname(destination)):
os.makedirs(os.path.dirname(destination))
resource.meta.client.download_file(bucket, file.get("Key"), destination)