Skip to content

Commit 7c30322

Browse files
authored
Merge branch 'master' into master
2 parents f263ae8 + 69d06ad commit 7c30322

40 files changed

+528
-90
lines changed

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
# Changelog
22

3+
## v1.62.0 (2020-06-11)
4+
5+
### Features
6+
7+
* Support for multi variant endpoint invocation with target variant param
8+
9+
### Bug Fixes and Other Changes
10+
11+
* Revert "feature: Support for multi variant endpoint invocation with target variant param (#1571)"
12+
* make instance_type optional for prepare_container_def
13+
* docs: workflows navigation
14+
15+
### Documentation Changes
16+
17+
* fix typo in MXNet documentation
18+
319
## v1.61.0 (2020-06-09)
420

521
### Features

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.61.1.dev0
1+
1.62.1.dev0

doc/frameworks/mxnet/using_mxnet.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ The default serialization system generates three files:
176176
- ``model-symbol.json``: The MXNet ``Module`` ``Symbol`` serialization,
177177
produced by invoking ``save`` on the ``symbol`` property of the
178178
``Module`` being saved.
179-
- ``modle.params``: The MXNet ``Module`` parameters, produced by
179+
- ``model.params``: The MXNet ``Module`` parameters, produced by
180180
invoking ``save_params`` on the ``Module`` being saved.
181181

182182
You can provide your own save function. This is useful if you are not working with the ``Module`` API or you need special processing.

doc/index.rst

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,14 @@ Amazon SageMaker provides implementations of some common machine learning algori
5353

5454

5555
*************
56-
Orchestration
56+
Workflows
5757
*************
58-
Orchestrate your SageMaker training and inference jobs with Kubernetes and Airflow.
58+
Orchestrate your SageMaker training and inference workflows with Airflow and Kubernetes.
5959

6060
.. toctree::
61-
:maxdepth: 1
61+
:maxdepth: 2
6262

63-
kubernetes/index
64-
airflow/index
63+
workflows/index
6564

6665

6766
*************************
File renamed without changes.

doc/workflows/index.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
##########
2+
Workflows
3+
##########
4+
5+
The SageMaker Python SDK supports managed training and inference for a variety of machine learning frameworks:
6+
7+
.. toctree::
8+
:maxdepth: 2
9+
10+
airflow/index
11+
kubernetes/index
File renamed without changes.

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def read_version():
3434

3535
# Declare minimal set for installation
3636
required_packages = [
37-
"boto3>=1.13.6",
37+
"boto3>=1.13.24",
3838
"numpy>=1.9.0",
3939
"protobuf>=3.1",
4040
"scipy>=0.19.0",

src/sagemaker/chainer/estimator.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,8 @@ def __init__(
105105
py_version (str): Python version you want to use for executing your
106106
model training code (default: 'py2'). One of 'py2' or 'py3'.
107107
framework_version (str): Chainer version you want to use for
108-
executing your model training code. List of supported versions
109-
https://github.com/aws/sagemaker-python-sdk#chainer-sagemaker-estimators.
110-
If not specified, this will default to 4.1.
108+
executing your model training code. If not specified, this will
109+
default to 4.1.
111110
image_name (str): If specified, the estimator will use this image
112111
for training and hosting, instead of selecting the appropriate
113112
SageMaker official image based on framework_version and

src/sagemaker/chainer/model.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515

1616
import logging
1717

18-
from sagemaker import fw_utils
19-
2018
import sagemaker
2119
from sagemaker.fw_utils import (
2220
create_image_uri,
@@ -126,7 +124,7 @@ def __init__(
126124
self.framework_version = framework_version or defaults.CHAINER_VERSION
127125
self.model_server_workers = model_server_workers
128126

129-
def prepare_container_def(self, instance_type, accelerator_type=None):
127+
def prepare_container_def(self, instance_type=None, accelerator_type=None):
130128
"""Return a container definition with framework configuration set in
131129
model environment variables.
132130
@@ -143,14 +141,14 @@ def prepare_container_def(self, instance_type, accelerator_type=None):
143141
"""
144142
deploy_image = self.image
145143
if not deploy_image:
144+
if instance_type is None:
145+
raise ValueError(
146+
"Must supply either an instance type (for choosing CPU vs GPU) or an image URI."
147+
)
148+
146149
region_name = self.sagemaker_session.boto_session.region_name
147-
deploy_image = create_image_uri(
148-
region_name,
149-
self.__framework_name__,
150-
instance_type,
151-
self.framework_version,
152-
self.py_version,
153-
accelerator_type=accelerator_type,
150+
deploy_image = self.serving_image_uri(
151+
region_name, instance_type, accelerator_type=accelerator_type
154152
)
155153

156154
deploy_key_prefix = model_code_key_prefix(self.key_prefix, self.name, deploy_image)
@@ -162,7 +160,7 @@ def prepare_container_def(self, instance_type, accelerator_type=None):
162160
deploy_env[MODEL_SERVER_WORKERS_PARAM_NAME.upper()] = str(self.model_server_workers)
163161
return sagemaker.container_def(deploy_image, self.model_data, deploy_env)
164162

165-
def serving_image_uri(self, region_name, instance_type):
163+
def serving_image_uri(self, region_name, instance_type, accelerator_type=None):
166164
"""Create a URI for the serving image.
167165
168166
Args:
@@ -174,10 +172,11 @@ def serving_image_uri(self, region_name, instance_type):
174172
str: The appropriate image URI based on the given parameters.
175173
176174
"""
177-
return fw_utils.create_image_uri(
175+
return create_image_uri(
178176
region_name,
179177
self.__framework_name__,
180178
instance_type,
181179
self.framework_version,
182180
self.py_version,
181+
accelerator_type=accelerator_type,
183182
)

src/sagemaker/local/local_session.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,7 @@ def invoke_endpoint(
343343
Accept=None,
344344
CustomAttributes=None,
345345
TargetModel=None,
346+
TargetVariant=None,
346347
):
347348
"""
348349
@@ -370,6 +371,9 @@ def invoke_endpoint(
370371
if TargetModel is not None:
371372
headers["X-Amzn-SageMaker-Target-Model"] = TargetModel
372373

374+
if TargetVariant is not None:
375+
headers["X-Amzn-SageMaker-Target-Variant"] = TargetVariant
376+
373377
r = self.http.request("POST", url, body=Body, preload_content=False, headers=headers)
374378

375379
return {"Body": r, "ContentType": Accept}

src/sagemaker/model.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ def _init_sagemaker_session_if_does_not_exist(self, instance_type):
138138
self.sagemaker_session = session.Session()
139139

140140
def prepare_container_def(
141-
self, instance_type, accelerator_type=None
141+
self, instance_type=None, accelerator_type=None
142142
): # pylint: disable=unused-argument
143143
"""Return a dict created by ``sagemaker.container_def()`` for deploying
144144
this model to a specified instance type.
@@ -166,7 +166,7 @@ def enable_network_isolation(self):
166166
"""
167167
return self._enable_network_isolation
168168

169-
def _create_sagemaker_model(self, instance_type, accelerator_type=None, tags=None):
169+
def _create_sagemaker_model(self, instance_type=None, accelerator_type=None, tags=None):
170170
"""Create a SageMaker Model Entity
171171
172172
Args:
@@ -807,9 +807,7 @@ def __init__(
807807
self.uploaded_code = None
808808
self.repacked_model_data = None
809809

810-
def prepare_container_def(
811-
self, instance_type, accelerator_type=None
812-
): # pylint disable=unused-argument
810+
def prepare_container_def(self, instance_type=None, accelerator_type=None):
813811
"""Return a container definition with framework configuration set in
814812
model environment variables.
815813

src/sagemaker/multidatamodel.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def __init__(
111111
**kwargs
112112
)
113113

114-
def prepare_container_def(self, instance_type, accelerator_type=None):
114+
def prepare_container_def(self, instance_type=None, accelerator_type=None):
115115
"""Return a container definition set with MultiModel mode,
116116
model data and other parameters from the model (if available).
117117

src/sagemaker/mxnet/model.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ def __init__(
126126
self.framework_version = framework_version or defaults.MXNET_VERSION
127127
self.model_server_workers = model_server_workers
128128

129-
def prepare_container_def(self, instance_type, accelerator_type=None):
129+
def prepare_container_def(self, instance_type=None, accelerator_type=None):
130130
"""Return a container definition with framework configuration set in
131131
model environment variables.
132132
@@ -143,6 +143,11 @@ def prepare_container_def(self, instance_type, accelerator_type=None):
143143
"""
144144
deploy_image = self.image
145145
if not deploy_image:
146+
if instance_type is None:
147+
raise ValueError(
148+
"Must supply either an instance type (for choosing CPU vs GPU) or an image URI."
149+
)
150+
146151
region_name = self.sagemaker_session.boto_session.region_name
147152
deploy_image = self.serving_image_uri(
148153
region_name, instance_type, accelerator_type=accelerator_type

src/sagemaker/predictor.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def __init__(
8383
self._endpoint_config_name = self._get_endpoint_config_name()
8484
self._model_names = self._get_model_names()
8585

86-
def predict(self, data, initial_args=None, target_model=None):
86+
def predict(self, data, initial_args=None, target_model=None, target_variant=None):
8787
"""Return the inference from the specified endpoint.
8888
8989
Args:
@@ -98,6 +98,9 @@ def predict(self, data, initial_args=None, target_model=None):
9898
target_model (str): S3 model artifact path to run an inference request on,
9999
in case of a multi model endpoint. Does not apply to endpoints hosting
100100
single model (Default: None)
101+
target_variant (str): The name of the production variant to run an inference
102+
request on (Default: None). Note that the ProductionVariant identifies the model
103+
you want to host and the resources you want to deploy for hosting it.
101104
102105
Returns:
103106
object: Inference for the given input. If a deserializer was specified when creating
@@ -106,7 +109,7 @@ def predict(self, data, initial_args=None, target_model=None):
106109
as is.
107110
"""
108111

109-
request_args = self._create_request_args(data, initial_args, target_model)
112+
request_args = self._create_request_args(data, initial_args, target_model, target_variant)
110113
response = self.sagemaker_session.sagemaker_runtime_client.invoke_endpoint(**request_args)
111114
return self._handle_response(response)
112115

@@ -123,12 +126,13 @@ def _handle_response(self, response):
123126
response_body.close()
124127
return data
125128

126-
def _create_request_args(self, data, initial_args=None, target_model=None):
129+
def _create_request_args(self, data, initial_args=None, target_model=None, target_variant=None):
127130
"""
128131
Args:
129132
data:
130133
initial_args:
131134
target_model:
135+
target_variant:
132136
"""
133137
args = dict(initial_args) if initial_args else {}
134138

@@ -144,6 +148,9 @@ def _create_request_args(self, data, initial_args=None, target_model=None):
144148
if target_model:
145149
args["TargetModel"] = target_model
146150

151+
if target_variant:
152+
args["TargetVariant"] = target_variant
153+
147154
if self.serializer is not None:
148155
data = self.serializer(data)
149156

src/sagemaker/pytorch/estimator.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,8 @@ def __init__(
8383
py_version (str): Python version you want to use for executing your
8484
model training code (default: 'py3'). One of 'py2' or 'py3'.
8585
framework_version (str): PyTorch version you want to use for
86-
executing your model training code. List of supported versions
87-
https://github.com/aws/sagemaker-python-sdk#pytorch-sagemaker-estimators.
88-
If not specified, this will default to 0.4.
86+
executing your model training code. If not specified, this will default
87+
to 0.4.
8988
image_name (str): If specified, the estimator will use this image
9089
for training and hosting, instead of selecting the appropriate
9190
SageMaker official image based on framework_version and

src/sagemaker/pytorch/model.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ def __init__(
127127
self.framework_version = framework_version or defaults.PYTORCH_VERSION
128128
self.model_server_workers = model_server_workers
129129

130-
def prepare_container_def(self, instance_type, accelerator_type=None):
130+
def prepare_container_def(self, instance_type=None, accelerator_type=None):
131131
"""Return a container definition with framework configuration set in
132132
model environment variables.
133133
@@ -144,6 +144,11 @@ def prepare_container_def(self, instance_type, accelerator_type=None):
144144
"""
145145
deploy_image = self.image
146146
if not deploy_image:
147+
if instance_type is None:
148+
raise ValueError(
149+
"Must supply either an instance type (for choosing CPU vs GPU) or an image URI."
150+
)
151+
147152
region_name = self.sagemaker_session.boto_session.region_name
148153
deploy_image = self.serving_image_uri(
149154
region_name, instance_type, accelerator_type=accelerator_type

src/sagemaker/s3.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,9 @@ def upload(local_path, desired_s3_uri, kms_key=None, session=None):
5757
"""Static method that uploads a given file or directory to S3.
5858
5959
Args:
60-
local_path (str): A local path to a file or directory.
61-
desired_s3_uri (str): The desired S3 uri to upload to.
60+
local_path (str): Path (absolute or relative) of local file or directory to upload.
61+
desired_s3_uri (str): The desired S3 location to upload to. It is the prefix to
62+
which the local filename will be added.
6263
kms_key (str): The KMS key to use to encrypt the files.
6364
session (sagemaker.session.Session): Session object which
6465
manages interactions with Amazon SageMaker APIs and any other

src/sagemaker/sklearn/estimator.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,7 @@ def __init__(
6868
If ``source_dir`` is specified, then ``entry_point``
6969
must point to a file located at the root of ``source_dir``.
7070
framework_version (str): Scikit-learn version you want to use for
71-
executing your model training code. List of supported versions
72-
https://github.com/aws/sagemaker-python-sdk#sklearn-sagemaker-estimators
71+
executing your model training code.
7372
source_dir (str): Path (absolute, relative or an S3 URI) to a directory
7473
with any other training source code dependencies aside from the entry
7574
point file (default: None). If ``source_dir`` is an S3 URI, it must

0 commit comments

Comments
 (0)