Skip to content

Commit be84420

Browse files
authored
Merge branch 'master' into migrate-sklearn
2 parents d16f3d5 + 3816a56 commit be84420

32 files changed

+83
-70
lines changed

.travis.yml

Lines changed: 0 additions & 10 deletions
This file was deleted.

CHANGELOG.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ CHANGELOG
1515
* bug-fix: pass accelerator_type in ``deploy`` for REST API TFS ``Model``
1616
* doc-fix: move content from tf/README.rst into sphynx project
1717
* doc-fix: move content from sklearn/README.rst into sphynx project
18+
* doc-fix: Improve new developer experience in README
1819

1920
1.18.3.post1
2021
============

README.rst

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,16 @@ Running tests
9797

9898
SageMaker Python SDK has unit tests and integration tests.
9999

100+
You can install the libraries needed to run the tests by running :code:`pip install --upgrade .[test]` or, for Zsh users: :code:`pip install --upgrade .\[test\]`
101+
100102
**Unit tests**
101103

102-
tox is a prerequisite for running unit tests so you need to make sure you have it installed. To run the unit tests:
104+
105+
We run unit tests with tox, which is a program that lets you run unit tests for multiple Python versions, and also make sure the
106+
code fits our style guidelines. We run tox with Python 2.7 and 3.6, so to run unit tests
107+
with the same configuration we do, you'll need to have interpreters for Python 2.7 and Python 3.6 installed.
108+
109+
To run the unit tests with tox, run:
103110

104111
::
105112

@@ -109,23 +116,29 @@ tox is a prerequisite for running unit tests so you need to make sure you have i
109116

110117
To run the integration tests, the following prerequisites must be met
111118

112-
1. Access to an AWS account to run the tests on
113-
2. AWS account credentials available to boto3 clients used in the tests
114-
3. The AWS account has an IAM role named :code:`SageMakerRole`
115-
4. The libraries listed in the ``extras_require`` object in ``setup.py`` for ``test`` are installed.
116-
You can do this by running the following command: :code:`pip install --upgrade .[test]`
119+
1. AWS account credentials are available in the environment for the boto3 client to use.
120+
2. The AWS account has an IAM role named :code:`SageMakerRole` with the AmazonSageMakerFullAccess policy attached.
121+
122+
We recommend selectively running just those integration tests you'd like to run. You can filter by individual test function names with:
123+
124+
::
125+
126+
pytest -k 'test_i_care_about'
127+
117128

118-
You can run integ tests by issuing the following command:
129+
You can also run all of the integration tests by running the following command, which runs them in sequence, which may take a while:
119130

120131
::
121132

122133
pytest tests/integ
123134

124-
You can also filter by individual test function names (usable with any of the previous commands):
135+
136+
You can also run them in parallel:
125137

126138
::
127139

128-
pytest -k 'test_i_care_about'
140+
pytest -n auto tests/integ
141+
129142

130143
Building Sphinx docs
131144
~~~~~~~~~~~~~~~~~~~~

buildspec.yml

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,33 @@ phases:
1919
AWS_CONTAINER_CREDENTIALS_RELATIVE_URI= AWS_DEFAULT_REGION=
2020
tox -e py27,py36 -- tests/unit
2121

22+
# run notebook test
23+
- |
24+
if has-matching-changes "src/*.py" "setup.py" "setup.cfg"; then
25+
echo "running notebook test"
26+
python setup.py sdist
27+
aws s3 --region us-west-2 cp ./dist/sagemaker-*.tar.gz s3://sagemaker-python-sdk-pr/
28+
aws s3 cp s3://sagemaker-mead-cli/mead-nb-test.tar.gz mead-nb-test.tar.gz
29+
tar -xzf mead-nb-test.tar.gz
30+
git clone --depth 1 https://github.com/awslabs/amazon-sagemaker-examples.git
31+
JAVA_HOME=$(get-java-home)
32+
echo "set JAVA_HOME=$JAVA_HOME"
33+
SAGEMAKER_ROLE_ARN=$(get-sagemaker-role-arn)
34+
echo "set SAGEMAKER_ROLE_ARN=$SAGEMAKER_ROLE_ARN"
35+
./runtime/bin/mead-run-nb-test \
36+
--instance-type ml.c4.8xlarge \
37+
--region us-west-2 \
38+
--lifecycle-config-name install-python-sdk \
39+
--notebook-instance-role-arn $SAGEMAKER_ROLE_ARN \
40+
./amazon-sagemaker-examples/sagemaker-python-sdk/tensorflow_distributed_mnist/tensorflow_batch_transform_mnist.ipynb
41+
else
42+
echo "skipping notebook test"
43+
fi
44+
2245
# run integration tests
23-
- if-matching-changes "test/" "tests/" "src/*.py" "docker/*/Dockerfile" &&
24-
IGNORE_COVERAGE=- tox -e py27,py36 -- -n 24 --boxed tests/integ
46+
- |
47+
if has-matching-changes "tests/" "src/*.py" "setup.py" "setup.cfg"; then
48+
IGNORE_COVERAGE=- tox -e py27,py36 -- -n 24 --boxed tests/integ
49+
else
50+
echo "skipping integration tests"
51+
fi

tests/integ/test_byo_estimator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def fm_serializer(data):
4040
return json.dumps(js)
4141

4242

43-
@pytest.mark.continuous_testing
43+
@pytest.mark.canary_quick
4444
def test_byo_estimator(sagemaker_session, region):
4545
"""Use Factorization Machines algorithm as an example here.
4646

tests/integ/test_chainer_train.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def test_training_with_additional_hyperparameters(sagemaker_session, chainer_ful
6666
return chainer.latest_training_job.name
6767

6868

69-
@pytest.mark.continuous_testing
69+
@pytest.mark.canary_quick
7070
@pytest.mark.regional_testing
7171
def test_attach_deploy(chainer_training_job, sagemaker_session):
7272
endpoint_name = 'test-chainer-attach-deploy-{}'.format(sagemaker_timestamp())

tests/integ/test_factorization_machines.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,12 @@
1818
import sys
1919
import time
2020

21-
import pytest
22-
2321
from sagemaker import FactorizationMachines, FactorizationMachinesModel
2422
from sagemaker.utils import unique_name_from_base
2523
from tests.integ import DATA_DIR, TRAINING_DEFAULT_TIMEOUT_MINUTES
2624
from tests.integ.timeout import timeout, timeout_and_delete_endpoint_by_name
2725

2826

29-
@pytest.mark.continuous_testing
3027
def test_factorization_machines(sagemaker_session):
3128
with timeout(minutes=TRAINING_DEFAULT_TIMEOUT_MINUTES):
3229
data_path = os.path.join(DATA_DIR, 'one_p_mnist', 'mnist.pkl.gz')

tests/integ/test_horovod.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
horovod_dir = os.path.join(os.path.dirname(__file__), '..', 'data', 'horovod')
2828

2929

30+
@pytest.mark.canary_quick
3031
@pytest.mark.parametrize('instance_type', ['ml.c5.xlarge', 'ml.p3.2xlarge'])
3132
def test_horovod(sagemaker_session, instance_type, tmpdir):
3233

tests/integ/test_inference_pipeline.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
from sagemaker.utils import sagemaker_timestamp
2929

3030

31-
@pytest.mark.continuous_testing
31+
@pytest.mark.canary_quick
3232
@pytest.mark.regional_testing
3333
def test_inference_pipeline_model_deploy(sagemaker_session):
3434
sparkml_data_path = os.path.join(DATA_DIR, 'sparkml_model')

tests/integ/test_ipinsights.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
from __future__ import absolute_import
1414

1515
import os
16-
import pytest
1716

1817
from sagemaker import IPInsights, IPInsightsModel
1918
from sagemaker.predictor import RealTimePredictor
@@ -25,7 +24,6 @@
2524
FEATURE_DIM = None
2625

2726

28-
@pytest.mark.continuous_testing
2927
def test_ipinsights(sagemaker_session):
3028
with timeout(minutes=TRAINING_DEFAULT_TIMEOUT_MINUTES):
3129
data_path = os.path.join(DATA_DIR, 'ipinsights')

tests/integ/test_kmeans.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
from tests.integ.timeout import timeout, timeout_and_delete_endpoint_by_name
2727

2828

29-
@pytest.mark.continuous_testing
3029
def test_kmeans(sagemaker_session):
3130
with timeout(minutes=TRAINING_DEFAULT_TIMEOUT_MINUTES):
3231
data_path = os.path.join(DATA_DIR, 'one_p_mnist', 'mnist.pkl.gz')

tests/integ/test_knn.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,12 @@
1818
import sys
1919
import time
2020

21-
import pytest
22-
2321
from sagemaker import KNN, KNNModel
2422
from sagemaker.utils import unique_name_from_base
2523
from tests.integ import DATA_DIR, TRAINING_DEFAULT_TIMEOUT_MINUTES
2624
from tests.integ.timeout import timeout, timeout_and_delete_endpoint_by_name
2725

2826

29-
@pytest.mark.continuous_testing
3027
def test_knn_regressor(sagemaker_session):
3128
with timeout(minutes=TRAINING_DEFAULT_TIMEOUT_MINUTES):
3229
data_path = os.path.join(DATA_DIR, 'one_p_mnist', 'mnist.pkl.gz')

tests/integ/test_lda.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import os
1616

1717
import numpy as np
18-
import pytest
1918

2019
from sagemaker import LDA, LDAModel
2120
from sagemaker.amazon.common import read_records
@@ -25,7 +24,6 @@
2524
from tests.integ.record_set import prepare_record_set_from_local_files
2625

2726

28-
@pytest.mark.continuous_testing
2927
def test_lda(sagemaker_session):
3028
with timeout(minutes=TRAINING_DEFAULT_TIMEOUT_MINUTES):
3129
data_path = os.path.join(DATA_DIR, 'lda')

tests/integ/test_linear_learner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
from tests.integ.timeout import timeout, timeout_and_delete_endpoint_by_name
2828

2929

30-
@pytest.mark.continuous_testing
30+
@pytest.mark.canary_quick
3131
def test_linear_learner(sagemaker_session):
3232
with timeout(minutes=TRAINING_DEFAULT_TIMEOUT_MINUTES):
3333
data_path = os.path.join(DATA_DIR, 'one_p_mnist', 'mnist.pkl.gz')

tests/integ/test_marketplace.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import time
1818

1919
import pandas
20+
import pytest
2021

2122
import sagemaker
2223
from sagemaker import AlgorithmEstimator, ModelPackage
@@ -42,6 +43,7 @@
4243
'154230595-8f00905c1f927a512b73ea29dd09ae30'
4344

4445

46+
@pytest.mark.canary_quick
4547
def test_marketplace_estimator(sagemaker_session):
4648
with timeout(minutes=15):
4749
data_path = os.path.join(DATA_DIR, 'marketplace', 'training')
@@ -112,6 +114,7 @@ def test_marketplace_attach(sagemaker_session):
112114
print(predictor.predict(test_x.values).decode('utf-8'))
113115

114116

117+
@pytest.mark.canary_quick
115118
def test_marketplace_model(sagemaker_session):
116119

117120
def predict_wrapper(endpoint, session):

tests/integ/test_mxnet_train.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def mxnet_training_job(sagemaker_session, mxnet_full_version):
4545
return mx.latest_training_job.name
4646

4747

48-
@pytest.mark.continuous_testing
48+
@pytest.mark.canary_quick
4949
@pytest.mark.regional_testing
5050
def test_attach_deploy(mxnet_training_job, sagemaker_session):
5151
endpoint_name = 'test-mxnet-attach-deploy-{}'.format(sagemaker_timestamp())
@@ -122,7 +122,7 @@ def test_deploy_model_with_update_non_existing_endpoint(mxnet_training_job, sage
122122
model.deploy(1, 'ml.m4.xlarge', update_endpoint=True, endpoint_name='non-existing-endpoint')
123123

124124

125-
@pytest.mark.continuous_testing
125+
@pytest.mark.canary_quick
126126
@pytest.mark.regional_testing
127127
@pytest.mark.skipif(tests.integ.test_region() not in tests.integ.EI_SUPPORTED_REGIONS,
128128
reason="EI isn't supported in that specific region.")

tests/integ/test_neo_mxnet.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def mxnet_training_job(sagemaker_session, mxnet_full_version):
4444
return mx.latest_training_job.name
4545

4646

47-
@pytest.mark.continuous_testing
47+
@pytest.mark.canary_quick
4848
@pytest.mark.regional_testing
4949
@pytest.mark.skip(reason="This should be enabled along with the Boto SDK release for Neo API changes")
5050
def test_attach_deploy(mxnet_training_job, sagemaker_session):

tests/integ/test_ntm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
from tests.integ.record_set import prepare_record_set_from_local_files
2626

2727

28-
@pytest.mark.continuous_testing
28+
@pytest.mark.canary_quick
2929
def test_ntm(sagemaker_session):
3030
with timeout(minutes=TRAINING_DEFAULT_TIMEOUT_MINUTES):
3131
data_path = os.path.join(DATA_DIR, 'ntm')

tests/integ/test_object2vec.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
from __future__ import absolute_import
1414

1515
import os
16-
import pytest
1716

1817
from sagemaker.predictor import RealTimePredictor
1918
from sagemaker import Object2Vec, Object2VecModel
@@ -26,7 +25,6 @@
2625
FEATURE_NUM = None
2726

2827

29-
@pytest.mark.continuous_testing
3028
def test_object2vec(sagemaker_session):
3129
with timeout(minutes=TRAINING_DEFAULT_TIMEOUT_MINUTES):
3230
data_path = os.path.join(DATA_DIR, 'object2vec')

tests/integ/test_pca.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,12 @@
1818
import sys
1919
import time
2020

21-
import pytest
22-
2321
import sagemaker.amazon.pca
2422
from sagemaker.utils import unique_name_from_base
2523
from tests.integ import DATA_DIR, TRAINING_DEFAULT_TIMEOUT_MINUTES
2624
from tests.integ.timeout import timeout, timeout_and_delete_endpoint_by_name
2725

2826

29-
@pytest.mark.continuous_testing
3027
def test_pca(sagemaker_session):
3128
with timeout(minutes=TRAINING_DEFAULT_TIMEOUT_MINUTES):
3229
data_path = os.path.join(DATA_DIR, 'one_p_mnist', 'mnist.pkl.gz')

tests/integ/test_pytorch_train.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def fixture_training_job(sagemaker_session, pytorch_full_version):
3939
return pytorch.latest_training_job.name
4040

4141

42-
@pytest.mark.continuous_testing
42+
@pytest.mark.canary_quick
4343
@pytest.mark.regional_testing
4444
def test_sync_fit_deploy(pytorch_training_job, sagemaker_session):
4545
# TODO: add tests against local mode when it's ready to be used

tests/integ/test_randomcutforest.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,13 @@
1313
from __future__ import absolute_import
1414

1515
import numpy as np
16-
import pytest
1716

1817
from sagemaker import RandomCutForest, RandomCutForestModel
1918
from sagemaker.utils import unique_name_from_base
2019
from tests.integ import TRAINING_DEFAULT_TIMEOUT_MINUTES
2120
from tests.integ.timeout import timeout, timeout_and_delete_endpoint_by_name
2221

2322

24-
@pytest.mark.continuous_testing
2523
def test_randomcutforest(sagemaker_session):
2624
with timeout(minutes=TRAINING_DEFAULT_TIMEOUT_MINUTES):
2725
# Generate a thousand 14-dimensional datapoints.

tests/integ/test_rl.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
CPU_INSTANCE = 'ml.m4.xlarge'
2626

2727

28-
@pytest.mark.continuous_testing
28+
@pytest.mark.canary_quick
2929
@pytest.mark.skipif(PYTHON_VERSION != 'py3', reason="RL images supports only Python 3.")
3030
def test_coach_mxnet(sagemaker_session, rl_coach_full_version):
3131
estimator = _test_coach(sagemaker_session, RLFramework.MXNET, rl_coach_full_version)
@@ -89,7 +89,7 @@ def _test_coach(sagemaker_session, rl_framework, rl_coach_version):
8989
})
9090

9191

92-
@pytest.mark.continuous_testing
92+
@pytest.mark.canary_quick
9393
@pytest.mark.skipif(PYTHON_VERSION != 'py3', reason="RL images supports only Python 3.")
9494
def test_ray_tf(sagemaker_session, rl_ray_full_version):
9595
source_dir = os.path.join(DATA_DIR, 'ray_cartpole')

tests/integ/test_sklearn_train.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def test_training_with_additional_hyperparameters(sagemaker_session, sklearn_ful
5454
return sklearn.latest_training_job.name
5555

5656

57-
@pytest.mark.continuous_testing
57+
@pytest.mark.canary_quick
5858
@pytest.mark.regional_testing
5959
@pytest.mark.skipif(PYTHON_VERSION != 'py3', reason="Scikit-learn image supports only python 3.")
6060
def test_attach_deploy(sklearn_training_job, sagemaker_session):

tests/integ/test_sparkml_serving.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from tests.integ.timeout import timeout_and_delete_endpoint_by_name
2424

2525

26-
@pytest.mark.continuous_testing
26+
@pytest.mark.canary_quick
2727
@pytest.mark.regional_testing
2828
def test_sparkml_model_deploy(sagemaker_session):
2929
# Uploads an MLeap serialized MLeap model to S3 and use that to deploy a SparkML model to perform inference

tests/integ/test_tf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def tf_training_job(sagemaker_session, tf_full_version):
5252
return estimator.latest_training_job.name
5353

5454

55-
@pytest.mark.continuous_testing
55+
@pytest.mark.canary_quick
5656
@pytest.mark.regional_testing
5757
@pytest.mark.skipif(PYTHON_VERSION != 'py2', reason="TensorFlow image supports only python 2.")
5858
def test_deploy_model(sagemaker_session, tf_training_job):
@@ -78,7 +78,7 @@ def test_deploy_model(sagemaker_session, tf_training_job):
7878
assert dict_result == list_result
7979

8080

81-
@pytest.mark.continuous_testing
81+
@pytest.mark.canary_quick
8282
@pytest.mark.regional_testing
8383
@pytest.mark.skipif(tests.integ.test_region() not in tests.integ.EI_SUPPORTED_REGIONS,
8484
reason="EI isn't supported in that specific region.")

0 commit comments

Comments
 (0)