Skip to content

Commit db1876d

Browse files
authored
update sdk for new re:invent 2018 features
2 parents d8c055b + 7fad99e commit db1876d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+7427
-349
lines changed

CHANGELOG.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,24 @@
22
CHANGELOG
33
=========
44

5+
1.16.1
6+
======
7+
8+
* feature: update boto3 to version 1.9.55
9+
10+
1.16.0
11+
======
12+
13+
* feature: Add 0.10.1 coach version
14+
* feature: Add support for SageMaker Neo
15+
* feature: Estimators: Add RLEstimator to provide support for Reinforcement Learning
16+
* feature: Add support for Amazon Elastic Inference
17+
* feature: Add support for Algorithm Estimators and ModelPackages: includes support for AWS Marketplace
18+
* feature: Add SKLearn Estimator to provide support for SciKit Learn
19+
* feature: Add Amazon SageMaker Semantic Segmentation algorithm to the registry
20+
* feature: Add support for SageMaker Inference Pipelines
21+
* feature: Add support for SparkML serving container
22+
523
1.15.2
624
======
725

README.rst

Lines changed: 136 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,17 @@ Table of Contents
3232
4. `TensorFlow SageMaker Estimators <#tensorflow-sagemaker-estimators>`__
3333
5. `Chainer SageMaker Estimators <#chainer-sagemaker-estimators>`__
3434
6. `PyTorch SageMaker Estimators <#pytorch-sagemaker-estimators>`__
35-
7. `AWS SageMaker Estimators <#aws-sagemaker-estimators>`__
36-
8. `BYO Docker Containers with SageMaker Estimators <#byo-docker-containers-with-sagemaker-estimators>`__
37-
9. `SageMaker Automatic Model Tuning <#sagemaker-automatic-model-tuning>`__
38-
10. `SageMaker Batch Transform <#sagemaker-batch-transform>`__
39-
11. `Secure Training and Inference with VPC <#secure-training-and-inference-with-vpc>`__
40-
12. `BYO Model <#byo-model>`__
41-
13. `SageMaker Workflow <#sagemaker-workflow>`__
35+
7. `SageMaker SparkML Serving <#sagemaker-sparkml-serving>`__
36+
8. `AWS SageMaker Estimators <#aws-sagemaker-estimators>`__
37+
9. `Using SageMaker AlgorithmEstimators <#using-sagemaker-algorithmestimators>`__
38+
10. `Consuming SageMaker Model Packages <#consuming-sagemaker-model-packages>`__
39+
11. `BYO Docker Containers with SageMaker Estimators <#byo-docker-containers-with-sagemaker-estimators>`__
40+
12. `SageMaker Automatic Model Tuning <#sagemaker-automatic-model-tuning>`__
41+
13. `SageMaker Batch Transform <#sagemaker-batch-transform>`__
42+
14. `Secure Training and Inference with VPC <#secure-training-and-inference-with-vpc>`__
43+
15. `BYO Model <#byo-model>`__
44+
16. `Inference Pipelines <#inference-pipelines>`__
45+
17. `SageMaker Workflow <#sagemaker-workflow>`__
4246

4347

4448
Installing the SageMaker Python SDK
@@ -342,7 +346,7 @@ Currently, the following algorithms support incremental training:
342346
343347
- Image Classification
344348
- Object Detection
345-
- Semantics Segmentation
349+
- Semantic Segmentation
346350
347351
348352
MXNet SageMaker Estimators
@@ -374,7 +378,7 @@ For more information, see `TensorFlow SageMaker Estimators and Models`_.
374378
375379
376380
Chainer SageMaker Estimators
377-
-------------------------------
381+
----------------------------
378382
379383
By using Chainer SageMaker ``Estimators``, you can train and host Chainer models on Amazon SageMaker.
380384
@@ -390,7 +394,7 @@ For more information about Chainer SageMaker ``Estimators``, see `Chainer SageM
390394
391395
392396
PyTorch SageMaker Estimators
393-
-------------------------------
397+
----------------------------
394398
395399
With PyTorch SageMaker ``Estimators``, you can train and host PyTorch models on Amazon SageMaker.
396400
@@ -408,6 +412,39 @@ For more information about PyTorch SageMaker ``Estimators``, see `PyTorch SageMa
408412
.. _PyTorch SageMaker Estimators and Models: src/sagemaker/pytorch/README.rst
409413
410414
415+
SageMaker SparkML Serving
416+
-------------------------
417+
418+
With SageMaker SparkML Serving, you can now perform predictions against a SparkML Model in SageMaker.
419+
In order to host a SparkML model in SageMaker, it should be serialized with ``MLeap`` library.
420+
421+
For more information on MLeap, see https://github.com/combust/mleap .
422+
423+
Supported major version of Spark: 2.2 (MLeap version - 0.9.6)
424+
425+
Here is an example on how to create an instance of ``SparkMLModel`` class and use ``deploy()`` method to create an
426+
endpoint which can be used to perform prediction against your trained SparkML Model.
427+
428+
.. code:: python
429+
430+
sparkml_model = SparkMLModel(model_data='s3://path/to/model.tar.gz', env={'SAGEMAKER_SPARKML_SCHEMA': schema})
431+
model_name = 'sparkml-model'
432+
endpoint_name = 'sparkml-endpoint'
433+
predictor = sparkml_model.deploy(initial_instance_count=1, instance_type='ml.c4.xlarge', endpoint_name=endpoint_name)
434+
435+
Once the model is deployed, we can invoke the endpoint with a ``CSV`` payload like this:
436+
437+
.. code:: python
438+
439+
payload = 'field_1,field_2,field_3,field_4,field_5'
440+
predictor.predict(payload)
441+
442+
443+
For more information about the different ``content-type`` and ``Accept`` formats as well as the structure of the
444+
``schema`` that SageMaker SparkML Serving recognizes, please see `SageMaker SparkML Serving Container`_.
445+
446+
.. _SageMaker SparkML Serving Container: https://github.com/aws/sagemaker-sparkml-serving-container
447+
411448
AWS SageMaker Estimators
412449
------------------------
413450
Amazon SageMaker provides several built-in machine learning algorithms that you can use to solve a variety of problems.
@@ -421,6 +458,59 @@ For more information, see `AWS SageMaker Estimators and Models`_.
421458
422459
.. _AWS SageMaker Estimators and Models: src/sagemaker/amazon/README.rst
423460
461+
Using SageMaker AlgorithmEstimators
462+
-----------------------------------
463+
464+
With the SageMaker Algorithm entities, you can create training jobs with just an ``algorithm_arn`` instead of
465+
a training image. There is a dedicated ``AlgorithmEstimator`` class that accepts ``algorithm_arn`` as a
466+
parameter, the rest of the arguments are similar to the other Estimator classes. This class also allows you to
467+
consume algorithms that you have subscribed to in the AWS Marketplace. The AlgorithmEstimator performs
468+
client-side validation on your inputs based on the algorithm's properties.
469+
470+
Here is an example:
471+
472+
.. code:: python
473+
474+
import sagemaker
475+
476+
algo = sagemaker.AlgorithmEstimator(
477+
algorithm_arn='arn:aws:sagemaker:us-west-2:1234567:algorithm/some-algorithm',
478+
role='SageMakerRole',
479+
train_instance_count=1,
480+
train_instance_type='ml.c4.xlarge')
481+
482+
train_input = algo.sagemaker_session.upload_data(path='/path/to/your/data')
483+
484+
algo.fit({'training': train_input})
485+
algo.deploy(1, 'ml.m4.xlarge')
486+
487+
# When you are done using your endpoint
488+
algo.delete_endpoint()
489+
490+
491+
Consuming SageMaker Model Packages
492+
----------------------------------
493+
494+
SageMaker Model Packages are a way to specify and share information for how to create SageMaker Models.
495+
With a SageMaker Model Package that you have created or subscribed to in the AWS Marketplace,
496+
you can use the specified serving image and model data for Endpoints and Batch Transform jobs.
497+
498+
To work with a SageMaker Model Package, use the ``ModelPackage`` class.
499+
500+
Here is an example:
501+
502+
.. code:: python
503+
504+
import sagemaker
505+
506+
model = sagemaker.ModelPackage(
507+
role='SageMakerRole',
508+
model_package_arn='arn:aws:sagemaker:us-west-2:123456:model-package/my-model-package')
509+
model.deploy(1, 'ml.m4.xlarge', endpoint_name='my-endpoint')
510+
511+
# When you are done using your endpoint
512+
model.sagemaker_session.delete_endpoint('my-endpoint')
513+
424514
425515
BYO Docker Containers with SageMaker Estimators
426516
-----------------------------------------------
@@ -435,7 +525,7 @@ Please refer to the full example in the examples repo:
435525
git clone https://github.com/awslabs/amazon-sagemaker-examples.git
436526
437527
438-
The example notebook is is located here:
528+
The example notebook is located here:
439529
``advanced_functionality/scikit_bring_your_own/scikit_bring_your_own.ipynb``
440530
441531
@@ -709,11 +799,45 @@ This returns a predictor the same way an ``Estimator`` does when ``deploy()`` is
709799
A full example is available in the `Amazon SageMaker examples repository <https://github.com/awslabs/amazon-sagemaker-examples/tree/master/advanced_functionality/mxnet_mnist_byom>`__.
710800
711801
802+
Inference Pipelines
803+
-------------------
804+
You can create a Pipeline for realtime or batch inference comprising of one or multiple model containers. This will help
805+
you to deploy an ML pipeline behind a single endpoint and you can have one API call perform pre-processing, model-scoring
806+
and post-processing on your data before returning it back as the response.
807+
808+
For this, you have to create a ``PipelineModel`` which will take a list of ``Model`` objects. Calling ``deploy()`` on the
809+
``PipelineModel`` will provide you with an endpoint which can be invoked to perform the prediction on a data point against
810+
the ML Pipeline.
811+
812+
.. code:: python
813+
814+
xgb_image = get_image_uri(sess.boto_region_name, 'xgboost', repo_version="latest")
815+
xgb_model = Model(model_data='s3://path/to/model.tar.gz', image=xgb_image)
816+
sparkml_model = SparkMLModel(model_data='s3://path/to/model.tar.gz', env={'SAGEMAKER_SPARKML_SCHEMA': schema})
817+
818+
model_name = 'inference-pipeline-model'
819+
endpoint_name = 'inference-pipeline-endpoint'
820+
sm_model = PipelineModel(name=model_name, role=sagemaker_role, models=[sparkml_model, xgb_model])
821+
822+
This will define a ``PipelineModel`` consisting of SparkML model and an XGBoost model stacked sequentially. For more
823+
information about how to train an XGBoost model, please refer to the XGBoost notebook here_.
824+
825+
.. _here: https://docs.aws.amazon.com/sagemaker/latest/dg/xgboost.html#xgboost-sample-notebooks
826+
827+
.. code:: python
828+
829+
sm_model.deploy(initial_instance_count=1, instance_type='ml.c5.xlarge', endpoint_name=endpoint_name)
830+
831+
This returns a predictor the same way an ``Estimator`` does when ``deploy()`` is called. Whenever you make an inference
832+
request using this predictor, you should pass the data that the first container expects and the predictor will return the
833+
output from the last container.
834+
835+
712836
SageMaker Workflow
713837
------------------
714838
715839
You can use Apache Airflow to author, schedule and monitor SageMaker workflow.
716840
717841
For more information, see `SageMaker Workflow in Apache Airflow`_.
718842
719-
.. _SageMaker Workflow in Apache Airflow: src/sagemaker/workflow/README.rst
843+
.. _SageMaker Workflow in Apache Airflow: src/sagemaker/workflow/README.rst

doc/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def __getattr__(cls, name):
3232
'numpy', 'scipy', 'scipy.sparse']
3333
sys.modules.update((mod_name, Mock()) for mod_name in MOCK_MODULES)
3434

35-
version = '1.15.2'
35+
version = '1.16.1'
3636
project = u'sagemaker'
3737

3838
# Add any Sphinx extension module names here, as strings. They can be extensions

doc/index.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,15 @@ A managed environment for TensorFlow training and hosting on Amazon SageMaker
3939

4040
sagemaker.tensorflow
4141

42+
Reinforcement Learning
43+
----------------------
44+
A managed environment for Reinforcement Learning training and hosting on Amazon SageMaker
45+
46+
.. toctree::
47+
:maxdepth: 2
48+
49+
sagemaker.rl
50+
4251
SageMaker First-Party Algorithms
4352
--------------------------------
4453
Amazon provides implementations of some common machine learning algortithms optimized for GPU architecture and massive datasets.

doc/pipeline.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
PipelineModel
2+
-------------
3+
4+
.. autoclass:: sagemaker.pipeline.PipelineModel
5+
:members:
6+
:undoc-members:
7+
:show-inheritance:

doc/sagemaker.sparkml.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
SparkML Serving
2+
===============
3+
4+
SparkML Model
5+
-------------
6+
7+
.. autoclass:: sagemaker.sparkml.model.SparkMLModel
8+
:members:
9+
:undoc-members:
10+
:show-inheritance:
11+
12+
SparkML Predictor
13+
-----------------
14+
15+
.. autoclass:: sagemaker.sparkml.model.SparkMLPredictor
16+
:members:
17+
:undoc-members:
18+
:show-inheritance:

setup.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import os
1616
import re
1717
from glob import glob
18+
import sys
1819

1920
from setuptools import setup, find_packages
2021

@@ -31,12 +32,21 @@ def read(fname):
3132
return open(os.path.join(os.path.dirname(__file__), fname)).read()
3233

3334

35+
# Declare minimal set for installation
36+
required_packages = ['boto3>=1.9.55', 'numpy>=1.9.0', 'protobuf>=3.1', 'scipy>=0.19.0',
37+
'urllib3>=1.21', 'PyYAML>=3.2', 'protobuf3-to-dict>=0.1.5',
38+
'docker-compose>=1.23.0']
39+
40+
# enum is introduced in Python 3.4. Installing enum back port
41+
if sys.version_info < (3, 4):
42+
required_packages.append('enum34>=1.1.6')
43+
3444
setup(name="sagemaker",
3545
version=get_version(),
3646
description="Open source library for training and deploying models on Amazon SageMaker.",
3747
packages=find_packages('src'),
3848
package_dir={'': 'src'},
39-
py_modules=[os.splitext(os.basename(path))[0] for path in glob('src/*.py')],
49+
py_modules=[os.path.splitext(os.path.basename(path))[0] for path in glob('src/*.py')],
4050
long_description=read('README.rst'),
4151
author="Amazon Web Services",
4252
url='https://github.com/aws/sagemaker-python-sdk/',
@@ -52,10 +62,7 @@ def read(fname):
5262
"Programming Language :: Python :: 3.5",
5363
],
5464

55-
# Declare minimal set for installation
56-
install_requires=['boto3>=1.9.45', 'numpy>=1.9.0', 'protobuf>=3.1', 'scipy>=0.19.0',
57-
'urllib3 >=1.21', 'PyYAML>=3.2', 'protobuf3-to-dict>=0.1.5',
58-
'docker-compose>=1.23.0'],
65+
install_requires=required_packages,
5966

6067
extras_require={
6168
'test': ['tox', 'flake8', 'pytest', 'pytest-cov', 'pytest-xdist',

src/sagemaker/__init__.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# language governing permissions and limitations under the License.
1313
from __future__ import absolute_import
1414

15-
from sagemaker import estimator # noqa: F401
15+
from sagemaker import estimator, parameter # noqa: F401
1616
from sagemaker.amazon.kmeans import KMeans, KMeansModel, KMeansPredictor # noqa: F401
1717
from sagemaker.amazon.pca import PCA, PCAModel, PCAPredictor # noqa: F401
1818
from sagemaker.amazon.lda import LDA, LDAModel, LDAPredictor # noqa: F401
@@ -26,15 +26,17 @@
2626
from sagemaker.amazon.object2vec import Object2Vec, Object2VecModel # noqa: F401
2727
from sagemaker.amazon.ipinsights import IPInsights, IPInsightsModel, IPInsightsPredictor # noqa: F401
2828

29+
from sagemaker.algorithm import AlgorithmEstimator # noqa: F401
2930
from sagemaker.analytics import TrainingJobAnalytics, HyperparameterTuningJobAnalytics # noqa: F401
3031
from sagemaker.local.local_session import LocalSession # noqa: F401
3132

32-
from sagemaker.model import Model # noqa: F401
33+
from sagemaker.model import Model, ModelPackage # noqa: F401
34+
from sagemaker.pipeline import PipelineModel # noqa: F401
3335
from sagemaker.predictor import RealTimePredictor # noqa: F401
3436
from sagemaker.session import Session # noqa: F401
35-
from sagemaker.session import container_def # noqa: F401
37+
from sagemaker.session import container_def, pipeline_container_def # noqa: F401
3638
from sagemaker.session import production_variant # noqa: F401
3739
from sagemaker.session import s3_input # noqa: F401
3840
from sagemaker.session import get_execution_role # noqa: F401
3941

40-
__version__ = '1.15.2'
42+
__version__ = '1.16.1'

0 commit comments

Comments
 (0)