22
22
import pytest
23
23
from botocore .exceptions import ClientError
24
24
25
+ import tests
26
+
25
27
from sagemaker import utils
26
28
from sagemaker .amazon .randomcutforest import RandomCutForest
27
29
from sagemaker .deserializers import StringDeserializer
@@ -46,18 +48,26 @@ def container_image(sagemaker_session):
46
48
algorithm_name = unique_name_from_base ("sagemaker-multimodel-integ-test" )
47
49
ecr_image = _ecr_image_uri (sagemaker_session , algorithm_name )
48
50
49
- # Build and tag docker image locally
51
+ ecr_client = sagemaker_session .boto_session .client ("ecr" )
52
+ username , password = _ecr_login (ecr_client )
53
+
50
54
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
51
61
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 ,
53
65
)
54
66
image .tag (ecr_image , tag = "latest" )
55
67
56
68
# Create AWS ECR and push the local docker image to it
57
- ecr_client = sagemaker_session .boto_session .client ("ecr" )
58
69
_create_repository (ecr_client , algorithm_name )
59
70
60
- username , password = _ecr_login (ecr_client )
61
71
# Retry docker image push
62
72
for _ in retries (3 , "Upload docker image to ECR repo" , seconds_to_sleep = 10 ):
63
73
try :
@@ -124,6 +134,10 @@ def _ecr_login(ecr_client):
124
134
return username , password
125
135
126
136
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
+ )
127
141
def test_multi_data_model_deploy_pretrained_models (
128
142
container_image , sagemaker_session , cpu_instance_type
129
143
):
@@ -184,6 +198,10 @@ def test_multi_data_model_deploy_pretrained_models(
184
198
185
199
186
200
@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
+ )
187
205
def test_multi_data_model_deploy_pretrained_models_local_mode (container_image , sagemaker_session ):
188
206
timestamp = sagemaker_timestamp ()
189
207
endpoint_name = "test-multimodel-endpoint-{}" .format (timestamp )
@@ -244,6 +262,10 @@ def test_multi_data_model_deploy_pretrained_models_local_mode(container_image, s
244
262
assert "Could not find endpoint" in str (exception .value )
245
263
246
264
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
+ )
247
269
def test_multi_data_model_deploy_trained_model_from_framework_estimator (
248
270
container_image ,
249
271
sagemaker_session ,
@@ -358,6 +380,10 @@ def _mxnet_training_job(
358
380
return mx .create_model (image_uri = container_image )
359
381
360
382
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
+ )
361
387
def test_multi_data_model_deploy_train_model_from_amazon_first_party_estimator (
362
388
container_image , sagemaker_session , cpu_instance_type
363
389
):
@@ -455,6 +481,10 @@ def __rcf_training_job(
455
481
return rcf_model
456
482
457
483
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
+ )
458
488
def test_multi_data_model_deploy_pretrained_models_update_endpoint (
459
489
container_image , sagemaker_session , cpu_instance_type , alternative_cpu_instance_type
460
490
):
0 commit comments