Skip to content

Commit 4adc5b9

Browse files
authored
Merge branch 'master' into fix-cloudwatch-logs-local
2 parents 5aa1b71 + 16c4a7e commit 4adc5b9

Some content is hidden

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

59 files changed

+3595
-218
lines changed

CHANGELOG.md

+51
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,56 @@
11
# Changelog
22

3+
## v2.53.0 (2021-08-12)
4+
5+
### Features
6+
7+
* support tuning step parameter range parameterization + support retry strategy in tuner
8+
9+
## v2.52.2.post0 (2021-08-11)
10+
11+
### Documentation Changes
12+
13+
* clarify that default_bucket creates a bucket
14+
* Minor updates to Clarify API documentation
15+
16+
## v2.52.2 (2021-08-10)
17+
18+
### Bug Fixes and Other Changes
19+
20+
* sklearn integ tests, remove swallowing exception on feature group delete attempt
21+
* sklearn integ test for custom bucket
22+
23+
### Documentation Changes
24+
25+
* Fix dataset_definition links
26+
* Document LambdaModel and LambdaPredictor classes
27+
28+
## v2.52.1 (2021-08-06)
29+
30+
### Bug Fixes and Other Changes
31+
32+
* revert #2251 changes for sklearn processor
33+
34+
## v2.52.0 (2021-08-05)
35+
36+
### Features
37+
38+
* processors that support multiple Python files, requirements.txt, and dependencies.
39+
* support step object in step depends on list
40+
41+
### Bug Fixes and Other Changes
42+
43+
* enable isolation while creating model from job
44+
* update `sagemaker.serverless` integration test
45+
* Use correct boto model name for RegisterModelStep properties
46+
47+
## v2.51.0 (2021-08-03)
48+
49+
### Features
50+
51+
* add LambdaStep support for SageMaker Pipelines
52+
* support JsonGet for all step types
53+
354
## v2.50.1 (2021-08-02)
455

556
### 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.53.1.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

+5-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ ConditionStep
55
-------------
66

77
.. autoclass:: sagemaker.workflow.condition_step.ConditionStep
8-
9-
.. autoclass:: sagemaker.workflow.condition_step.JsonGet
8+
.. deprecated:: sagemaker.workflow.condition_step.JsonGet
109

1110
Conditions
1211
----------
@@ -54,6 +53,8 @@ Functions
5453

5554
.. autoclass:: sagemaker.workflow.functions.Join
5655

56+
.. autoclass:: sagemaker.workflow.functions.JsonGet
57+
5758
Parameters
5859
----------
5960

@@ -125,3 +126,5 @@ Steps
125126
.. autoclass:: sagemaker.workflow.callback_step.CallbackStep
126127

127128
.. autoclass:: sagemaker.workflow.steps.CacheConfig
129+
130+
.. autoclass:: sagemaker.workflow.lambda_step.LambdaStep

src/sagemaker/clarify.py

+31-27
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,17 @@ def __init__(
4848
headers (list[str]): A list of column names in the input dataset.
4949
features (str): JSONPath for locating the feature columns for bias metrics if the
5050
dataset format is JSONLines.
51-
dataset_type (str): Format of the dataset. Valid values are "text/csv" for CSV
52-
and "application/jsonlines" for JSONLines.
51+
dataset_type (str): Format of the dataset. Valid values are "text/csv" for CSV,
52+
"application/jsonlines" for JSONLines, and "application/x-parquet" for Parquet.
5353
s3_data_distribution_type (str): Valid options are "FullyReplicated" or
5454
"ShardedByS3Key".
5555
s3_compression_type (str): Valid options are "None" or "Gzip".
5656
"""
57+
if dataset_type not in ["text/csv", "application/jsonlines", "application/x-parquet"]:
58+
raise ValueError(
59+
f"Invalid dataset_type '{dataset_type}'."
60+
f" Please check the API documentation for the supported dataset types."
61+
)
5762
self.s3_data_input_path = s3_data_input_path
5863
self.s3_output_path = s3_output_path
5964
self.s3_data_distribution_type = s3_data_distribution_type
@@ -508,7 +513,7 @@ def run_pre_training_bias(
508513
kms_key=None,
509514
experiment_config=None,
510515
):
511-
"""Runs a ProcessingJob to compute the requested bias 'methods' of the input data.
516+
"""Runs a ProcessingJob to compute the pre-training bias methods of the input data.
512517
513518
Computes the requested methods that compare 'methods' (e.g. fraction of examples) for the
514519
sensitive group vs the other examples.
@@ -517,14 +522,14 @@ def run_pre_training_bias(
517522
data_config (:class:`~sagemaker.clarify.DataConfig`): Config of the input/output data.
518523
data_bias_config (:class:`~sagemaker.clarify.BiasConfig`): Config of sensitive groups.
519524
methods (str or list[str]): Selector of a subset of potential metrics:
520-
["`CI <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-ci.html>`_",
521-
"`DPL <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-dpl.html>`_",
522-
"`KL <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-kl.html>`_",
523-
"`JS <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-js.html>`_",
524-
"`LP <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-lp.html>`_",
525-
"`TVD <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-tvd.html>`_",
526-
"`KS <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-ks.html>`_",
527-
"`CDDL <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-cdd.html>`_"].
525+
["`CI <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-bias-metric-class-imbalance.html>`_",
526+
"`DPL <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-data-bias-metric-true-label-imbalance.html>`_",
527+
"`KL <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-data-bias-metric-kl-divergence.html>`_",
528+
"`JS <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-data-bias-metric-jensen-shannon-divergence.html>`_",
529+
"`LP <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-data-bias-metric-lp-norm.html>`_",
530+
"`TVD <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-data-bias-metric-total-variation-distance.html>`_",
531+
"`KS <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-data-bias-metric-kolmogorov-smirnov.html>`_",
532+
"`CDDL <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-data-bias-metric-cddl.html>`_"].
528533
Defaults to computing all.
529534
wait (bool): Whether the call should wait until the job completes (default: True).
530535
logs (bool): Whether to show the logs produced by the job.
@@ -538,7 +543,7 @@ def run_pre_training_bias(
538543
experiment_config (dict[str, str]): Experiment management configuration.
539544
Dictionary contains three optional keys:
540545
'ExperimentName', 'TrialName', and 'TrialComponentDisplayName'.
541-
"""
546+
""" # noqa E501
542547
analysis_config = data_config.get_config()
543548
analysis_config.update(data_bias_config.get_config())
544549
analysis_config["methods"] = {"pre_training_bias": {"methods": methods}}
@@ -562,7 +567,7 @@ def run_post_training_bias(
562567
kms_key=None,
563568
experiment_config=None,
564569
):
565-
"""Runs a ProcessingJob to compute the requested bias 'methods' of the model predictions.
570+
"""Runs a ProcessingJob to compute the post-training bias methods of the model predictions.
566571
567572
Spins up a model endpoint, runs inference over the input example in the
568573
's3_data_input_path' to obtain predicted labels. Computes a the requested methods that
@@ -633,12 +638,11 @@ def run_bias(
633638
kms_key=None,
634639
experiment_config=None,
635640
):
636-
"""Runs a ProcessingJob to compute the requested bias 'methods' of the model predictions.
641+
"""Runs a ProcessingJob to compute the requested bias methods.
637642
638-
Spins up a model endpoint, runs inference over the input example in the
639-
's3_data_input_path' to obtain predicted labels. Computes a the requested methods that
640-
compare 'methods' (e.g. accuracy, precision, recall) for the sensitive group vs the other
641-
examples.
643+
It computes the metrics of both the pre-training methods and the post-training methods.
644+
To calculate post-training methods, it needs to spin up a model endpoint, runs inference
645+
over the input example in the 's3_data_input_path' to obtain predicted labels.
642646
643647
Args:
644648
data_config (:class:`~sagemaker.clarify.DataConfig`): Config of the input/output data.
@@ -648,14 +652,14 @@ def run_bias(
648652
model_predicted_label_config (:class:`~sagemaker.clarify.ModelPredictedLabelConfig`):
649653
Config of how to extract the predicted label from the model output.
650654
pre_training_methods (str or list[str]): Selector of a subset of potential metrics:
651-
["`CI <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-ci.html>`_",
652-
"`DPL <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-dpl.html>`_",
653-
"`KL <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-kl.html>`_",
654-
"`JS <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-js.html>`_",
655-
"`LP <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-lp.html>`_",
656-
"`TVD <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-tvd.html>`_",
657-
"`KS <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-ks.html>`_",
658-
"`CDDL <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-cdd.html>`_"].
655+
["`CI <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-bias-metric-class-imbalance.html>`_",
656+
"`DPL <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-data-bias-metric-true-label-imbalance.html>`_",
657+
"`KL <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-data-bias-metric-kl-divergence.html>`_",
658+
"`JS <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-data-bias-metric-jensen-shannon-divergence.html>`_",
659+
"`LP <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-data-bias-metric-lp-norm.html>`_",
660+
"`TVD <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-data-bias-metric-total-variation-distance.html>`_",
661+
"`KS <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-data-bias-metric-kolmogorov-smirnov.html>`_",
662+
"`CDDL <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-data-bias-metric-cddl.html>`_"].
659663
Defaults to computing all.
660664
post_training_methods (str or list[str]): Selector of a subset of potential metrics:
661665
["`DPPL <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-dppl.html>`_"
@@ -682,7 +686,7 @@ def run_bias(
682686
experiment_config (dict[str, str]): Experiment management configuration.
683687
Dictionary contains three optional keys:
684688
'ExperimentName', 'TrialName', and 'TrialComponentDisplayName'.
685-
"""
689+
""" # noqa E501
686690
analysis_config = data_config.get_config()
687691
analysis_config.update(bias_config.get_config())
688692
analysis_config["predictor"] = model_config.get_predictor_config()

src/sagemaker/dataset_definition/inputs.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,9 @@ class DatasetDefinition(ApiObject):
9999
Definition inputs to run a processing job. LocalPath is an absolute path to the input
100100
data. This is a required parameter when `AppManaged` is False (default).
101101
redshift_dataset_definition
102-
(:class:`~sagemaker.dataset_definition.RedshiftDatasetDefinition`): Redshift
102+
(:class:`~sagemaker.dataset_definition.inputs.RedshiftDatasetDefinition`): Redshift
103103
dataset definition.
104-
athena_dataset_definition (:class:`~sagemaker.dataset_definition.AthenaDatasetDefinition`):
104+
athena_dataset_definition (:class:`~sagemaker.dataset_definition.inputs.AthenaDatasetDefinition`):
105105
Configuration for Athena Dataset Definition input.
106106
"""
107107

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

0 commit comments

Comments
 (0)