Skip to content

Commit 39cfcdc

Browse files
authored
Merge pull request #9 from danabens/master
short circuit docker image creation if image with same tag already ex…
2 parents 0ca1fb3 + 2b9c834 commit 39cfcdc

File tree

4 files changed

+19
-10
lines changed

4 files changed

+19
-10
lines changed

tests/conftest.py

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -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',

tests/integ-jobs/test_track_from_processing_job.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# language governing permissions and limitations under the License.
1313

1414
import sys
15+
1516
from tests.helpers import *
1617

1718
from smexperiments import trial_component, api_types
@@ -22,6 +23,7 @@ def wait_for_job(job, sagemaker_client):
2223
while True:
2324
response = sagemaker_client.describe_processing_job(ProcessingJobName=job)
2425
status = response['ProcessingJobStatus']
26+
print(f'Processing job status: {status}')
2527
if status == 'Failed':
2628
print(response)
2729
dump_logs(job)

tests/integ/__init__.py

Whitespace-only changes.

tests/unit/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)