Skip to content

Commit 74201e0

Browse files
authored
Merge branch 'master' into minor-updates-to-clarify-api-doc
2 parents ad35c43 + 12c222b commit 74201e0

Some content is hidden

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

51 files changed

+3319
-166
lines changed

CHANGELOG.md

+26
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,31 @@
11
# Changelog
22

3+
## v2.52.1 (2021-08-06)
4+
5+
### Bug Fixes and Other Changes
6+
7+
* revert #2251 changes for sklearn processor
8+
9+
## v2.52.0 (2021-08-05)
10+
11+
### Features
12+
13+
* processors that support multiple Python files, requirements.txt, and dependencies.
14+
* support step object in step depends on list
15+
16+
### Bug Fixes and Other Changes
17+
18+
* enable isolation while creating model from job
19+
* update `sagemaker.serverless` integration test
20+
* Use correct boto model name for RegisterModelStep properties
21+
22+
## v2.51.0 (2021-08-03)
23+
24+
### Features
25+
26+
* add LambdaStep support for SageMaker Pipelines
27+
* support JsonGet for all step types
28+
329
## v2.50.1 (2021-08-02)
430

531
### Bug Fixes and Other Changes

VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.50.2.dev0
1+
2.52.2.dev0

doc/api/inference/model.rst

+5
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,8 @@ Model
1515
:members:
1616
:undoc-members:
1717
:show-inheritance:
18+
19+
.. autoclass:: sagemaker.serverless.model.LambdaModel
20+
:members:
21+
:undoc-members:
22+
:show-inheritance:

doc/api/inference/predictors.rst

+5
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,8 @@ Make real-time predictions against SageMaker endpoints with Python objects
77
:members:
88
:undoc-members:
99
:show-inheritance:
10+
11+
.. autoclass:: sagemaker.serverless.predictor.LambdaPredictor
12+
:members:
13+
:undoc-members:
14+
:show-inheritance:

doc/api/utility/lambda_helper.rst

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Lambda Utilities
2+
----------------
3+
4+
.. automodule:: sagemaker.lambda_helper
5+
:members:
6+
:undoc-members:
7+
:show-inheritance:

doc/overview.rst

+44
Original file line numberDiff line numberDiff line change
@@ -1063,6 +1063,50 @@ You can also find these notebooks in the **Advanced Functionality** section of t
10631063
For information about using sample notebooks in a SageMaker notebook instance, see `Use Example Notebooks <https://docs.aws.amazon.com/sagemaker/latest/dg/howitworks-nbexamples.html>`__
10641064
in the AWS documentation.
10651065
1066+
********************
1067+
Serverless Inference
1068+
********************
1069+
1070+
You can use the SageMaker Python SDK to perform serverless inference on Lambda.
1071+
1072+
To deploy models to Lambda, you must complete the following prerequisites:
1073+
1074+
- `Package your model and inference code as a container image. <https://docs.aws.amazon.com/lambda/latest/dg/images-create.html>`_
1075+
- `Create a role that lists Lambda as a trusted entity. <https://docs.aws.amazon.com/lambda/latest/dg/lambda-intro-execution-role.html#permissions-executionrole-console>`_
1076+
1077+
After completing the prerequisites, you can deploy your model to Lambda using
1078+
the `LambdaModel`_ class.
1079+
1080+
.. code:: python
1081+
1082+
from sagemaker.serverless import LambdaModel
1083+
1084+
image_uri = "123456789012.dkr.ecr.us-west-2.amazonaws.com/my-lambda-repository:latest"
1085+
role = "arn:aws:iam::123456789012:role/MyLambdaExecutionRole"
1086+
1087+
model = LambdaModel(image_uri=image_uri, role=role)
1088+
predictor = model.deploy("my-lambda-function", timeout=20, memory_size=4092)
1089+
1090+
The ``deploy`` method returns a `LambdaPredictor`_ instance. Use the
1091+
`LambdaPredictor`_ ``predict`` method to perform inference on Lambda.
1092+
1093+
.. code:: python
1094+
1095+
url = "https://example.com/cat.jpeg"
1096+
predictor.predict({"url": url}) # {'class': 'tabby'}
1097+
1098+
Once you are done performing inference on Lambda, free the `LambdaModel`_ and
1099+
`LambdaPredictor`_ resources using the ``delete_model`` and ``delete_predictor``
1100+
methods.
1101+
1102+
.. code:: python
1103+
1104+
model.delete_model()
1105+
predictor.delete_predictor()
1106+
1107+
.. _LambdaModel : https://sagemaker.readthedocs.io/en/stable/api/inference/model.html#sagemaker.serverless.model.LambdaModel
1108+
.. _LambdaPredictor : https://sagemaker.readthedocs.io/en/stable/api/inference/predictors.html#sagemaker.serverless.predictor.LambdaPredictor
1109+
10661110
******************
10671111
SageMaker Workflow
10681112
******************

doc/workflows/pipelines/sagemaker.workflow.pipelines.rst

+2
Original file line numberDiff line numberDiff line change
@@ -127,3 +127,5 @@ Steps
127127
.. autoclass:: sagemaker.workflow.callback_step.CallbackStep
128128

129129
.. autoclass:: sagemaker.workflow.steps.CacheConfig
130+
131+
.. autoclass:: sagemaker.workflow.lambda_step.LambdaStep

src/sagemaker/huggingface/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@
1515

1616
from sagemaker.huggingface.estimator import HuggingFace # noqa: F401
1717
from sagemaker.huggingface.model import HuggingFaceModel, HuggingFacePredictor # noqa: F401
18+
from sagemaker.huggingface.processing import HuggingFaceProcessor # noqa:F401
+132
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
# Copyright 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+
"""This module contains code related to HuggingFace Processors which are used for Processing jobs.
14+
15+
These jobs let customers perform data pre-processing, post-processing, feature engineering,
16+
data validation, and model evaluation and interpretation on SageMaker.
17+
"""
18+
from __future__ import absolute_import
19+
20+
from sagemaker.processing import FrameworkProcessor
21+
from sagemaker.huggingface.estimator import HuggingFace
22+
23+
24+
class HuggingFaceProcessor(FrameworkProcessor):
25+
"""Handles Amazon SageMaker processing tasks for jobs using HuggingFace containers."""
26+
27+
estimator_cls = HuggingFace
28+
29+
def __init__(
30+
self,
31+
role,
32+
instance_count,
33+
instance_type,
34+
transformers_version=None,
35+
tensorflow_version=None,
36+
pytorch_version=None,
37+
py_version="py36",
38+
image_uri=None,
39+
command=None,
40+
volume_size_in_gb=30,
41+
volume_kms_key=None,
42+
output_kms_key=None,
43+
code_location=None,
44+
max_runtime_in_seconds=None,
45+
base_job_name=None,
46+
sagemaker_session=None,
47+
env=None,
48+
tags=None,
49+
network_config=None,
50+
):
51+
"""This processor executes a Python script in a HuggingFace execution environment.
52+
53+
Unless ``image_uri`` is specified, the environment is an Amazon-built Docker container
54+
that executes functions defined in the supplied ``code`` Python script.
55+
56+
The arguments have the same meaning as in ``FrameworkProcessor``, with the following
57+
exceptions.
58+
59+
Args:
60+
transformers_version (str): Transformers version you want to use for
61+
executing your model training code. Defaults to ``None``. Required unless
62+
``image_uri`` is provided. The current supported version is ``4.4.2``.
63+
tensorflow_version (str): TensorFlow version you want to use for
64+
executing your model training code. Defaults to ``None``. Required unless
65+
``pytorch_version`` is provided. The current supported version is ``1.6.0``.
66+
pytorch_version (str): PyTorch version you want to use for
67+
executing your model training code. Defaults to ``None``. Required unless
68+
``tensorflow_version`` is provided. The current supported version is ``2.4.1``.
69+
py_version (str): Python version you want to use for executing your model training
70+
code. Defaults to ``None``. Required unless ``image_uri`` is provided. If
71+
using PyTorch, the current supported version is ``py36``. If using TensorFlow,
72+
the current supported version is ``py37``.
73+
74+
.. tip::
75+
76+
You can find additional parameters for initializing this class at
77+
:class:`~sagemaker.processing.FrameworkProcessor`.
78+
"""
79+
self.pytorch_version = pytorch_version
80+
self.tensorflow_version = tensorflow_version
81+
super().__init__(
82+
self.estimator_cls,
83+
transformers_version,
84+
role,
85+
instance_count,
86+
instance_type,
87+
py_version,
88+
image_uri,
89+
command,
90+
volume_size_in_gb,
91+
volume_kms_key,
92+
output_kms_key,
93+
code_location,
94+
max_runtime_in_seconds,
95+
base_job_name,
96+
sagemaker_session,
97+
env,
98+
tags,
99+
network_config,
100+
)
101+
102+
def _create_estimator(
103+
self,
104+
entry_point="",
105+
source_dir=None,
106+
dependencies=None,
107+
git_config=None,
108+
):
109+
"""Override default estimator factory function for HuggingFace's different parameters
110+
111+
HuggingFace estimators have 3 framework version parameters instead of one: The version for
112+
Transformers, PyTorch, and TensorFlow.
113+
"""
114+
return self.estimator_cls(
115+
transformers_version=self.framework_version,
116+
tensorflow_version=self.tensorflow_version,
117+
pytorch_version=self.pytorch_version,
118+
py_version=self.py_version,
119+
entry_point=entry_point,
120+
source_dir=source_dir,
121+
dependencies=dependencies,
122+
git_config=git_config,
123+
code_location=self.code_location,
124+
enable_network_isolation=False,
125+
image_uri=self.image_uri,
126+
role=self.role,
127+
instance_count=self.instance_count,
128+
instance_type=self.instance_type,
129+
sagemaker_session=self.sagemaker_session,
130+
debugger_hook_config=False,
131+
disable_profiler=True,
132+
)

0 commit comments

Comments
 (0)