Skip to content

Commit d8d4100

Browse files
authored
fix additional p2 and job/endpoint naming issues (#544)
1 parent 6555f09 commit d8d4100

17 files changed

+42
-40
lines changed

tests/integ/__init__.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,11 @@
2323
TUNING_DEFAULT_TIMEOUT_MINUTES = 20
2424
TRANSFORM_DEFAULT_TIMEOUT_MINUTES = 20
2525
PYTHON_VERSION = 'py' + str(sys.version_info.major)
26-
HOSTING_P2_UNAVAILABLE_REGIONS = ['ca-central-1', 'us-west-1', 'eu-west-2']
27-
HOSTING_P3_UNAVAILABLE_REGIONS = ['ap-southeast-1', 'ap-southeast-2', 'ap-south-1', 'ca-central-1',
28-
'eu-west-2', 'us-west-1']
26+
27+
# 'eu-central-1' has some p2, but no enough for continuous testing
28+
HOSTING_NO_P2_REGIONS = ['ca-central-1', 'eu-west-2', 'us-west-1', 'eu-central-1']
29+
HOSTING_NO_P3_REGIONS = ['ap-southeast-1', 'ap-southeast-2', 'ap-south-1', 'ca-central-1',
30+
'eu-west-2', 'us-west-1']
2931

3032
logging.getLogger('boto3').setLevel(logging.INFO)
3133
logging.getLogger('botocore').setLevel(logging.INFO)

tests/integ/test_byo_estimator.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import sagemaker
2424
from sagemaker.amazon.amazon_estimator import registry
2525
from sagemaker.estimator import Estimator
26-
from sagemaker.utils import name_from_base
26+
from sagemaker.utils import unique_name_from_base
2727
from tests.integ import DATA_DIR, TRAINING_DEFAULT_TIMEOUT_MINUTES
2828
from tests.integ.timeout import timeout, timeout_and_delete_endpoint_by_name
2929

@@ -81,7 +81,7 @@ def test_byo_estimator(sagemaker_session, region):
8181
# training labels must be 'float32'
8282
estimator.fit({'train': s3_train_data})
8383

84-
endpoint_name = name_from_base('byo')
84+
endpoint_name = unique_name_from_base('byo')
8585

8686
with timeout_and_delete_endpoint_by_name(endpoint_name, sagemaker_session):
8787
model = estimator.create_model()
@@ -99,7 +99,7 @@ def test_byo_estimator(sagemaker_session, region):
9999

100100
def test_async_byo_estimator(sagemaker_session, region):
101101
image_name = registry(region) + "/factorization-machines:1"
102-
endpoint_name = name_from_base('byo')
102+
endpoint_name = unique_name_from_base('byo')
103103
training_data_path = os.path.join(DATA_DIR, 'dummy_tensor')
104104
training_job_name = ""
105105

tests/integ/test_chainer_train.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ def test_distributed_cpu_training(sagemaker_session, chainer_full_version):
3636
_run_mnist_training_job(sagemaker_session, "ml.c4.xlarge", 2, chainer_full_version)
3737

3838

39-
@pytest.mark.skipif(tests.integ.test_region() in ['us-west-1', 'eu-west-2', 'ca-central-1'],
40-
reason='No ml.p2.xlarge supported in these regions')
39+
@pytest.mark.skipif(tests.integ.test_region() in tests.integ.HOSTING_NO_P2_REGIONS,
40+
reason='no ml.p2 instances in these regions')
4141
def test_distributed_gpu_training(sagemaker_session, chainer_full_version):
4242
_run_mnist_training_job(sagemaker_session, "ml.p2.xlarge", 2, chainer_full_version)
4343

tests/integ/test_factorization_machines.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import pytest
2222

2323
from sagemaker import FactorizationMachines, FactorizationMachinesModel
24-
from sagemaker.utils import name_from_base
24+
from sagemaker.utils import unique_name_from_base
2525
from tests.integ import DATA_DIR, TRAINING_DEFAULT_TIMEOUT_MINUTES
2626
from tests.integ.timeout import timeout, timeout_and_delete_endpoint_by_name
2727

@@ -45,7 +45,7 @@ def test_factorization_machines(sagemaker_session):
4545
# training labels must be 'float32'
4646
fm.fit(fm.record_set(train_set[0][:200], train_set[1][:200].astype('float32')))
4747

48-
endpoint_name = name_from_base('fm')
48+
endpoint_name = unique_name_from_base('fm')
4949
with timeout_and_delete_endpoint_by_name(endpoint_name, sagemaker_session):
5050
model = FactorizationMachinesModel(fm.model_data, role='SageMakerRole', sagemaker_session=sagemaker_session)
5151
predictor = model.deploy(1, 'ml.c4.xlarge', endpoint_name=endpoint_name)
@@ -58,7 +58,7 @@ def test_factorization_machines(sagemaker_session):
5858

5959
def test_async_factorization_machines(sagemaker_session):
6060
training_job_name = ""
61-
endpoint_name = name_from_base('factorizationMachines')
61+
endpoint_name = unique_name_from_base('factorizationMachines')
6262

6363
with timeout(minutes=5):
6464
data_path = os.path.join(DATA_DIR, 'one_p_mnist', 'mnist.pkl.gz')

tests/integ/test_ipinsights.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
from sagemaker import IPInsights, IPInsightsModel
1919
from sagemaker.predictor import RealTimePredictor
20-
from sagemaker.utils import name_from_base
20+
from sagemaker.utils import unique_name_from_base
2121
from tests.integ import DATA_DIR, TRAINING_DEFAULT_TIMEOUT_MINUTES
2222
from tests.integ.record_set import prepare_record_set_from_local_files
2323
from tests.integ.timeout import timeout, timeout_and_delete_endpoint_by_name
@@ -47,7 +47,7 @@ def test_ipinsights(sagemaker_session):
4747
num_records, FEATURE_DIM, sagemaker_session)
4848
ipinsights.fit(record_set, None)
4949

50-
endpoint_name = name_from_base('ipinsights')
50+
endpoint_name = unique_name_from_base('ipinsights')
5151
with timeout_and_delete_endpoint_by_name(endpoint_name, sagemaker_session):
5252
model = IPInsightsModel(ipinsights.model_data, role='SageMakerRole', sagemaker_session=sagemaker_session)
5353
predictor = model.deploy(1, 'ml.c4.xlarge', endpoint_name=endpoint_name)

tests/integ/test_kmeans.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import pytest
2222

2323
from sagemaker import KMeans, KMeansModel
24-
from sagemaker.utils import name_from_base
24+
from sagemaker.utils import unique_name_from_base
2525
from tests.integ import DATA_DIR, TRAINING_DEFAULT_TIMEOUT_MINUTES
2626
from tests.integ.timeout import timeout, timeout_and_delete_endpoint_by_name
2727

@@ -64,7 +64,7 @@ def test_kmeans(sagemaker_session):
6464

6565
kmeans.fit(kmeans.record_set(train_set[0][:100]))
6666

67-
endpoint_name = name_from_base('kmeans')
67+
endpoint_name = unique_name_from_base('kmeans')
6868
with timeout_and_delete_endpoint_by_name(endpoint_name, sagemaker_session):
6969
model = KMeansModel(kmeans.model_data, role='SageMakerRole', sagemaker_session=sagemaker_session)
7070
predictor = model.deploy(1, 'ml.c4.xlarge', endpoint_name=endpoint_name)
@@ -78,7 +78,7 @@ def test_kmeans(sagemaker_session):
7878

7979
def test_async_kmeans(sagemaker_session):
8080
training_job_name = ""
81-
endpoint_name = name_from_base('kmeans')
81+
endpoint_name = unique_name_from_base('kmeans')
8282

8383
with timeout(minutes=5):
8484
data_path = os.path.join(DATA_DIR, 'one_p_mnist', 'mnist.pkl.gz')

tests/integ/test_knn.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import pytest
2222

2323
from sagemaker import KNN, KNNModel
24-
from sagemaker.utils import name_from_base
24+
from sagemaker.utils import unique_name_from_base
2525
from tests.integ import DATA_DIR, TRAINING_DEFAULT_TIMEOUT_MINUTES
2626
from tests.integ.timeout import timeout, timeout_and_delete_endpoint_by_name
2727

@@ -44,7 +44,7 @@ def test_knn_regressor(sagemaker_session):
4444
# training labels must be 'float32'
4545
knn.fit(knn.record_set(train_set[0][:200], train_set[1][:200].astype('float32')))
4646

47-
endpoint_name = name_from_base('knn')
47+
endpoint_name = unique_name_from_base('knn')
4848
with timeout_and_delete_endpoint_by_name(endpoint_name, sagemaker_session):
4949
model = KNNModel(knn.model_data, role='SageMakerRole', sagemaker_session=sagemaker_session)
5050
predictor = model.deploy(1, 'ml.c4.xlarge', endpoint_name=endpoint_name)
@@ -57,7 +57,7 @@ def test_knn_regressor(sagemaker_session):
5757

5858
def test_async_knn_classifier(sagemaker_session):
5959
training_job_name = ""
60-
endpoint_name = name_from_base('knn')
60+
endpoint_name = unique_name_from_base('knn')
6161

6262
with timeout(minutes=5):
6363
data_path = os.path.join(DATA_DIR, 'one_p_mnist', 'mnist.pkl.gz')

tests/integ/test_lda.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
from sagemaker import LDA, LDAModel
2121
from sagemaker.amazon.common import read_records
22-
from sagemaker.utils import name_from_base
22+
from sagemaker.utils import unique_name_from_base
2323
from tests.integ import DATA_DIR, TRAINING_DEFAULT_TIMEOUT_MINUTES
2424
from tests.integ.timeout import timeout, timeout_and_delete_endpoint_by_name
2525
from tests.integ.record_set import prepare_record_set_from_local_files
@@ -44,7 +44,7 @@ def test_lda(sagemaker_session):
4444
len(all_records), feature_num, sagemaker_session)
4545
lda.fit(record_set, 100)
4646

47-
endpoint_name = name_from_base('lda')
47+
endpoint_name = unique_name_from_base('lda')
4848
with timeout_and_delete_endpoint_by_name(endpoint_name, sagemaker_session):
4949
model = LDAModel(lda.model_data, role='SageMakerRole', sagemaker_session=sagemaker_session)
5050
predictor = model.deploy(1, 'ml.c4.xlarge', endpoint_name=endpoint_name)

tests/integ/test_linear_learner.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import pytest
2323

2424
from sagemaker.amazon.linear_learner import LinearLearner, LinearLearnerModel
25-
from sagemaker.utils import name_from_base, sagemaker_timestamp
25+
from sagemaker.utils import unique_name_from_base, sagemaker_timestamp
2626
from tests.integ import DATA_DIR, TRAINING_DEFAULT_TIMEOUT_MINUTES
2727
from tests.integ.timeout import timeout, timeout_and_delete_endpoint_by_name
2828

@@ -80,7 +80,7 @@ def test_linear_learner(sagemaker_session):
8080
ll.early_stopping_patience = 3
8181
ll.fit(ll.record_set(train_set[0][:200], train_set[1][:200]))
8282

83-
endpoint_name = name_from_base('linear-learner')
83+
endpoint_name = unique_name_from_base('linear-learner')
8484
with timeout_and_delete_endpoint_by_name(endpoint_name, sagemaker_session):
8585

8686
predictor = ll.deploy(1, 'ml.c4.xlarge', endpoint_name=endpoint_name)
@@ -109,7 +109,7 @@ def test_linear_learner_multiclass(sagemaker_session):
109109
ll.epochs = 1
110110
ll.fit(ll.record_set(train_set[0][:200], train_set[1][:200]))
111111

112-
endpoint_name = name_from_base('linear-learner')
112+
endpoint_name = unique_name_from_base('linear-learner')
113113
with timeout_and_delete_endpoint_by_name(endpoint_name, sagemaker_session):
114114

115115
predictor = ll.deploy(1, 'ml.c4.xlarge', endpoint_name=endpoint_name)

tests/integ/test_ntm.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
from sagemaker import NTM, NTMModel
2121
from sagemaker.amazon.common import read_records
22-
from sagemaker.utils import name_from_base
22+
from sagemaker.utils import unique_name_from_base
2323
from tests.integ import DATA_DIR, TRAINING_DEFAULT_TIMEOUT_MINUTES
2424
from tests.integ.timeout import timeout, timeout_and_delete_endpoint_by_name
2525
from tests.integ.record_set import prepare_record_set_from_local_files
@@ -44,7 +44,7 @@ def test_ntm(sagemaker_session):
4444
len(all_records), feature_num, sagemaker_session)
4545
ntm.fit(record_set, None)
4646

47-
endpoint_name = name_from_base('ntm')
47+
endpoint_name = unique_name_from_base('ntm')
4848
with timeout_and_delete_endpoint_by_name(endpoint_name, sagemaker_session):
4949
model = NTMModel(ntm.model_data, role='SageMakerRole', sagemaker_session=sagemaker_session)
5050
predictor = model.deploy(1, 'ml.c4.xlarge', endpoint_name=endpoint_name)

tests/integ/test_object2vec.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
from sagemaker.predictor import RealTimePredictor
1919
from sagemaker import Object2Vec, Object2VecModel
20-
from sagemaker.utils import name_from_base
20+
from sagemaker.utils import unique_name_from_base
2121
from tests.integ import DATA_DIR, TRAINING_DEFAULT_TIMEOUT_MINUTES
2222
from tests.integ.timeout import timeout, timeout_and_delete_endpoint_by_name
2323
from tests.integ.record_set import prepare_record_set_from_local_files
@@ -52,7 +52,7 @@ def test_object2vec(sagemaker_session):
5252

5353
object2vec.fit(record_set, None)
5454

55-
endpoint_name = name_from_base('object2vec')
55+
endpoint_name = unique_name_from_base('object2vec')
5656

5757
with timeout_and_delete_endpoint_by_name(endpoint_name, sagemaker_session):
5858
model = Object2VecModel(object2vec.model_data, role='SageMakerRole', sagemaker_session=sagemaker_session)

tests/integ/test_pca.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import pytest
2222

2323
import sagemaker.amazon.pca
24-
from sagemaker.utils import name_from_base
24+
from sagemaker.utils import unique_name_from_base
2525
from tests.integ import DATA_DIR, TRAINING_DEFAULT_TIMEOUT_MINUTES
2626
from tests.integ.timeout import timeout, timeout_and_delete_endpoint_by_name
2727

@@ -45,7 +45,7 @@ def test_pca(sagemaker_session):
4545
pca.extra_components = 5
4646
pca.fit(pca.record_set(train_set[0][:100]))
4747

48-
endpoint_name = name_from_base('pca')
48+
endpoint_name = unique_name_from_base('pca')
4949
with timeout_and_delete_endpoint_by_name(endpoint_name, sagemaker_session):
5050
pca_model = sagemaker.amazon.pca.PCAModel(model_data=pca.model_data, role='SageMakerRole',
5151
sagemaker_session=sagemaker_session)
@@ -61,7 +61,7 @@ def test_pca(sagemaker_session):
6161

6262
def test_async_pca(sagemaker_session):
6363
training_job_name = ""
64-
endpoint_name = name_from_base('pca')
64+
endpoint_name = unique_name_from_base('pca')
6565

6666
with timeout(minutes=5):
6767
data_path = os.path.join(DATA_DIR, 'one_p_mnist', 'mnist.pkl.gz')

tests/integ/test_pytorch_train.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ def test_deploy_model(pytorch_training_job, sagemaker_session):
7575
assert output.shape == (batch_size, 10)
7676

7777

78-
@pytest.mark.skipif(tests.integ.test_region() in ['us-west-1', 'eu-west-2', 'ca-central-1'],
79-
reason='No ml.p2.xlarge supported in these regions')
78+
@pytest.mark.skipif(tests.integ.test_region() in tests.integ.HOSTING_NO_P2_REGIONS,
79+
reason='no ml.p2 instances in these regions')
8080
def test_async_fit_deploy(sagemaker_session, pytorch_full_version):
8181
training_job_name = ""
8282
# TODO: add tests against local mode when it's ready to be used

tests/integ/test_randomcutforest.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import pytest
1717

1818
from sagemaker import RandomCutForest, RandomCutForestModel
19-
from sagemaker.utils import name_from_base
19+
from sagemaker.utils import unique_name_from_base
2020
from tests.integ import TRAINING_DEFAULT_TIMEOUT_MINUTES
2121
from tests.integ.timeout import timeout, timeout_and_delete_endpoint_by_name
2222

@@ -34,7 +34,7 @@ def test_randomcutforest(sagemaker_session):
3434

3535
rcf.fit(rcf.record_set(train_input))
3636

37-
endpoint_name = name_from_base('randomcutforest')
37+
endpoint_name = unique_name_from_base('randomcutforest')
3838
with timeout_and_delete_endpoint_by_name(endpoint_name, sagemaker_session):
3939
model = RandomCutForestModel(rcf.model_data, role='SageMakerRole', sagemaker_session=sagemaker_session)
4040
predictor = model.deploy(1, 'ml.c4.xlarge', endpoint_name=endpoint_name)

tests/integ/test_tf_cifar.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ def __call__(self, data):
3737
@pytest.mark.continuous_testing
3838
@pytest.mark.skipif(tests.integ.PYTHON_VERSION != 'py2',
3939
reason="TensorFlow image supports only python 2.")
40-
@pytest.mark.skipif(tests.integ.test_region() in ['us-west-1', 'eu-west-2', 'ca-central-1'],
41-
reason='No ml.p2.xlarge supported in these regions')
40+
@pytest.mark.skipif(tests.integ.test_region() in tests.integ.HOSTING_NO_P2_REGIONS,
41+
reason='no ml.p2 instances in these regions')
4242
def test_cifar(sagemaker_session, tf_full_version):
4343
with timeout(minutes=45):
4444
script_path = os.path.join(tests.integ.DATA_DIR, 'cifar_10', 'source')

tests/integ/test_tf_keras.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
@pytest.mark.continuous_testing
2727
@pytest.mark.skipif(tests.integ.PYTHON_VERSION != 'py2',
2828
reason="TensorFlow image supports only python 2.")
29-
@pytest.mark.skipif(tests.integ.test_region() in ['us-west-1', 'eu-west-2', 'ca-central-1'],
30-
reason='No ml.p2.xlarge supported in these regions')
29+
@pytest.mark.skipif(tests.integ.test_region() in tests.integ.HOSTING_NO_P2_REGIONS,
30+
reason='no ml.p2 instances in these regions')
3131
def test_keras(sagemaker_session, tf_full_version):
3232
script_path = os.path.join(tests.integ.DATA_DIR, 'cifar_10', 'source')
3333
dataset_path = os.path.join(tests.integ.DATA_DIR, 'cifar_10', 'data')

tests/integ/test_tfs.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
'ml.c5.xlarge',
2727
pytest.param('ml.p3.2xlarge',
2828
marks=pytest.mark.skipif(
29-
tests.integ.test_region() in tests.integ.HOSTING_P3_UNAVAILABLE_REGIONS,
29+
tests.integ.test_region() in tests.integ.HOSTING_NO_P3_REGIONS,
3030
reason='no ml.p3 instances in this region'))])
3131
def instance_type(request):
3232
return request.param

0 commit comments

Comments
 (0)