25
25
from sagemaker .utils import sagemaker_timestamp
26
26
from tests .integ import DATA_DIR
27
27
from tests .integ .timeout import timeout , timeout_and_delete_endpoint_by_name
28
+ from tests .integ .marketplace_utils import REGION_ACCOUNT_MAP
28
29
29
30
30
31
# All these tests require a manual 1 time subscription to the following Marketplace items:
36
37
#
37
38
# Both are written by Amazon and are free to subscribe.
38
39
39
- ALGORITHM_ARN = 'arn:aws:sagemaker:%s:594846645681 :algorithm/scikit-decision-trees-' \
40
+ ALGORITHM_ARN = 'arn:aws:sagemaker:%s:%s :algorithm/scikit-decision-trees-' \
40
41
'15423055-57b73412d2e93e9239e4e16f83298b8f'
41
42
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-' \
43
44
'154230595-8f00905c1f927a512b73ea29dd09ae30'
44
45
45
46
46
47
@pytest .mark .canary_quick
47
48
def test_marketplace_estimator (sagemaker_session ):
48
49
with timeout (minutes = 15 ):
49
50
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 )
50
54
51
55
algo = AlgorithmEstimator (
52
- algorithm_arn = ( ALGORITHM_ARN % sagemaker_session . boto_region_name ) ,
56
+ algorithm_arn = algorithm_arn ,
53
57
role = 'SageMakerRole' ,
54
58
train_instance_count = 1 ,
55
59
train_instance_type = 'ml.c4.xlarge' ,
@@ -78,9 +82,12 @@ def test_marketplace_estimator(sagemaker_session):
78
82
def test_marketplace_attach (sagemaker_session ):
79
83
with timeout (minutes = 15 ):
80
84
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 )
81
88
82
89
mktplace = AlgorithmEstimator (
83
- algorithm_arn = ( ALGORITHM_ARN % sagemaker_session . boto_region_name ) ,
90
+ algorithm_arn = algorithm_arn ,
84
91
role = 'SageMakerRole' ,
85
92
train_instance_count = 1 ,
86
93
train_instance_type = 'ml.c4.xlarge' ,
@@ -116,14 +123,17 @@ def test_marketplace_attach(sagemaker_session):
116
123
117
124
@pytest .mark .canary_quick
118
125
def 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 )
119
129
120
130
def predict_wrapper (endpoint , session ):
121
131
return sagemaker .RealTimePredictor (
122
132
endpoint , session , serializer = sagemaker .predictor .csv_serializer
123
133
)
124
134
125
135
model = ModelPackage (role = 'SageMakerRole' ,
126
- model_package_arn = ( MODEL_PACKAGE_ARN % sagemaker_session . boto_region_name ) ,
136
+ model_package_arn = model_package_arn ,
127
137
sagemaker_session = sagemaker_session ,
128
138
predictor_cls = predict_wrapper )
129
139
@@ -144,9 +154,12 @@ def predict_wrapper(endpoint, session):
144
154
145
155
def test_marketplace_tuning_job (sagemaker_session ):
146
156
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 )
147
160
148
161
mktplace = AlgorithmEstimator (
149
- algorithm_arn = ( ALGORITHM_ARN % sagemaker_session . boto_region_name ) ,
162
+ algorithm_arn = algorithm_arn ,
150
163
role = 'SageMakerRole' ,
151
164
train_instance_count = 1 ,
152
165
train_instance_type = 'ml.c4.xlarge' ,
@@ -172,9 +185,12 @@ def test_marketplace_tuning_job(sagemaker_session):
172
185
173
186
def test_marketplace_transform_job (sagemaker_session ):
174
187
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 )
175
191
176
192
algo = AlgorithmEstimator (
177
- algorithm_arn = ( ALGORITHM_ARN % sagemaker_session . boto_region_name ) ,
193
+ algorithm_arn = algorithm_arn ,
178
194
role = 'SageMakerRole' ,
179
195
train_instance_count = 1 ,
180
196
train_instance_type = 'ml.c4.xlarge' ,
@@ -209,8 +225,12 @@ def test_marketplace_transform_job_from_model_package(sagemaker_session):
209
225
TRANSFORM_WORKDIR ,
210
226
key_prefix = 'integ-test-data/marketplace/transform' )
211
227
228
+ region = sagemaker_session .boto_region_name
229
+ account = REGION_ACCOUNT_MAP [region ]
230
+ model_package_arn = MODEL_PACKAGE_ARN % (region , account )
231
+
212
232
model = ModelPackage (role = 'SageMakerRole' ,
213
- model_package_arn = ( MODEL_PACKAGE_ARN % sagemaker_session . boto_region_name ) ,
233
+ model_package_arn = model_package_arn ,
214
234
sagemaker_session = sagemaker_session )
215
235
216
236
transformer = model .transformer (1 , 'ml.m4.xlarge' )
0 commit comments