Skip to content

Commit 5ed6d29

Browse files
authored
Merge branch 'master' into fix-issue-2426
2 parents 1c1f2d2 + e0b6353 commit 5ed6d29

File tree

24 files changed

+1122
-220
lines changed

24 files changed

+1122
-220
lines changed

CHANGELOG.md

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

3+
## v2.49.1 (2021-07-19)
4+
5+
### Bug Fixes and Other Changes
6+
7+
* Set flag when debugger is disabled
8+
* KMS Key fix for kwargs
9+
* Update BiasConfig to accept multiple facet params
10+
11+
### Documentation Changes
12+
13+
* Update huggingface estimator documentation
14+
15+
## v2.49.0 (2021-07-15)
16+
17+
### Features
18+
19+
* Adding serial inference pipeline support to RegisterModel Step
20+
21+
### Documentation Changes
22+
23+
* add tuning step get_top_model_s3_uri and callback step to doc
24+
* links for HF in sdk
25+
* Add Clarify module to Model Monitoring API docs
26+
327
## v2.48.2 (2021-07-12)
428

529
### Bug Fixes and Other Changes

VERSION

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

src/sagemaker/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
from sagemaker.processing import Processor, ScriptProcessor # noqa: F401
5656
from sagemaker.session import Session # noqa: F401
5757
from sagemaker.session import container_def, pipeline_container_def # noqa: F401
58+
from sagemaker.session import get_model_package_args # noqa: F401
5859
from sagemaker.session import production_variant # noqa: F401
5960
from sagemaker.session import get_execution_role # noqa: F401
6061

src/sagemaker/clarify.py

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,21 +88,34 @@ def __init__(
8888
Args:
8989
label_values_or_threshold (Any): List of label values or threshold to indicate positive
9090
outcome used for bias metrics.
91-
facet_name (str): Sensitive attribute in the input data for which we like to compare
92-
metrics.
91+
facet_name (str or [str]): String or List of strings of sensitive attribute(s) in the
92+
input data for which we like to compare metrics.
9393
facet_values_or_threshold (list): Optional list of values to form a sensitive group or
9494
threshold for a numeric facet column that defines the lower bound of a sensitive
9595
group. Defaults to considering each possible value as sensitive group and
9696
computing metrics vs all the other examples.
97+
If facet_name is a list, this needs to be None or a List consisting of lists or None
98+
with the same length as facet_name list.
9799
group_name (str): Optional column name or index to indicate a group column to be used
98100
for the bias metric 'Conditional Demographic Disparity in Labels - CDDL' or
99101
'Conditional Demographic Disparity in Predicted Labels - CDDPL'.
100102
"""
101-
facet = {"name_or_index": facet_name}
102-
_set(facet_values_or_threshold, "value_or_threshold", facet)
103+
if isinstance(facet_name, str):
104+
facet = {"name_or_index": facet_name}
105+
_set(facet_values_or_threshold, "value_or_threshold", facet)
106+
facet_list = [facet]
107+
elif facet_values_or_threshold is None or len(facet_name) == len(facet_values_or_threshold):
108+
facet_list = []
109+
for i, single_facet_name in enumerate(facet_name):
110+
facet = {"name_or_index": single_facet_name}
111+
if facet_values_or_threshold is not None:
112+
_set(facet_values_or_threshold[i], "value_or_threshold", facet)
113+
facet_list.append(facet)
114+
else:
115+
raise ValueError("Wrong combination of argument values passed")
103116
self.analysis_config = {
104117
"label_values_or_threshold": label_values_or_threshold,
105-
"facet": [facet],
118+
"facet": facet_list,
106119
}
107120
_set(group_name, "group_variable", self.analysis_config)
108121

src/sagemaker/debugger/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
from sagemaker.debugger.debugger import ( # noqa: F401
1717
CollectionConfig,
18+
DEBUGGER_FLAG,
1819
DebuggerHookConfig,
1920
framework_name,
2021
get_default_profiler_rule,

src/sagemaker/debugger/debugger.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
from sagemaker.utils import build_dict
3333

3434
framework_name = "debugger"
35+
DEBUGGER_FLAG = "USE_SMDEBUG"
3536

3637

3738
def get_rule_container_image_uri(region):

src/sagemaker/estimator.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
from sagemaker.analytics import TrainingJobAnalytics
3030
from sagemaker.debugger import TensorBoardOutputConfig # noqa: F401 # pylint: disable=unused-import
3131
from sagemaker.debugger import (
32+
DEBUGGER_FLAG,
3233
DebuggerHookConfig,
3334
FrameworkProfile,
3435
get_default_profiler_rule,
@@ -2269,6 +2270,11 @@ def _validate_and_set_debugger_configs(self):
22692270
)
22702271
self.debugger_hook_config = False
22712272

2273+
if self.debugger_hook_config is False:
2274+
if self.environment is None:
2275+
self.environment = {}
2276+
self.environment[DEBUGGER_FLAG] = "0"
2277+
22722278
def _stage_user_code_in_s3(self):
22732279
"""Upload the user training script to s3 and return the location.
22742280

src/sagemaker/huggingface/estimator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,10 @@ def __init__(
7070
``image_uri`` is provided. The current supported version is ``4.6.1``.
7171
tensorflow_version (str): TensorFlow version you want to use for
7272
executing your model training code. Defaults to ``None``. Required unless
73-
``pytorch_version`` is provided. The current supported version is ``1.6.0``.
73+
``pytorch_version`` is provided. The current supported version is ``2.4.1``.
7474
pytorch_version (str): PyTorch version you want to use for
7575
executing your model training code. Defaults to ``None``. Required unless
76-
``tensorflow_version`` is provided. The current supported version is ``2.4.1``.
76+
``tensorflow_version`` is provided. The current supported versions are ``1.7.1`` and ``1.6.0``.
7777
source_dir (str): Path (absolute, relative or an S3 URI) to a directory
7878
with any other training source code dependencies aside from the entry
7979
point file (default: None). If ``source_dir`` is an S3 URI, it must

src/sagemaker/model.py

Lines changed: 7 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -158,14 +158,15 @@ def register(
158158
if self.model_data is None:
159159
raise ValueError("SageMaker Model Package cannot be created without model data.")
160160

161-
model_pkg_args = self._get_model_package_args(
161+
model_pkg_args = sagemaker.get_model_package_args(
162162
content_types,
163163
response_types,
164164
inference_instances,
165165
transform_instances,
166166
model_package_name,
167167
model_package_group_name,
168-
image_uri,
168+
self.model_data,
169+
image_uri or self.image_uri,
169170
model_metrics,
170171
metadata_properties,
171172
marketplace_cert,
@@ -181,80 +182,6 @@ def register(
181182
model_package_arn=model_package.get("ModelPackageArn"),
182183
)
183184

184-
def _get_model_package_args(
185-
self,
186-
content_types,
187-
response_types,
188-
inference_instances,
189-
transform_instances,
190-
model_package_name=None,
191-
model_package_group_name=None,
192-
image_uri=None,
193-
model_metrics=None,
194-
metadata_properties=None,
195-
marketplace_cert=False,
196-
approval_status=None,
197-
description=None,
198-
tags=None,
199-
):
200-
"""Get arguments for session.create_model_package method.
201-
202-
Args:
203-
content_types (list): The supported MIME types for the input data.
204-
response_types (list): The supported MIME types for the output data.
205-
inference_instances (list): A list of the instance types that are used to
206-
generate inferences in real-time.
207-
transform_instances (list): A list of the instance types on which a transformation
208-
job can be run or on which an endpoint can be deployed.
209-
model_package_name (str): Model Package name, exclusive to `model_package_group_name`,
210-
using `model_package_name` makes the Model Package un-versioned (default: None).
211-
model_package_group_name (str): Model Package Group name, exclusive to
212-
`model_package_name`, using `model_package_group_name` makes the Model Package
213-
versioned (default: None).
214-
image_uri (str): Inference image uri for the container. Model class' self.image will
215-
be used if it is None (default: None).
216-
model_metrics (ModelMetrics): ModelMetrics object (default: None).
217-
metadata_properties (MetadataProperties): MetadataProperties object (default: None).
218-
marketplace_cert (bool): A boolean value indicating if the Model Package is certified
219-
for AWS Marketplace (default: False).
220-
approval_status (str): Model Approval Status, values can be "Approved", "Rejected",
221-
or "PendingManualApproval" (default: "PendingManualApproval").
222-
description (str): Model Package description (default: None).
223-
Returns:
224-
dict: A dictionary of method argument names and values.
225-
"""
226-
if image_uri:
227-
self.image_uri = image_uri
228-
container = {
229-
"Image": self.image_uri,
230-
"ModelDataUrl": self.model_data,
231-
}
232-
233-
model_package_args = {
234-
"containers": [container],
235-
"content_types": content_types,
236-
"response_types": response_types,
237-
"inference_instances": inference_instances,
238-
"transform_instances": transform_instances,
239-
"marketplace_cert": marketplace_cert,
240-
}
241-
242-
if model_package_name is not None:
243-
model_package_args["model_package_name"] = model_package_name
244-
if model_package_group_name is not None:
245-
model_package_args["model_package_group_name"] = model_package_group_name
246-
if model_metrics is not None:
247-
model_package_args["model_metrics"] = model_metrics._to_request_dict()
248-
if metadata_properties is not None:
249-
model_package_args["metadata_properties"] = metadata_properties._to_request_dict()
250-
if approval_status is not None:
251-
model_package_args["approval_status"] = approval_status
252-
if description is not None:
253-
model_package_args["description"] = description
254-
if tags is not None:
255-
model_package_args["tags"] = tags
256-
return model_package_args
257-
258185
def _init_sagemaker_session_if_does_not_exist(self, instance_type):
259186
"""Set ``self.sagemaker_session`` to ``LocalSession`` or ``Session`` if it's not already.
260187
@@ -1128,6 +1055,10 @@ def _upload_code(self, key_prefix, repack=False):
11281055
)
11291056

11301057
if repack and self.model_data is not None and self.entry_point is not None:
1058+
if isinstance(self.model_data, sagemaker.workflow.properties.Properties):
1059+
# model is not yet there, defer repacking to later during pipeline execution
1060+
return
1061+
11311062
bucket = self.bucket or self.sagemaker_session.default_bucket()
11321063
repacked_model_data = "s3://" + "/".join([bucket, key_prefix, "model.tar.gz"])
11331064

0 commit comments

Comments
 (0)