Skip to content

Commit 1b9d66b

Browse files
Merge branch 'aws:master' into master
2 parents 8cf18b8 + 125adc3 commit 1b9d66b

23 files changed

+514
-70
lines changed

CHANGELOG.md

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

3+
## v2.47.2 (2021-06-30)
4+
5+
### Bug Fixes and Other Changes
6+
7+
* handle tags when upsert pipeine
8+
9+
## v2.47.1 (2021-06-27)
10+
11+
### Bug Fixes and Other Changes
12+
13+
* revert "fix: jsonGet interpolation issue 2426 + allow step depends on pass in step instance (#2477)"
14+
15+
## v2.47.0 (2021-06-25)
16+
17+
### Features
18+
19+
* support job_name_prefix for Clarify
20+
21+
### Bug Fixes and Other Changes
22+
23+
* Add configuration option with headers for Clarify Explainability
24+
* jsonGet interpolation issue 2426 + allow step depends on pass in step instance
25+
* add default retries to feature group ingestion.
26+
* Update using_pytorch.rst
27+
* kms key does not propapate in register model step
28+
* Correctly interpolate Callback output parameters
29+
30+
## v2.46.1 (2021-06-22)
31+
32+
### Bug Fixes and Other Changes
33+
34+
* Register model step tags
35+
36+
### Documentation Changes
37+
38+
* update to include new batch_get_record api call
39+
* Correct type annotation for TrainingStep inputs
40+
* introduce input mode FastFile
41+
* update hf transformer version
42+
43+
## v2.46.0 (2021-06-15)
44+
45+
### Features
46+
47+
* Add HF transformer version 4.6.1
48+
49+
### Bug Fixes and Other Changes
50+
51+
* encode localmode payload to UTF-8
52+
* call DescribeDomain as fallback in get_execution_role
53+
* parameterize PT and TF version for HuggingFace tests
54+
55+
### Documentation Changes
56+
57+
* Add import statement in Batch Transform Overview doc
58+
359
## v2.45.0 (2021-06-07)
460

561
### Features

VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.45.1.dev0
1+
2.47.3.dev0

doc/amazon_sagemaker_featurestore.rst

+7
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,13 @@ example identifier to retrieve the record.
291291
record_identifier_value = str(2990130)
292292
featurestore_runtime.get_record(FeatureGroupName=transaction_feature_group_name, RecordIdentifierValueAsString=record_identifier_value)
293293
294+
You can use the ``batch_get_record`` function to retrieve multiple records simultaneously from your feature store. The following example uses this API to retrieve a batch of records.
295+
296+
.. code:: python
297+
298+
record_identifier_values = ["573291", "109382", "828400", "124013"]
299+
featurestore_runtime.batch_get_record(Identifiers=[{"FeatureGroupName": transaction_feature_group_name, "RecordIdentifiersValueAsString": record_identifier_values}])
300+
294301
An example response from the fraud detection example:
295302
296303
.. code:: python

doc/frameworks/pytorch/using_pytorch.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ To train a PyTorch model by using the SageMaker Python SDK:
3131
Prepare a PyTorch Training Script
3232
=================================
3333

34-
Your PyTorch training script must be a Python 2.7 or 3.5 compatible source file.
34+
Your PyTorch training script must be a Python 3.6 compatible source file.
3535

3636
Prepare your script in a separate source file than the notebook, terminal session, or source file you're
3737
using to submit the script to SageMaker via a ``PyTorch`` Estimator. This will be discussed in further detail below.

doc/overview.rst

+2
Original file line numberDiff line numberDiff line change
@@ -703,6 +703,8 @@ Alternatively, if you already have a SageMaker model, you can create an instance
703703

704704
.. code:: python
705705
706+
from sagemaker.transformer import Transformer
707+
706708
transformer = Transformer(model_name='my-previously-trained-model',
707709
instance_count=1,
708710
instance_type='ml.m4.xlarge')

src/sagemaker/clarify.py

+84-23
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,7 @@ def __init__(
350350
env=None,
351351
tags=None,
352352
network_config=None,
353+
job_name_prefix=None,
353354
version=None,
354355
):
355356
"""Initializes a ``Processor`` instance, computing bias metrics and model explanations.
@@ -384,9 +385,11 @@ def __init__(
384385
A :class:`~sagemaker.network.NetworkConfig`
385386
object that configures network isolation, encryption of
386387
inter-container traffic, security group IDs, and subnets.
388+
job_name_prefix (str): Processing job name prefix.
387389
version (str): Clarify version want to be used.
388390
"""
389391
container_uri = image_uris.retrieve("clarify", sagemaker_session.boto_region_name, version)
392+
self.job_name_prefix = job_name_prefix
390393
super(SageMakerClarifyProcessor, self).__init__(
391394
role,
392395
container_uri,
@@ -500,13 +503,22 @@ def run_pre_training_bias(
500503
data_config (:class:`~sagemaker.clarify.DataConfig`): Config of the input/output data.
501504
data_bias_config (:class:`~sagemaker.clarify.BiasConfig`): Config of sensitive groups.
502505
methods (str or list[str]): Selector of a subset of potential metrics:
503-
["CI", "DPL", "KL", "JS", "LP", "TVD", "KS", "CDDL"]. Defaults to computing all.
504-
# TODO: Provide a pointer to the official documentation of those.
506+
["`CI <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-ci.html>`_",
507+
"`DPL <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-dpl.html>`_",
508+
"`KL <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-kl.html>`_",
509+
"`JS <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-js.html>`_",
510+
"`LP <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-lp.html>`_",
511+
"`TVD <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-tvd.html>`_",
512+
"`KS <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-ks.html>`_",
513+
"`CDDL <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-cdd.html>`_"].
514+
Defaults to computing all.
505515
wait (bool): Whether the call should wait until the job completes (default: True).
506516
logs (bool): Whether to show the logs produced by the job.
507517
Only meaningful when ``wait`` is True (default: True).
508-
job_name (str): Processing job name. If not specified, a name is composed of
509-
"Clarify-Pretraining-Bias" and current timestamp.
518+
job_name (str): Processing job name. When ``job_name`` is not specified, if
519+
``job_name_prefix`` in :class:`SageMakerClarifyProcessor` specified, the job name
520+
will be composed of ``job_name_prefix`` and current timestamp; otherwise use
521+
"Clarify-Pretraining-Bias" as prefix.
510522
kms_key (str): The ARN of the KMS key that is used to encrypt the
511523
user code file (default: None).
512524
experiment_config (dict[str, str]): Experiment management configuration.
@@ -517,7 +529,10 @@ def run_pre_training_bias(
517529
analysis_config.update(data_bias_config.get_config())
518530
analysis_config["methods"] = {"pre_training_bias": {"methods": methods}}
519531
if job_name is None:
520-
job_name = utils.name_from_base("Clarify-Pretraining-Bias")
532+
if self.job_name_prefix:
533+
job_name = utils.name_from_base(self.job_name_prefix)
534+
else:
535+
job_name = utils.name_from_base("Clarify-Pretraining-Bias")
521536
self._run(data_config, analysis_config, wait, logs, job_name, kms_key, experiment_config)
522537

523538
def run_post_training_bias(
@@ -548,14 +563,25 @@ def run_post_training_bias(
548563
model_predicted_label_config (:class:`~sagemaker.clarify.ModelPredictedLabelConfig`):
549564
Config of how to extract the predicted label from the model output.
550565
methods (str or list[str]): Selector of a subset of potential metrics:
551-
# TODO: Provide a pointer to the official documentation of those.
552-
["DPPL", "DI", "DCA", "DCR", "RD", "DAR", "DRR", "AD", "CDDPL", "TE", "FT"].
566+
["`DPPL <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-dppl.html>`_"
567+
, "`DI <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-di.html>`_",
568+
"`DCA <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-dca.html>`_",
569+
"`DCR <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-dcr.html>`_",
570+
"`RD <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-rd.html>`_",
571+
"`DAR <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-dar.html>`_",
572+
"`DRR <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-drr.html>`_",
573+
"`AD <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-ad.html>`_",
574+
"`CDDPL <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-cddpl.html>`_
575+
", "`TE <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-te.html>`_",
576+
"`FT <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-ft.html>`_"].
553577
Defaults to computing all.
554578
wait (bool): Whether the call should wait until the job completes (default: True).
555579
logs (bool): Whether to show the logs produced by the job.
556580
Only meaningful when ``wait`` is True (default: True).
557-
job_name (str): Processing job name. If not specified, a name is composed of
558-
"Clarify-Posttraining-Bias" and current timestamp.
581+
job_name (str): Processing job name. When ``job_name`` is not specified, if
582+
``job_name_prefix`` in :class:`SageMakerClarifyProcessor` specified, the job name
583+
will be composed of ``job_name_prefix`` and current timestamp; otherwise use
584+
"Clarify-Posttraining-Bias" as prefix.
559585
kms_key (str): The ARN of the KMS key that is used to encrypt the
560586
user code file (default: None).
561587
experiment_config (dict[str, str]): Experiment management configuration.
@@ -573,7 +599,10 @@ def run_post_training_bias(
573599
analysis_config["predictor"] = predictor_config
574600
_set(probability_threshold, "probability_threshold", analysis_config)
575601
if job_name is None:
576-
job_name = utils.name_from_base("Clarify-Posttraining-Bias")
602+
if self.job_name_prefix:
603+
job_name = utils.name_from_base(self.job_name_prefix)
604+
else:
605+
job_name = utils.name_from_base("Clarify-Posttraining-Bias")
577606
self._run(data_config, analysis_config, wait, logs, job_name, kms_key, experiment_config)
578607

579608
def run_bias(
@@ -605,18 +634,35 @@ def run_bias(
605634
model_predicted_label_config (:class:`~sagemaker.clarify.ModelPredictedLabelConfig`):
606635
Config of how to extract the predicted label from the model output.
607636
pre_training_methods (str or list[str]): Selector of a subset of potential metrics:
608-
# TODO: Provide a pointer to the official documentation of those.
609-
["DPPL", "DI", "DCA", "DCR", "RD", "DAR", "DRR", "AD", "CDDPL", "TE", "FT"].
637+
["`CI <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-ci.html>`_",
638+
"`DPL <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-dpl.html>`_",
639+
"`KL <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-kl.html>`_",
640+
"`JS <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-js.html>`_",
641+
"`LP <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-lp.html>`_",
642+
"`TVD <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-tvd.html>`_",
643+
"`KS <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-ks.html>`_",
644+
"`CDDL <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-cdd.html>`_"].
610645
Defaults to computing all.
611646
post_training_methods (str or list[str]): Selector of a subset of potential metrics:
612-
# TODO: Provide a pointer to the official documentation of those.
613-
["DPPL", "DI", "DCA", "DCR", "RD", "DAR", "DRR", "AD", "CDDPL", "TE", "FT"].
647+
["`DPPL <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-dppl.html>`_"
648+
, "`DI <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-di.html>`_",
649+
"`DCA <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-dca.html>`_",
650+
"`DCR <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-dcr.html>`_",
651+
"`RD <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-rd.html>`_",
652+
"`DAR <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-dar.html>`_",
653+
"`DRR <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-drr.html>`_",
654+
"`AD <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-ad.html>`_",
655+
"`CDDPL <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-cddpl.html>`_
656+
", "`TE <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-te.html>`_",
657+
"`FT <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-ft.html>`_"].
614658
Defaults to computing all.
615659
wait (bool): Whether the call should wait until the job completes (default: True).
616660
logs (bool): Whether to show the logs produced by the job.
617661
Only meaningful when ``wait`` is True (default: True).
618-
job_name (str): Processing job name. If not specified, a name is composed of
619-
"Clarify-Bias" and current timestamp.
662+
job_name (str): Processing job name. When ``job_name`` is not specified, if
663+
``job_name_prefix`` in :class:`SageMakerClarifyProcessor` specified, the job name
664+
will be composed of ``job_name_prefix`` and current timestamp; otherwise use
665+
"Clarify-Bias" as prefix.
620666
kms_key (str): The ARN of the KMS key that is used to encrypt the
621667
user code file (default: None).
622668
experiment_config (dict[str, str]): Experiment management configuration.
@@ -641,7 +687,10 @@ def run_bias(
641687
"post_training_bias": {"methods": post_training_methods},
642688
}
643689
if job_name is None:
644-
job_name = utils.name_from_base("Clarify-Bias")
690+
if self.job_name_prefix:
691+
job_name = utils.name_from_base(self.job_name_prefix)
692+
else:
693+
job_name = utils.name_from_base("Clarify-Bias")
645694
self._run(data_config, analysis_config, wait, logs, job_name, kms_key, experiment_config)
646695

647696
def run_explainability(
@@ -674,13 +723,17 @@ def run_explainability(
674723
endpoint to be created.
675724
explainability_config (:class:`~sagemaker.clarify.ExplainabilityConfig`): Config of the
676725
specific explainability method. Currently, only SHAP is supported.
677-
model_scores: Index or JSONPath location in the model output for the predicted scores
678-
to be explained. This is not required if the model output is a single score.
726+
model_scores(str|int|ModelPredictedLabelConfig): Index or JSONPath location in the
727+
model output for the predicted scores to be explained. This is not required if the
728+
model output is a single score. Alternatively, an instance of
729+
ModelPredictedLabelConfig can be provided.
679730
wait (bool): Whether the call should wait until the job completes (default: True).
680731
logs (bool): Whether to show the logs produced by the job.
681732
Only meaningful when ``wait`` is True (default: True).
682-
job_name (str): Processing job name. If not specified, a name is composed of
683-
"Clarify-Explainability" and current timestamp.
733+
job_name (str): Processing job name. When ``job_name`` is not specified, if
734+
``job_name_prefix`` in :class:`SageMakerClarifyProcessor` specified, the job name
735+
will be composed of ``job_name_prefix`` and current timestamp; otherwise use
736+
"Clarify-Explainability" as prefix.
684737
kms_key (str): The ARN of the KMS key that is used to encrypt the
685738
user code file (default: None).
686739
experiment_config (dict[str, str]): Experiment management configuration.
@@ -689,11 +742,19 @@ def run_explainability(
689742
"""
690743
analysis_config = data_config.get_config()
691744
predictor_config = model_config.get_predictor_config()
692-
_set(model_scores, "label", predictor_config)
745+
if isinstance(model_scores, ModelPredictedLabelConfig):
746+
probability_threshold, predicted_label_config = model_scores.get_predictor_config()
747+
_set(probability_threshold, "probability_threshold", analysis_config)
748+
predictor_config.update(predicted_label_config)
749+
else:
750+
_set(model_scores, "label", predictor_config)
693751
analysis_config["methods"] = explainability_config.get_explainability_config()
694752
analysis_config["predictor"] = predictor_config
695753
if job_name is None:
696-
job_name = utils.name_from_base("Clarify-Explainability")
754+
if self.job_name_prefix:
755+
job_name = utils.name_from_base(self.job_name_prefix)
756+
else:
757+
job_name = utils.name_from_base("Clarify-Explainability")
697758
self._run(data_config, analysis_config, wait, logs, job_name, kms_key, experiment_config)
698759

699760

src/sagemaker/estimator.py

+2
Original file line numberDiff line numberDiff line change
@@ -1007,6 +1007,8 @@ def register(
10071007
if compile_model_family is not None:
10081008
model = self._compiled_models[compile_model_family]
10091009
else:
1010+
if "model_kms_key" not in kwargs:
1011+
kwargs["model_kms_key"] = self.output_kms_key
10101012
model = self.create_model(image_uri=image_uri, **kwargs)
10111013
model.name = model_name
10121014
return model.register(

src/sagemaker/feature_store/feature_group.py

+5
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
from __future__ import absolute_import
2323

24+
import copy
2425
import logging
2526
import math
2627
import os
@@ -193,6 +194,10 @@ def _ingest_single_batch(
193194
Returns:
194195
List of row indices that failed to be ingested.
195196
"""
197+
retry_config = client_config.retries
198+
if "max_attempts" not in retry_config and "total_max_attempts" not in retry_config:
199+
client_config = copy.deepcopy(client_config)
200+
client_config.retries = {"max_attempts": 10, "mode": "standard"}
196201
sagemaker_featurestore_runtime_client = boto3.Session().client(
197202
service_name="sagemaker-featurestore-runtime", config=client_config
198203
)

src/sagemaker/huggingface/estimator.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def __init__(
6666
must point to a file located at the root of ``source_dir``.
6767
transformers_version (str): Transformers version you want to use for
6868
executing your model training code. Defaults to ``None``. Required unless
69-
``image_uri`` is provided. The current supported version is ``4.4.2``.
69+
``image_uri`` is provided. The current supported version is ``4.6.1``.
7070
tensorflow_version (str): TensorFlow version you want to use for
7171
executing your model training code. Defaults to ``None``. Required unless
7272
``pytorch_version`` is provided. The current supported version is ``1.6.0``.

src/sagemaker/inputs.py

+2
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ def __init__(
7070
a local directory.
7171
* 'Pipe' - Amazon SageMaker streams data directly from S3 to the container via
7272
a Unix-named pipe.
73+
* 'FastFile' - Amazon SageMaker streams data from S3 on demand instead of
74+
downloading the entire dataset before training begins.
7375
7476
attribute_names (list[str]): A list of one or more attribute names to use that are
7577
found in a specified AugmentedManifestFile.

0 commit comments

Comments
 (0)