2525from sagemaker .utils import sagemaker_timestamp
2626from tests .integ import DATA_DIR
2727from tests .integ .timeout import timeout , timeout_and_delete_endpoint_by_name
28+ from tests .integ .marketplace_utils import REGION_ACCOUNT_MAP
2829
2930
3031# All these tests require a manual 1 time subscription to the following Marketplace items:
3637#
3738# Both are written by Amazon and are free to subscribe.
3839
39- ALGORITHM_ARN = 'arn:aws:sagemaker:%s:594846645681 :algorithm/scikit-decision-trees-' \
40+ ALGORITHM_ARN = 'arn:aws:sagemaker:%s:%s :algorithm/scikit-decision-trees-' \
4041 '15423055-57b73412d2e93e9239e4e16f83298b8f'
4142
42- MODEL_PACKAGE_ARN = 'arn:aws:sagemaker:%s:594846645681 :model-package/scikit-iris-detector-' \
43+ MODEL_PACKAGE_ARN = 'arn:aws:sagemaker:%s:%s :model-package/scikit-iris-detector-' \
4344 '154230595-8f00905c1f927a512b73ea29dd09ae30'
4445
4546
4647@pytest .mark .canary_quick
4748def test_marketplace_estimator (sagemaker_session ):
4849 with timeout (minutes = 15 ):
4950 data_path = os .path .join (DATA_DIR , 'marketplace' , 'training' )
51+ region = sagemaker_session .boto_region_name
52+ account = REGION_ACCOUNT_MAP [region ]
53+ algorithm_arn = ALGORITHM_ARN % (region , account )
5054
5155 algo = AlgorithmEstimator (
52- algorithm_arn = ( ALGORITHM_ARN % sagemaker_session . boto_region_name ) ,
56+ algorithm_arn = algorithm_arn ,
5357 role = 'SageMakerRole' ,
5458 train_instance_count = 1 ,
5559 train_instance_type = 'ml.c4.xlarge' ,
@@ -78,9 +82,12 @@ def test_marketplace_estimator(sagemaker_session):
7882def test_marketplace_attach (sagemaker_session ):
7983 with timeout (minutes = 15 ):
8084 data_path = os .path .join (DATA_DIR , 'marketplace' , 'training' )
85+ region = sagemaker_session .boto_region_name
86+ account = REGION_ACCOUNT_MAP [region ]
87+ algorithm_arn = ALGORITHM_ARN % (region , account )
8188
8289 mktplace = AlgorithmEstimator (
83- algorithm_arn = ( ALGORITHM_ARN % sagemaker_session . boto_region_name ) ,
90+ algorithm_arn = algorithm_arn ,
8491 role = 'SageMakerRole' ,
8592 train_instance_count = 1 ,
8693 train_instance_type = 'ml.c4.xlarge' ,
@@ -116,14 +123,17 @@ def test_marketplace_attach(sagemaker_session):
116123
117124@pytest .mark .canary_quick
118125def test_marketplace_model (sagemaker_session ):
126+ region = sagemaker_session .boto_region_name
127+ account = REGION_ACCOUNT_MAP [region ]
128+ model_package_arn = MODEL_PACKAGE_ARN % (region , account )
119129
120130 def predict_wrapper (endpoint , session ):
121131 return sagemaker .RealTimePredictor (
122132 endpoint , session , serializer = sagemaker .predictor .csv_serializer
123133 )
124134
125135 model = ModelPackage (role = 'SageMakerRole' ,
126- model_package_arn = ( MODEL_PACKAGE_ARN % sagemaker_session . boto_region_name ) ,
136+ model_package_arn = model_package_arn ,
127137 sagemaker_session = sagemaker_session ,
128138 predictor_cls = predict_wrapper )
129139
@@ -144,9 +154,12 @@ def predict_wrapper(endpoint, session):
144154
145155def test_marketplace_tuning_job (sagemaker_session ):
146156 data_path = os .path .join (DATA_DIR , 'marketplace' , 'training' )
157+ region = sagemaker_session .boto_region_name
158+ account = REGION_ACCOUNT_MAP [region ]
159+ algorithm_arn = ALGORITHM_ARN % (region , account )
147160
148161 mktplace = AlgorithmEstimator (
149- algorithm_arn = ( ALGORITHM_ARN % sagemaker_session . boto_region_name ) ,
162+ algorithm_arn = algorithm_arn ,
150163 role = 'SageMakerRole' ,
151164 train_instance_count = 1 ,
152165 train_instance_type = 'ml.c4.xlarge' ,
@@ -172,9 +185,12 @@ def test_marketplace_tuning_job(sagemaker_session):
172185
173186def test_marketplace_transform_job (sagemaker_session ):
174187 data_path = os .path .join (DATA_DIR , 'marketplace' , 'training' )
188+ region = sagemaker_session .boto_region_name
189+ account = REGION_ACCOUNT_MAP [region ]
190+ algorithm_arn = ALGORITHM_ARN % (region , account )
175191
176192 algo = AlgorithmEstimator (
177- algorithm_arn = ( ALGORITHM_ARN % sagemaker_session . boto_region_name ) ,
193+ algorithm_arn = algorithm_arn ,
178194 role = 'SageMakerRole' ,
179195 train_instance_count = 1 ,
180196 train_instance_type = 'ml.c4.xlarge' ,
@@ -209,8 +225,12 @@ def test_marketplace_transform_job_from_model_package(sagemaker_session):
209225 TRANSFORM_WORKDIR ,
210226 key_prefix = 'integ-test-data/marketplace/transform' )
211227
228+ region = sagemaker_session .boto_region_name
229+ account = REGION_ACCOUNT_MAP [region ]
230+ model_package_arn = MODEL_PACKAGE_ARN % (region , account )
231+
212232 model = ModelPackage (role = 'SageMakerRole' ,
213- model_package_arn = ( MODEL_PACKAGE_ARN % sagemaker_session . boto_region_name ) ,
233+ model_package_arn = model_package_arn ,
214234 sagemaker_session = sagemaker_session )
215235
216236 transformer = model .transformer (1 , 'ml.m4.xlarge' )
0 commit comments