Skip to content

Commit 129bdb3

Browse files
authored
Add region account map to marketplace test for canary (aws#688)
1 parent 341ea36 commit 129bdb3

File tree

2 files changed

+57
-8
lines changed

2 files changed

+57
-8
lines changed

tests/integ/marketplace_utils.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License"). You
4+
# may not use this file except in compliance with the License. A copy of
5+
# the License is located at
6+
#
7+
# http://aws.amazon.com/apache2.0/
8+
#
9+
# or in the "license" file accompanying this file. This file is
10+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11+
# ANY KIND, either express or implied. See the License for the specific
12+
# language governing permissions and limitations under the License.
13+
from __future__ import absolute_import
14+
15+
REGION_ACCOUNT_MAP = {
16+
'us-east-1': '865070037744',
17+
'us-east-2': '057799348421',
18+
'us-west-2': '594846645681',
19+
'eu-west-1': '985815980388',
20+
'eu-central-1': '446921602837',
21+
'ap-northeast-1': '977537786026',
22+
'ap-northeast-2': '745090734665',
23+
'ap-southeast-2': '666831318237',
24+
'ap-southeast-1': '192199979996',
25+
'ap-south-1': '077584701553',
26+
'ca-central-1': '470592106596',
27+
'eu-west-2': '856760150666',
28+
'us-west-1': '382657785993'
29+
}

tests/integ/test_marketplace.py

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
from sagemaker.utils import sagemaker_timestamp
2626
from tests.integ import DATA_DIR
2727
from 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:
@@ -36,20 +37,23 @@
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
4748
def 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):
7882
def 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
118125
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)
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

145155
def 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

173186
def 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

Comments
 (0)