in benchmarking/pipemode_benchmark/repo_helper.py [0:0]
def repository(region='us-west-2'):
"""Return a repository to store benchmarking docker images in."""
client = boto3.client('ecr', region_name=region)
try:
client.create_repository(repositoryName='tf-pipemode')
except ClientError as ex:
if 'RepositoryAlreadyExistsException' in ex.message:
pass
else:
raise ex
policy = {
"Version": "2008-10-17",
"Statement": [
{
"Sid": "sagemaker",
"Effect": "Allow",
"Principal": {
"Service": [
"sagemaker.amazonaws.com"
]
},
"Action": [
"ecr:GetDownloadUrlForLayer",
"ecr:BatchGetImage",
"ecr:BatchCheckLayerAvailabilityecr:GetDownloadUrlForLayer",
"ecr:BatchGetImage",
"ecr:BatchCheckLayerAvailability",
"ecr:ListImages",
"ecr:DescribeImages"
]
}
]
}
client.set_repository_policy(repositoryName='tf-pipemode', policyText=json.dumps(policy))
account = boto3.client('sts').get_caller_identity()['Account']
return '{}.dkr.ecr.{}.amazonaws.com/tf-pipemode'.format(account, region)