Skip to content

Commit 792026f

Browse files
authored
Merge branch 'master' into lambda-model
2 parents d46cd24 + 7d56242 commit 792026f

File tree

18 files changed

+1096
-217
lines changed

18 files changed

+1096
-217
lines changed

CHANGELOG.md

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

3+
## v2.49.0 (2021-07-15)
4+
5+
### Features
6+
7+
* Adding serial inference pipeline support to RegisterModel Step
8+
9+
### Documentation Changes
10+
11+
* add tuning step get_top_model_s3_uri and callback step to doc
12+
* links for HF in sdk
13+
* Add Clarify module to Model Monitoring API docs
14+
315
## v2.48.2 (2021-07-12)
416

517
### 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.1.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/model.py

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

179-
model_pkg_args = self._get_model_package_args(
179+
model_pkg_args = sagemaker.get_model_package_args(
180180
content_types,
181181
response_types,
182182
inference_instances,
183183
transform_instances,
184184
model_package_name,
185185
model_package_group_name,
186-
image_uri,
186+
self.model_data,
187+
image_uri or self.image_uri,
187188
model_metrics,
188189
metadata_properties,
189190
marketplace_cert,
@@ -199,80 +200,6 @@ def register(
199200
model_package_arn=model_package.get("ModelPackageArn"),
200201
)
201202

202-
def _get_model_package_args(
203-
self,
204-
content_types,
205-
response_types,
206-
inference_instances,
207-
transform_instances,
208-
model_package_name=None,
209-
model_package_group_name=None,
210-
image_uri=None,
211-
model_metrics=None,
212-
metadata_properties=None,
213-
marketplace_cert=False,
214-
approval_status=None,
215-
description=None,
216-
tags=None,
217-
):
218-
"""Get arguments for session.create_model_package method.
219-
220-
Args:
221-
content_types (list): The supported MIME types for the input data.
222-
response_types (list): The supported MIME types for the output data.
223-
inference_instances (list): A list of the instance types that are used to
224-
generate inferences in real-time.
225-
transform_instances (list): A list of the instance types on which a transformation
226-
job can be run or on which an endpoint can be deployed.
227-
model_package_name (str): Model Package name, exclusive to `model_package_group_name`,
228-
using `model_package_name` makes the Model Package un-versioned (default: None).
229-
model_package_group_name (str): Model Package Group name, exclusive to
230-
`model_package_name`, using `model_package_group_name` makes the Model Package
231-
versioned (default: None).
232-
image_uri (str): Inference image uri for the container. Model class' self.image will
233-
be used if it is None (default: None).
234-
model_metrics (ModelMetrics): ModelMetrics object (default: None).
235-
metadata_properties (MetadataProperties): MetadataProperties object (default: None).
236-
marketplace_cert (bool): A boolean value indicating if the Model Package is certified
237-
for AWS Marketplace (default: False).
238-
approval_status (str): Model Approval Status, values can be "Approved", "Rejected",
239-
or "PendingManualApproval" (default: "PendingManualApproval").
240-
description (str): Model Package description (default: None).
241-
Returns:
242-
dict: A dictionary of method argument names and values.
243-
"""
244-
if image_uri:
245-
self.image_uri = image_uri
246-
container = {
247-
"Image": self.image_uri,
248-
"ModelDataUrl": self.model_data,
249-
}
250-
251-
model_package_args = {
252-
"containers": [container],
253-
"content_types": content_types,
254-
"response_types": response_types,
255-
"inference_instances": inference_instances,
256-
"transform_instances": transform_instances,
257-
"marketplace_cert": marketplace_cert,
258-
}
259-
260-
if model_package_name is not None:
261-
model_package_args["model_package_name"] = model_package_name
262-
if model_package_group_name is not None:
263-
model_package_args["model_package_group_name"] = model_package_group_name
264-
if model_metrics is not None:
265-
model_package_args["model_metrics"] = model_metrics._to_request_dict()
266-
if metadata_properties is not None:
267-
model_package_args["metadata_properties"] = metadata_properties._to_request_dict()
268-
if approval_status is not None:
269-
model_package_args["approval_status"] = approval_status
270-
if description is not None:
271-
model_package_args["description"] = description
272-
if tags is not None:
273-
model_package_args["tags"] = tags
274-
return model_package_args
275-
276203
def _init_sagemaker_session_if_does_not_exist(self, instance_type):
277204
"""Set ``self.sagemaker_session`` to ``LocalSession`` or ``Session`` if it's not already.
278205
@@ -1148,6 +1075,10 @@ def _upload_code(self, key_prefix, repack=False):
11481075
)
11491076

11501077
if repack and self.model_data is not None and self.entry_point is not None:
1078+
if isinstance(self.model_data, sagemaker.workflow.properties.Properties):
1079+
# model is not yet there, defer repacking to later during pipeline execution
1080+
return
1081+
11511082
bucket = self.bucket or self.sagemaker_session.default_bucket()
11521083
repacked_model_data = "s3://" + "/".join([bucket, key_prefix, "model.tar.gz"])
11531084

0 commit comments

Comments
 (0)