Skip to content

Commit eb56b79

Browse files
Merge branch 'master' into ci-queueing-improvements
2 parents a8df44d + e244e61 commit eb56b79

24 files changed

+167
-1488
lines changed

CHANGELOG.md

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

3+
## v2.66.2.post0 (2021-10-28)
4+
5+
### Documentation Changes
6+
7+
* Update estimator docstrings to add Fast File Mode
8+
9+
## v2.66.2 (2021-10-27)
10+
11+
### Bug Fixes and Other Changes
12+
13+
* expose num_clusters parameter for clarify shap in shapconfig
14+
* Update cron job to run hourly
15+
316
## v2.66.1 (2021-10-26)
417

518
### Bug Fixes and Other Changes

VERSION

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

doc/api/inference/model.rst

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,3 @@ Model
1616
:undoc-members:
1717
:show-inheritance:
1818

19-
.. autoclass:: sagemaker.serverless.model.LambdaModel
20-
:members:
21-
:undoc-members:
22-
:show-inheritance:

doc/api/inference/predictors.rst

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,3 @@ 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/overview.rst

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,50 +1063,6 @@ 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-
11101066
******************
11111067
SageMaker Workflow
11121068
******************

src/sagemaker/clarify.py

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -305,12 +305,13 @@ class SHAPConfig(ExplainabilityConfig):
305305

306306
def __init__(
307307
self,
308-
baseline,
309-
num_samples,
310-
agg_method,
308+
baseline=None,
309+
num_samples=None,
310+
agg_method=None,
311311
use_logit=False,
312312
save_local_shap_values=True,
313313
seed=None,
314+
num_clusters=None,
314315
):
315316
"""Initializes config for SHAP.
316317
@@ -320,34 +321,49 @@ def __init__(
320321
be the same as the dataset format. Each row should contain only the feature
321322
columns/values and omit the label column/values. If None a baseline will be
322323
calculated automatically by using K-means or K-prototypes in the input dataset.
323-
num_samples (int): Number of samples to be used in the Kernel SHAP algorithm.
324+
num_samples (None or int): Number of samples to be used in the Kernel SHAP algorithm.
324325
This number determines the size of the generated synthetic dataset to compute the
325-
SHAP values.
326-
agg_method (str): Aggregation method for global SHAP values. Valid values are
326+
SHAP values. If not provided then Clarify job will choose a proper value according
327+
to the count of features.
328+
agg_method (None or str): Aggregation method for global SHAP values. Valid values are
327329
"mean_abs" (mean of absolute SHAP values for all instances),
328330
"median" (median of SHAP values for all instances) and
329331
"mean_sq" (mean of squared SHAP values for all instances).
332+
If not provided then Clarify job uses method "mean_abs"
330333
use_logit (bool): Indicator of whether the logit function is to be applied to the model
331334
predictions. Default is False. If "use_logit" is true then the SHAP values will
332335
have log-odds units.
333336
save_local_shap_values (bool): Indicator of whether to save the local SHAP values
334337
in the output location. Default is True.
335338
seed (int): seed value to get deterministic SHAP values. Default is None.
339+
num_clusters (None or int): If a baseline is not provided, Clarify automatically
340+
computes a baseline dataset via a clustering algorithm (K-means/K-prototypes).
341+
num_clusters is a parameter for this algorithm. num_clusters will be the resulting
342+
size of the baseline dataset. If not provided, Clarify job will use a default value.
336343
"""
337-
if agg_method not in ["mean_abs", "median", "mean_sq"]:
344+
if agg_method is not None and agg_method not in ["mean_abs", "median", "mean_sq"]:
338345
raise ValueError(
339346
f"Invalid agg_method {agg_method}." f" Please choose mean_abs, median, or mean_sq."
340347
)
341-
348+
if num_clusters is not None and baseline is not None:
349+
raise ValueError(
350+
"Baseline and num_clusters cannot be provided together. "
351+
"Please specify one of the two."
352+
)
342353
self.shap_config = {
343-
"baseline": baseline,
344-
"num_samples": num_samples,
345-
"agg_method": agg_method,
346354
"use_logit": use_logit,
347355
"save_local_shap_values": save_local_shap_values,
348356
}
357+
if baseline is not None:
358+
self.shap_config["baseline"] = baseline
359+
if num_samples is not None:
360+
self.shap_config["num_samples"] = num_samples
361+
if agg_method is not None:
362+
self.shap_config["agg_method"] = agg_method
349363
if seed is not None:
350364
self.shap_config["seed"] = seed
365+
if num_clusters is not None:
366+
self.shap_config["num_clusters"] = num_clusters
351367

352368
def get_explainability_config(self):
353369
"""Returns config."""

src/sagemaker/deprecations.py

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,27 @@
2121
V2_URL = "https://sagemaker.readthedocs.io/en/stable/v2.html"
2222

2323

24-
def _warn(msg):
24+
def _warn(msg, sdk_version=None):
2525
"""Generic warning raiser referencing V2
2626
2727
Args:
2828
phrase: The phrase to include in the warning.
29+
sdk_version: the sdk version of removal of support.
2930
"""
30-
full_msg = f"{msg} in sagemaker>=2.\nSee: {V2_URL} for details."
31+
_sdk_version = sdk_version if sdk_version is not None else "2"
32+
full_msg = f"{msg} in sagemaker>={_sdk_version}.\nSee: {V2_URL} for details."
3133
warnings.warn(full_msg, DeprecationWarning, stacklevel=2)
3234
logger.warning(full_msg)
3335

3436

35-
def removed_warning(phrase):
37+
def removed_warning(phrase, sdk_version=None):
3638
"""Raise a warning for a no-op in sagemaker>=2
3739
3840
Args:
3941
phrase: the prefix phrase of the warning message.
42+
sdk_version: the sdk version of removal of support.
4043
"""
41-
_warn(f"{phrase} is a no-op")
44+
_warn(f"{phrase} is a no-op", sdk_version)
4245

4346

4447
def renamed_warning(phrase):
@@ -146,26 +149,32 @@ def func(*args, **kwargs): # pylint: disable=W0613
146149
return func
147150

148151

149-
def deprecated(obj):
152+
def deprecated(sdk_version=None):
150153
"""Decorator for raising deprecated warning for a feature in sagemaker>=2
151154
155+
Args:
156+
sdk_version (str): the sdk version of removal of support.
157+
152158
Usage:
153-
@deprecated
159+
@deprecated()
154160
def sample_function():
155161
print("xxxx....")
156162
157-
@deprecated
163+
@deprecated(sdk_version="2.66")
158164
class SampleClass():
159165
def __init__(self):
160166
print("xxxx....")
161167
162168
"""
163169

164-
def wrapper(*args, **kwargs):
165-
removed_warning(obj.__name__)
166-
return obj(*args, **kwargs)
170+
def deprecate(obj):
171+
def wrapper(*args, **kwargs):
172+
removed_warning(obj.__name__, sdk_version)
173+
return obj(*args, **kwargs)
174+
175+
return wrapper
167176

168-
return wrapper
177+
return deprecate
169178

170179

171180
def deprecated_function(func, name):

src/sagemaker/estimator.py

Lines changed: 27 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -11,63 +11,54 @@
1111
# ANY KIND, either express or implied. See the License for the specific
1212
# language governing permissions and limitations under the License.
1313
"""Placeholder docstring"""
14-
from __future__ import print_function, absolute_import
14+
from __future__ import absolute_import, print_function
1515

1616
import json
1717
import logging
1818
import os
1919
import uuid
20+
from abc import ABCMeta, abstractmethod
2021

21-
from abc import ABCMeta
22-
from abc import abstractmethod
23-
24-
from six import with_metaclass
25-
from six import string_types
22+
from six import string_types, with_metaclass
2623
from six.moves.urllib.parse import urlparse
24+
2725
import sagemaker
28-
from sagemaker import git_utils, image_uris
26+
from sagemaker import git_utils, image_uris, vpc_utils
2927
from sagemaker.analytics import TrainingJobAnalytics
30-
from sagemaker.debugger import TensorBoardOutputConfig # noqa: F401 # pylint: disable=unused-import
31-
from sagemaker.debugger import (
28+
from sagemaker.debugger import ( # noqa: F401 # pylint: disable=unused-import
3229
DEBUGGER_FLAG,
3330
DebuggerHookConfig,
3431
FrameworkProfile,
35-
get_default_profiler_rule,
36-
get_rule_container_image_uri,
3732
ProfilerConfig,
3833
ProfilerRule,
3934
Rule,
35+
TensorBoardOutputConfig,
36+
get_default_profiler_rule,
37+
get_rule_container_image_uri,
4038
)
41-
from sagemaker.deprecations import (
42-
removed_kwargs,
43-
removed_function,
44-
renamed_kwargs,
45-
)
46-
from sagemaker.s3 import S3Uploader, parse_s3_url
47-
39+
from sagemaker.deprecations import removed_function, removed_kwargs, renamed_kwargs
4840
from sagemaker.fw_utils import (
49-
tar_and_upload_dir,
5041
UploadedCode,
51-
validate_source_dir,
5242
_region_supports_debugger,
5343
_region_supports_profiler,
5444
get_mp_parameters,
45+
tar_and_upload_dir,
46+
validate_source_dir,
5547
)
56-
from sagemaker.workflow.properties import Properties
57-
from sagemaker.workflow.parameters import Parameter
58-
from sagemaker.workflow.entities import Expression
5948
from sagemaker.inputs import TrainingInput
6049
from sagemaker.job import _Job
6150
from sagemaker.local import LocalSession
62-
from sagemaker.model import Model, NEO_ALLOWED_FRAMEWORKS
6351
from sagemaker.model import (
64-
SCRIPT_PARAM_NAME,
65-
DIR_PARAM_NAME,
6652
CONTAINER_LOG_LEVEL_PARAM_NAME,
53+
DIR_PARAM_NAME,
6754
JOB_NAME_PARAM_NAME,
55+
NEO_ALLOWED_FRAMEWORKS,
6856
SAGEMAKER_REGION_PARAM_NAME,
57+
SCRIPT_PARAM_NAME,
58+
Model,
6959
)
7060
from sagemaker.predictor import Predictor
61+
from sagemaker.s3 import S3Uploader, parse_s3_url
7162
from sagemaker.session import Session
7263
from sagemaker.transformer import Transformer
7364
from sagemaker.utils import (
@@ -77,7 +68,9 @@
7768
get_config_value,
7869
name_from_base,
7970
)
80-
from sagemaker import vpc_utils
71+
from sagemaker.workflow.entities import Expression
72+
from sagemaker.workflow.parameters import Parameter
73+
from sagemaker.workflow.properties import Properties
8174

8275
logger = logging.getLogger(__name__)
8376

@@ -150,11 +143,14 @@ def __init__(
150143
60 * 60). After this amount of time Amazon SageMaker terminates
151144
the job regardless of its current status.
152145
input_mode (str): The input mode that the algorithm supports
153-
(default: 'File'). Valid modes: 'File' - Amazon SageMaker copies
154-
the training dataset from the S3 location to a local directory.
146+
(default: 'File'). Valid modes:
147+
'File' - Amazon SageMaker copiesthe training dataset from the
148+
S3 location to a local directory.
155149
'Pipe' - Amazon SageMaker streams data directly from S3 to the
156-
container via a Unix-named pipe. This argument can be overriden
157-
on a per-channel basis using
150+
container via a Unix-named pipe.
151+
'FastFile' - Amazon SageMaker streams data from S3 on demand instead of
152+
downloading the entire dataset before training begins. This argument can
153+
be overriden on a per-channel basis using
158154
``sagemaker.inputs.TrainingInput.input_mode``.
159155
output_path (str): S3 location for saving the training result (model
160156
artifacts and output files). If not specified, results are

0 commit comments

Comments
 (0)