@@ -291,15 +291,11 @@ def docker_image(boto_model_file):
291291 token = ecr_client .get_authorization_token ()
292292 username , password = base64 .b64decode (token ['authorizationData' ][0 ]['authorizationToken' ]).decode ().split (':' )
293293 registry = token ['authorizationData' ][0 ]['proxyEndpoint' ]
294-
295- subprocess .check_call ([sys .executable , 'setup.py' , 'sdist' ])
296- [sdist_path ] = glob .glob ('dist/smexperiments*' )
297- shutil .copy (sdist_path , 'tests/integ-jobs/docker/smexperiments-0.1.0.tar.gz' )
298-
299- os .makedirs ('tests/integ-jobs/docker/boto' , exist_ok = True )
300- shutil .copy (boto_model_file , 'tests/integ-jobs/docker/boto/sagemaker-experiments-2017-07-24.normal.json' )
301-
302294 repository_name = "smexperiments-test"
295+ image_version = '1.0.0'
296+ tag = '{}/{}:{}' .format (registry , repository_name , image_version )[8 :]
297+
298+ # initialize the docker image repository
303299 try :
304300 ecr_client .create_repository (repositoryName = repository_name )
305301 except botocore .exceptions .ClientError as e :
@@ -308,13 +304,24 @@ def docker_image(boto_model_file):
308304 else :
309305 raise
310306
311- tag = '{}/{}:{}' .format (registry , repository_name , '1.0.0' )[8 :]
312-
313307 # pull existing image for layer cache
314308 try :
315309 client .images .pull (tag , auth_config = {'username' : username , 'password' : password })
310+ # the image with this tag already exists
311+ return tag
316312 except docker .errors .NotFound :
317313 pass
314+
315+ if boto_model_file is None :
316+ raise ValueError ('boto_model_file cannot be None' )
317+
318+ subprocess .check_call ([sys .executable , 'setup.py' , 'sdist' ])
319+ [sdist_path ] = glob .glob ('dist/sagemaker-experiments*' )
320+ shutil .copy (sdist_path , 'tests/integ-jobs/docker/smexperiments-0.1.0.tar.gz' )
321+
322+ os .makedirs ('tests/integ-jobs/docker/boto' , exist_ok = True )
323+ shutil .copy (boto_model_file , 'tests/integ-jobs/docker/boto/sagemaker-experiments-2017-07-24.normal.json' )
324+
318325 client .images .build (
319326 path = 'tests/integ-jobs/docker' ,
320327 dockerfile = 'Dockerfile' ,
0 commit comments