Skip to content

Commit 2df8fb6

Browse files
authored
Merge branch 'master' into master
2 parents cef44c1 + d229105 commit 2df8fb6

38 files changed

+723
-57
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,17 @@
88

99
_Put an `x` in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your pull request._
1010

11+
#### General
12+
1113
- [ ] I have read the [CONTRIBUTING](https://github.com/aws/sagemaker-python-sdk/blob/master/CONTRIBUTING.md) doc
1214
- [ ] I used the commit message format described in [CONTRIBUTING](https://github.com/aws/sagemaker-python-sdk/blob/master/CONTRIBUTING.md#committing-your-change)
1315
- [ ] I have used the regional endpoint when creating S3 and/or STS clients (if appropriate)
16+
- [ ] I have updated any necessary documentation, including [READMEs](https://github.com/aws/sagemaker-python-sdk/blob/master/README.rst) and [API docs](https://github.com/aws/sagemaker-python-sdk/tree/master/doc) (if appropriate)
17+
18+
#### Tests
19+
1420
- [ ] I have added tests that prove my fix is effective or that my feature works (if appropriate)
1521
- [ ] I have checked that my tests are not configured for a specific region or account (if appropriate)
16-
- [ ] I have updated any necessary documentation, including [READMEs](https://github.com/aws/sagemaker-python-sdk/blob/master/README.rst) and [API docs](https://github.com/aws/sagemaker-python-sdk/tree/master/doc) (if appropriate)
22+
- [ ] I have used [`unique_name_from_base`](https://github.com/aws/sagemaker-python-sdk/blob/master/src/sagemaker/utils.py#L77) to create resource names in integ tests (if appropriate)
1723

1824
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

README.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ Table of Contents
6565
21. `SageMaker Workflow <#sagemaker-workflow>`__
6666
22. `SageMaker Autopilot <#sagemaker-autopilot>`__
6767
23. `Model Monitoring <#amazon-sagemaker-model-monitoring>`__
68+
24. `SageMaker Debugger <#amazon-sagemaker-debugger>`__
6869

6970

7071
Installing the SageMaker Python SDK
@@ -366,3 +367,13 @@ You can use Amazon SageMaker Model Monitoring to automatically detect concept dr
366367
For more information, see `Amazon SageMaker Model Monitoring`_.
367368

368369
.. _Amazon SageMaker Model Monitoring: https://sagemaker.readthedocs.io/en/stable/amazon_sagemaker_model_monitoring.html
370+
371+
Amazon SageMaker Debugger
372+
-------------------------
373+
374+
You can use Amazon SageMaker Debugger to automatically detect anomalies while training your machine learning models.
375+
376+
For more information, see `Amazon SageMaker Debugger`_.
377+
378+
.. _Amazon SageMaker Debugger: https://sagemaker.readthedocs.io/en/stable/amazon_sagemaker_debugger.html
379+

doc/amazon_sagemaker_debugger.rst

Lines changed: 415 additions & 0 deletions
Large diffs are not rendered by default.

doc/amazon_sagemaker_operators_for_kubernetes.rst

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,11 @@ IAM role-based operator deployment
8282
Before you can deploy your operator using an IAM role, associate an OpenID Connect (OIDC) provider with your role to
8383
authenticate with the IAM service.
8484

85-
Associate an OpenID Connect Provider to Your Instance
86-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
85+
Create an OpenID Connect Provider for Your Cluster
86+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
8787

88-
Create an OIDC identity provider for your cluster. If your
89-
cluster is managed by EKS, then your cluster will already have an OIDC
90-
attached to it.
88+
The following instruction will create and associate an OIDC provider
89+
with your EKS cluster.
9190

9291
Set the local ``CLUSTER_NAME`` and \ ``AWS_REGION`` environment
9392
variables as follows:

doc/amazon_sagemaker_operators_for_kubernetes_jobs.rst

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,13 @@ Download the sample YAML file for training using the following command:
2929

3030
wget https://github.com/aws/amazon-sagemaker-operator-for-k8s/blob/master/samples/xgboost-mnist-trainingjob.yaml
3131

32-
Edit the \ ``xgboost-mnist-trainingjob.yaml`` file to replace the ``roleArn`` parameter with your \ ``<sagemaker-execution-role>``, and \ ``outputPath`` with your S3 bucket that the Amazon SageMaker
33-
execution role has write access to. Apply the YAML file using the
32+
Edit the ``xgboost-mnist-trainingjob.yaml`` file to replace the ``roleArn`` parameter with your ``<sagemaker-execution-role>``, and ``outputPath`` with your S3 bucket that the Amazon SageMaker
33+
execution role has write access to. The ``roleArn`` must have permissions so that Amazon SageMaker
34+
can access Amazon S3, Amazon CloudWatch, and other services on your
35+
behalf. For more information on creating an Amazon SageMaker
36+
ExecutionRole, see `Amazon SageMaker
37+
Roles <https://docs.aws.amazon.com/sagemaker/latest/dg/sagemaker-roles.html#sagemaker-roles-createtrainingjob-perms>`__.
38+
Apply the YAML file using the
3439
following command:
3540

3641
::

doc/index.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,3 +208,13 @@ You can use Amazon SageMaker Model Monitoring to automatically detect concept dr
208208
:maxdepth: 2
209209

210210
amazon_sagemaker_model_monitoring
211+
212+
*************************
213+
Amazon SageMaker Debugger
214+
*************************
215+
You can use Amazon SageMaker Debugger to automatically detect anomalies while training your machine learning models.
216+
217+
.. toctree::
218+
:maxdepth: 2
219+
220+
amazon_sagemaker_debugger

doc/overview.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1048,6 +1048,15 @@ For more information, see `SageMaker Model Monitoring`_.
10481048
10491049
.. _SageMaker Model Monitoring: https://github.com/aws/sagemaker-python-sdk/blob/master/doc/amazon_sagemaker_model_monitoring.rst
10501050
1051+
******************
1052+
SageMaker Debugger
1053+
******************
1054+
You can use Amazon SageMaker Debugger to automatically detect anomalies while training your machine learning models.
1055+
1056+
For more information, see `SageMaker Debugger`_.
1057+
1058+
.. _SageMaker Debugger: https://github.com/aws/sagemaker-python-sdk/blob/master/doc/amazon_sagemaker_debugger.rst
1059+
10511060
***
10521061
FAQ
10531062
***

doc/using_chainer.rst

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,10 @@ When running your training script on SageMaker, it will have access to some pre-
116116
For more information on the runtime environment, including specific package versions, see `SageMaker Chainer Docker containers <#sagemaker-chainer-docker-containers>`__.
117117

118118
If there are other packages you want to use with your script, you can include a ``requirements.txt`` file in the same directory as your training script to install other dependencies at runtime.
119-
A ``requirements.txt`` file is a text file that contains a list of items that are installed by using ``pip install``. You can also specify the version of an item to install.
119+
Both ``requirements.txt`` and your training script should be put in the same folder.
120+
You must specify this folder in ``source_dir`` argument when creating a Chainer estimator.
121+
A ``requirements.txt`` file is a text file that contains a list of items that are installed by using ``pip install``.
122+
You can also specify the version of an item to install.
120123
For information about the format of a ``requirements.txt`` file, see `Requirements Files <https://pip.pypa.io/en/stable/user_guide/#requirements-files>`__ in the pip documentation.
121124

122125
Create an Estimator
@@ -637,4 +640,4 @@ SageMaker Chainer Docker containers
637640

638641
You can visit the SageMaker Chainer containers repository here: https://github.com/aws/sagemaker-chainer-container
639642

640-
For information about SageMaker Chainer Docker containers and their dependencies, see `SageMaker Chainer Docker containers <https://github.com/aws/sagemaker-python-sdk/tree/master/src/sagemaker/chainer#sagemaker-chainer-docker-containers>`_.
643+
For information about SageMaker Chainer Docker containers and their dependencies, see `SageMaker Chainer Docker containers <https://github.com/aws/sagemaker-python-sdk/tree/master/src/sagemaker/chainer#sagemaker-chainer-docker-containers>`_.

doc/using_mxnet.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,10 @@ When running your training script on SageMaker, it will have access to some pre-
310310
For more information on the runtime environment, including specific package versions, see `SageMaker MXNet Containers <#sagemaker-mxnet-containers>`__.
311311

312312
If there are other packages you want to use with your script, you can include a ``requirements.txt`` file in the same directory as your training script to install other dependencies at runtime.
313-
A ``requirements.txt`` file is a text file that contains a list of items that are installed by using ``pip install``. You can also specify the version of an item to install.
313+
Both ``requirements.txt`` and your training script should be put in the same folder.
314+
You must specify this folder in ``source_dir`` argument when creating an MXNet estimator.
315+
A ``requirements.txt`` file is a text file that contains a list of items that are installed by using ``pip install``.
316+
You can also specify the version of an item to install.
314317
For information about the format of a ``requirements.txt`` file, see `Requirements Files <https://pip.pypa.io/en/stable/user_guide/#requirements-files>`__ in the pip documentation.
315318

316319
Create an Estimator

doc/using_pytorch.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ The function of installing packages using ``requirements.txt`` is supported for
131131

132132
A ``requirements.txt`` file is a text file that contains a list of items that are installed by using ``pip install``. You can also specify the version of an item to install. For information about the format of a ``requirements.txt`` file, see `Requirements Files <https://pip.pypa.io/en/stable/user_guide/#requirements-files>`__ in the pip documentation.
133133

134-
135134
Create an Estimator
136135
===================
137136

doc/using_sklearn.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,12 @@ When running your training script on SageMaker, it has access to some pre-instal
114114
For more information on the runtime environment, including specific package versions, see `SageMaker Scikit-learn Docker Container <https://github.com/aws/sagemaker-scikit-learn-container>`__.
115115

116116
If there are other packages you want to use with your script, you can include a ``requirements.txt`` file in the same directory as your training script to install other dependencies at runtime.
117-
A ``requirements.txt`` file is a text file that contains a list of items that are installed by using ``pip install``. You can also specify the version of an item to install.
117+
Both ``requirements.txt`` and your training script should be put in the same folder.
118+
You must specify this folder in ``source_dir`` argument when creating a Scikit-learn estimator.
119+
A ``requirements.txt`` file is a text file that contains a list of items that are installed by using ``pip install``.
120+
You can also specify the version of an item to install.
118121
For information about the format of a ``requirements.txt`` file, see `Requirements Files <https://pip.pypa.io/en/stable/user_guide/#requirements-files>`__ in the pip documentation.
119122

120-
121-
122123
Create an Estimator
123124
===================
124125

src/sagemaker/automl/automl.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ def deploy(
201201
vpc_config=None,
202202
enable_network_isolation=False,
203203
model_kms_key=None,
204+
predictor_cls=None,
204205
):
205206
"""Deploy a candidate to a SageMaker Inference Pipeline and return a Predictor
206207
@@ -237,10 +238,15 @@ def deploy(
237238
training cluster for distributed training. Default: False
238239
model_kms_key (str): KMS key ARN used to encrypt the repacked
239240
model archive file if the model is repacked
241+
predictor_cls (callable[string, sagemaker.session.Session]): A
242+
function to call to create a predictor (default: None). If
243+
specified, ``deploy()`` returns the result of invoking this
244+
function on the created endpoint name.
240245
241246
Returns:
242-
callable[string, sagemaker.session.Session]: Invocation of
243-
``self.predictor_cls`` on the created endpoint name.
247+
callable[string, sagemaker.session.Session] or ``None``:
248+
If ``predictor_cls`` is specified, the invocation of ``self.predictor_cls`` on
249+
the created endpoint name. Otherwise, ``None``.
244250
"""
245251
if candidate is None:
246252
candidate_dict = self.best_candidate()
@@ -264,6 +270,7 @@ def deploy(
264270
vpc_config=vpc_config,
265271
enable_network_isolation=enable_network_isolation,
266272
model_kms_key=model_kms_key,
273+
predictor_cls=predictor_cls,
267274
)
268275

269276
def _check_problem_type_and_job_objective(self, problem_type, job_objective):
@@ -299,6 +306,7 @@ def _deploy_inference_pipeline(
299306
vpc_config=None,
300307
enable_network_isolation=False,
301308
model_kms_key=None,
309+
predictor_cls=None,
302310
):
303311
"""Deploy a SageMaker Inference Pipeline.
304312
@@ -329,6 +337,10 @@ def _deploy_inference_pipeline(
329337
contains "SecurityGroupIds", "Subnets"
330338
model_kms_key (str): KMS key ARN used to encrypt the repacked
331339
model archive file if the model is repacked
340+
predictor_cls (callable[string, sagemaker.session.Session]): A
341+
function to call to create a predictor (default: None). If
342+
specified, ``deploy()`` returns the result of invoking this
343+
function on the created endpoint name.
332344
"""
333345
# construct Model objects
334346
models = []
@@ -352,6 +364,7 @@ def _deploy_inference_pipeline(
352364
pipeline = PipelineModel(
353365
models=models,
354366
role=self.role,
367+
predictor_cls=predictor_cls,
355368
name=name,
356369
vpc_config=vpc_config,
357370
sagemaker_session=sagemaker_session or self.sagemaker_session,

src/sagemaker/chainer/defaults.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,6 @@
1717
"""Default Chainer version for when the framework version is not specified.
1818
This is no longer updated so as to not break existing workflows.
1919
"""
20+
21+
LATEST_VERSION = "5.0.0"
22+
"""The latest version of Chainer included in the SageMaker pre-built Docker images."""

src/sagemaker/chainer/estimator.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
empty_framework_version_warning,
2323
python_deprecation_warning,
2424
)
25-
from sagemaker.chainer.defaults import CHAINER_VERSION
25+
from sagemaker.chainer.defaults import CHAINER_VERSION, LATEST_VERSION
2626
from sagemaker.chainer.model import ChainerModel
2727
from sagemaker.vpc_utils import VPC_CONFIG_DEFAULT
2828

@@ -40,8 +40,7 @@ class Chainer(Framework):
4040
_process_slots_per_host = "sagemaker_process_slots_per_host"
4141
_additional_mpi_options = "sagemaker_additional_mpi_options"
4242

43-
LATEST_VERSION = "5.0.0"
44-
"""The latest version of Chainer included in the SageMaker pre-built Docker images."""
43+
LATEST_VERSION = LATEST_VERSION
4544

4645
def __init__(
4746
self,

src/sagemaker/chainer/model.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,14 @@
1616
import logging
1717

1818
import sagemaker
19-
from sagemaker.fw_utils import create_image_uri, model_code_key_prefix, python_deprecation_warning
19+
from sagemaker.fw_utils import (
20+
create_image_uri,
21+
model_code_key_prefix,
22+
python_deprecation_warning,
23+
empty_framework_version_warning,
24+
)
2025
from sagemaker.model import FrameworkModel, MODEL_SERVER_WORKERS_PARAM_NAME
21-
from sagemaker.chainer.defaults import CHAINER_VERSION
26+
from sagemaker.chainer.defaults import CHAINER_VERSION, LATEST_VERSION
2227
from sagemaker.predictor import RealTimePredictor, npy_serializer, numpy_deserializer
2328

2429
logger = logging.getLogger("sagemaker")
@@ -61,7 +66,7 @@ def __init__(
6166
entry_point,
6267
image=None,
6368
py_version="py3",
64-
framework_version=CHAINER_VERSION,
69+
framework_version=None,
6570
predictor_cls=ChainerPredictor,
6671
model_server_workers=None,
6772
**kwargs
@@ -107,9 +112,11 @@ def __init__(
107112
)
108113
if py_version == "py2":
109114
logger.warning(python_deprecation_warning(self.__framework_name__))
115+
if framework_version is None:
116+
logger.warning(empty_framework_version_warning(CHAINER_VERSION, LATEST_VERSION))
110117

111118
self.py_version = py_version
112-
self.framework_version = framework_version
119+
self.framework_version = framework_version or CHAINER_VERSION
113120
self.model_server_workers = model_server_workers
114121

115122
def prepare_container_def(self, instance_type, accelerator_type=None):

src/sagemaker/model.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,9 @@ def deploy(
473473
kms_key=kms_key,
474474
data_capture_config_dict=data_capture_config_dict,
475475
)
476-
self.sagemaker_session.update_endpoint(self.endpoint_name, endpoint_config_name)
476+
self.sagemaker_session.update_endpoint(
477+
self.endpoint_name, endpoint_config_name, wait=wait
478+
)
477479
else:
478480
self.sagemaker_session.endpoint_from_production_variants(
479481
name=self.endpoint_name,

src/sagemaker/multidatamodel.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,9 @@ def deploy(
243243
kms_key=kms_key,
244244
data_capture_config_dict=data_capture_config_dict,
245245
)
246-
self.sagemaker_session.update_endpoint(self.endpoint_name, endpoint_config_name)
246+
self.sagemaker_session.update_endpoint(
247+
self.endpoint_name, endpoint_config_name, wait=wait
248+
)
247249
else:
248250
self.sagemaker_session.endpoint_from_production_variants(
249251
name=self.endpoint_name,

src/sagemaker/mxnet/defaults.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,6 @@
1717
"""Default MXNet version for when the framework version is not specified.
1818
This is no longer updated so as to not break existing workflows.
1919
"""
20+
21+
LATEST_VERSION = "1.6.0"
22+
"""The latest version of MXNet included in the SageMaker pre-built Docker images."""

src/sagemaker/mxnet/estimator.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
python_deprecation_warning,
2424
is_version_equal_or_higher,
2525
)
26-
from sagemaker.mxnet.defaults import MXNET_VERSION
26+
from sagemaker.mxnet.defaults import MXNET_VERSION, LATEST_VERSION
2727
from sagemaker.mxnet.model import MXNetModel
2828
from sagemaker.vpc_utils import VPC_CONFIG_DEFAULT
2929

@@ -36,8 +36,7 @@ class MXNet(Framework):
3636
__framework_name__ = "mxnet"
3737
_LOWEST_SCRIPT_MODE_VERSION = ["1", "3"]
3838

39-
LATEST_VERSION = "1.6.0"
40-
"""The latest version of MXNet included in the SageMaker pre-built Docker images."""
39+
LATEST_VERSION = LATEST_VERSION
4140

4241
def __init__(
4342
self,

src/sagemaker/mxnet/model.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,14 @@
1818
from pkg_resources import parse_version
1919

2020
import sagemaker
21-
from sagemaker.fw_utils import create_image_uri, model_code_key_prefix, python_deprecation_warning
21+
from sagemaker.fw_utils import (
22+
create_image_uri,
23+
model_code_key_prefix,
24+
python_deprecation_warning,
25+
empty_framework_version_warning,
26+
)
2227
from sagemaker.model import FrameworkModel, MODEL_SERVER_WORKERS_PARAM_NAME
23-
from sagemaker.mxnet.defaults import MXNET_VERSION
28+
from sagemaker.mxnet.defaults import MXNET_VERSION, LATEST_VERSION
2429
from sagemaker.predictor import RealTimePredictor, json_serializer, json_deserializer
2530

2631
logger = logging.getLogger("sagemaker")
@@ -62,7 +67,7 @@ def __init__(
6267
entry_point,
6368
image=None,
6469
py_version="py2",
65-
framework_version=MXNET_VERSION,
70+
framework_version=None,
6671
predictor_cls=MXNetPredictor,
6772
model_server_workers=None,
6873
**kwargs
@@ -109,9 +114,11 @@ def __init__(
109114

110115
if py_version == "py2":
111116
logger.warning(python_deprecation_warning(self.__framework_name__))
117+
if framework_version is None:
118+
logger.warning(empty_framework_version_warning(MXNET_VERSION, LATEST_VERSION))
112119

113120
self.py_version = py_version
114-
self.framework_version = framework_version
121+
self.framework_version = framework_version or MXNET_VERSION
115122
self.model_server_workers = model_server_workers
116123

117124
def prepare_container_def(self, instance_type, accelerator_type=None):

src/sagemaker/pipeline.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,9 @@ def deploy(
159159
tags=tags,
160160
data_capture_config_dict=data_capture_config_dict,
161161
)
162-
self.sagemaker_session.update_endpoint(self.endpoint_name, endpoint_config_name)
162+
self.sagemaker_session.update_endpoint(
163+
self.endpoint_name, endpoint_config_name, wait=wait
164+
)
163165
else:
164166
self.sagemaker_session.endpoint_from_production_variants(
165167
name=self.endpoint_name,

src/sagemaker/pytorch/defaults.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,7 @@
1919
break existing workflows.
2020
"""
2121

22+
LATEST_VERSION = "1.3.1"
23+
"""The latest version of PyTorch included in the SageMaker pre-built Docker images."""
24+
2225
PYTHON_VERSION = "py3"

0 commit comments

Comments
 (0)