Skip to content

Commit 204533b

Browse files
authored
infra: use ECR-hosted image for ubuntu:16.04 (#1987)
1 parent 6537931 commit 204533b

File tree

2 files changed

+35
-5
lines changed

2 files changed

+35
-5
lines changed

tests/data/multimodel/container/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM ubuntu:16.04
1+
FROM 142577830533.dkr.ecr.us-east-2.amazonaws.com/ubuntu:16.04
22

33
# Set a docker label to advertise multi-model support on the container
44
LABEL com.amazonaws.sagemaker.capabilities.multi-models=true

tests/integ/test_multidatamodel.py

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
import pytest
2323
from botocore.exceptions import ClientError
2424

25+
import tests
26+
2527
from sagemaker import utils
2628
from sagemaker.amazon.randomcutforest import RandomCutForest
2729
from sagemaker.deserializers import StringDeserializer
@@ -46,18 +48,26 @@ def container_image(sagemaker_session):
4648
algorithm_name = unique_name_from_base("sagemaker-multimodel-integ-test")
4749
ecr_image = _ecr_image_uri(sagemaker_session, algorithm_name)
4850

49-
# Build and tag docker image locally
51+
ecr_client = sagemaker_session.boto_session.client("ecr")
52+
username, password = _ecr_login(ecr_client)
53+
5054
docker_client = docker.from_env()
55+
56+
# Base image pull
57+
base_image = "142577830533.dkr.ecr.us-east-2.amazonaws.com/ubuntu:16.04"
58+
docker_client.images.pull(base_image, auth_config={"username": username, "password": password})
59+
60+
# Build and tag docker image locally
5161
image, build_log = docker_client.images.build(
52-
path=os.path.join(DATA_DIR, "multimodel", "container"), tag=algorithm_name, rm=True
62+
path=os.path.join(DATA_DIR, "multimodel", "container"),
63+
tag=algorithm_name,
64+
rm=True,
5365
)
5466
image.tag(ecr_image, tag="latest")
5567

5668
# Create AWS ECR and push the local docker image to it
57-
ecr_client = sagemaker_session.boto_session.client("ecr")
5869
_create_repository(ecr_client, algorithm_name)
5970

60-
username, password = _ecr_login(ecr_client)
6171
# Retry docker image push
6272
for _ in retries(3, "Upload docker image to ECR repo", seconds_to_sleep=10):
6373
try:
@@ -124,6 +134,10 @@ def _ecr_login(ecr_client):
124134
return username, password
125135

126136

137+
@pytest.mark.skipif(
138+
tests.integ.test_region() != "us-east-2",
139+
reason="Pulling the base image is currently limited to us-east-2.",
140+
)
127141
def test_multi_data_model_deploy_pretrained_models(
128142
container_image, sagemaker_session, cpu_instance_type
129143
):
@@ -184,6 +198,10 @@ def test_multi_data_model_deploy_pretrained_models(
184198

185199

186200
@pytest.mark.local_mode
201+
@pytest.mark.skipif(
202+
tests.integ.test_region() != "us-east-2",
203+
reason="Pulling the base image is currently limited to us-east-2.",
204+
)
187205
def test_multi_data_model_deploy_pretrained_models_local_mode(container_image, sagemaker_session):
188206
timestamp = sagemaker_timestamp()
189207
endpoint_name = "test-multimodel-endpoint-{}".format(timestamp)
@@ -244,6 +262,10 @@ def test_multi_data_model_deploy_pretrained_models_local_mode(container_image, s
244262
assert "Could not find endpoint" in str(exception.value)
245263

246264

265+
@pytest.mark.skipif(
266+
tests.integ.test_region() != "us-east-2",
267+
reason="Pulling the base image is currently limited to us-east-2.",
268+
)
247269
def test_multi_data_model_deploy_trained_model_from_framework_estimator(
248270
container_image,
249271
sagemaker_session,
@@ -358,6 +380,10 @@ def _mxnet_training_job(
358380
return mx.create_model(image_uri=container_image)
359381

360382

383+
@pytest.mark.skipif(
384+
tests.integ.test_region() != "us-east-2",
385+
reason="Pulling the base image is currently limited to us-east-2.",
386+
)
361387
def test_multi_data_model_deploy_train_model_from_amazon_first_party_estimator(
362388
container_image, sagemaker_session, cpu_instance_type
363389
):
@@ -455,6 +481,10 @@ def __rcf_training_job(
455481
return rcf_model
456482

457483

484+
@pytest.mark.skipif(
485+
tests.integ.test_region() != "us-east-2",
486+
reason="Pulling the base image is currently limited to us-east-2.",
487+
)
458488
def test_multi_data_model_deploy_pretrained_models_update_endpoint(
459489
container_image, sagemaker_session, cpu_instance_type, alternative_cpu_instance_type
460490
):

0 commit comments

Comments
 (0)