Skip to content

Commit d3f5761

Browse files
authored
Merge branch 'master' into fix-issue-2426
2 parents fcd2615 + c12fd49 commit d3f5761

16 files changed

+181
-82
lines changed

CHANGELOG.md

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

3+
## v2.50.1 (2021-08-02)
4+
5+
### Bug Fixes and Other Changes
6+
7+
* null checks for uploaded_code and entry_point
8+
9+
### Documentation Changes
10+
11+
* update sagemaker.estimator.EstimatorBase
12+
* Mark baseline as optional in KernelSHAP.
13+
314
## v2.50.0 (2021-07-28)
415

516
### Features

VERSION

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

doc/workflows/pipelines/index.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
################
2-
Amazon Pipelines
3-
################
1+
###################
2+
SageMaker Pipelines
3+
###################
44

5-
SageMaker APIs for creating and managing Amazon Pipelines.
5+
SageMaker APIs for creating and managing SageMaker Pipelines.
66

77
.. toctree::
88
:maxdepth: 2

doc/workflows/pipelines/sagemaker.workflow.pipelines.rst

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ Conditions
3333

3434
.. autoclass:: sagemaker.workflow.conditions.ConditionOr
3535

36-
.. autofunction:: sagemaker.workflow.conditions.primitive_or_expr
37-
3836
Entities
3937
--------
4038

@@ -44,7 +42,7 @@ Entities
4442

4543
.. autoclass:: sagemaker.workflow.entities.Expression
4644

47-
Execution_variables
45+
Execution Variables
4846
-------------------
4947

5048
.. autoclass:: sagemaker.workflow.execution_variables.ExecutionVariable
@@ -75,12 +73,17 @@ Pipeline
7573
--------
7674

7775
.. autoclass:: sagemaker.workflow.pipeline.Pipeline
76+
:members:
77+
78+
.. autoclass:: sagemaker.workflow.pipeline._PipelineExecution
79+
:members:
7880

79-
.. autofunction:: sagemaker.workflow.pipeline.format_start_parameters
81+
Pipeline Experiment Config
82+
--------------------------
8083

81-
.. autofunction:: sagemaker.workflow.pipeline.interpolate
84+
.. autoclass:: sagemaker.workflow.pipeline_experiment_config.PipelineExperimentConfig
8285

83-
.. autofunction:: sagemaker.workflow.pipeline.update_args
86+
.. autoclass:: sagemaker.workflow.pipeline_experiment_config.PipelineExperimentConfigProperty
8487

8588
Properties
8689
----------
@@ -123,7 +126,4 @@ Steps
123126

124127
.. autoclass:: sagemaker.workflow.callback_step.CallbackStep
125128

126-
Utilities
127-
---------
128-
129-
.. autofunction:: sagemaker.workflow.utilities.list_to_request
129+
.. autoclass:: sagemaker.workflow.steps.CacheConfig

src/sagemaker/clarify.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -305,10 +305,11 @@ def __init__(
305305
"""Initializes config for SHAP.
306306
307307
Args:
308-
baseline (str or list): A list of rows (at least one) or S3 object URI to be used as
309-
the baseline dataset in the Kernel SHAP algorithm. The format should be the same
310-
as the dataset format. Each row should contain only the feature columns/values
311-
and omit the label column/values.
308+
baseline (None or str or list): None or S3 object Uri or A list of rows (at least one)
309+
to be used asthe baseline dataset in the Kernel SHAP algorithm. The format should
310+
be the same as the dataset format. Each row should contain only the feature
311+
columns/values and omit the label column/values. If None a baseline will be
312+
calculated automatically by using K-means or K-prototypes in the input dataset.
312313
num_samples (int): Number of samples to be used in the Kernel SHAP algorithm.
313314
This number determines the size of the generated synthetic dataset to compute the
314315
SHAP values.

src/sagemaker/estimator.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,10 @@ def __init__(
164164
file:// urls are used for local mode. For example: 'file://model/'
165165
will save to the model folder in the current directory.
166166
output_kms_key (str): Optional. KMS key ID for encrypting the
167-
training output (default: None).
167+
training output (default: Your IAM role's KMS key for Amazon S3).
168+
If you don't provide a KMS key ID, Amazon SageMaker uses the
169+
default KMS key for Amazon S3 of the account linked to your
170+
IAM role.
168171
base_job_name (str): Prefix for training job name when the
169172
:meth:`~sagemaker.estimator.EstimatorBase.fit` method launches.
170173
If not specified, the estimator generates a default job name
@@ -2319,9 +2322,13 @@ def _model_source_dir(self):
23192322
str: Either a local or an S3 path pointing to the ``source_dir`` to be
23202323
used for code by the model to be deployed
23212324
"""
2322-
return (
2323-
self.source_dir if self.sagemaker_session.local_mode else self.uploaded_code.s3_prefix
2324-
)
2325+
if self.sagemaker_session.local_mode:
2326+
return self.source_dir
2327+
2328+
if self.uploaded_code is not None:
2329+
return self.uploaded_code.s3_prefix
2330+
2331+
return None
23252332

23262333
def _model_entry_point(self):
23272334
"""Get the appropriate value to pass as ``entry_point`` to a model constructor.
@@ -2333,7 +2340,10 @@ def _model_entry_point(self):
23332340
if self.sagemaker_session.local_mode or (self._model_source_dir() is None):
23342341
return self.entry_point
23352342

2336-
return self.uploaded_code.script_name
2343+
if self.uploaded_code is not None:
2344+
return self.uploaded_code.script_name
2345+
2346+
return None
23372347

23382348
def hyperparameters(self):
23392349
"""Return the hyperparameters as a dictionary to use for training.

src/sagemaker/workflow/_utils.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,9 @@ def arguments(self) -> RequestType:
312312
model = self.estimator.create_model(**self.kwargs)
313313
self.image_uri = model.image_uri
314314

315+
if self.model_data is None:
316+
self.model_data = model.model_data
317+
315318
# reset placeholder
316319
self.estimator.output_path = output_path
317320

src/sagemaker/workflow/condition_step.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ def __init__(
5656
conditions (List[Condition]): A list of `sagemaker.workflow.conditions.Condition`
5757
instances.
5858
if_steps (List[Union[Step, StepCollection]]): A list of `sagemaker.workflow.steps.Step`
59-
and `sagemaker.workflow.step_collections.StepCollection` instances that are
59+
or `sagemaker.workflow.step_collections.StepCollection` instances that are
6060
marked as ready for execution if the list of conditions evaluates to True.
6161
else_steps (List[Union[Step, StepCollection]]): A list of `sagemaker.workflow.steps.Step`
62-
and `sagemaker.workflow.step_collections.StepCollection` instances that are
62+
or `sagemaker.workflow.step_collections.StepCollection` instances that are
6363
marked as ready for execution if the list of conditions evaluates to False.
6464
"""
6565
super(ConditionStep, self).__init__(name, StepTypeEnum.CONDITION, depends_on)

src/sagemaker/workflow/conditions.py

Lines changed: 43 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,13 @@ class ConditionComparison(Condition):
6666
"""Generic comparison condition that can be used to derive specific condition comparisons.
6767
6868
Attributes:
69-
left (ConditionValueType): The execution variable, parameter, or
70-
property to use in the comparison.
69+
left (Union[ConditionValueType, PrimitiveType]): The execution variable, parameter,
70+
property, or Python primitive value to use in the comparison.
7171
right (Union[ConditionValueType, PrimitiveType]): The execution variable,
7272
parameter, property, or Python primitive value to compare to.
7373
"""
7474

75-
left: ConditionValueType = attr.ib(default=None)
75+
left: Union[ConditionValueType, PrimitiveType] = attr.ib(default=None)
7676
right: Union[ConditionValueType, PrimitiveType] = attr.ib(default=None)
7777

7878
def to_request(self) -> RequestType:
@@ -87,12 +87,16 @@ def to_request(self) -> RequestType:
8787
class ConditionEquals(ConditionComparison):
8888
"""A condition for equality comparisons."""
8989

90-
def __init__(self, left: ConditionValueType, right: Union[ConditionValueType, PrimitiveType]):
90+
def __init__(
91+
self,
92+
left: Union[ConditionValueType, PrimitiveType],
93+
right: Union[ConditionValueType, PrimitiveType],
94+
):
9195
"""Construct A condition for equality comparisons.
9296
9397
Args:
94-
left (ConditionValueType): The execution variable, parameter,
95-
or property to use in the comparison.
98+
left (Union[ConditionValueType, PrimitiveType]): The execution variable,
99+
parameter, property, or Python primitive value to use in the comparison.
96100
right (Union[ConditionValueType, PrimitiveType]): The execution
97101
variable, parameter, property, or Python primitive value to compare to.
98102
"""
@@ -103,12 +107,16 @@ def __init__(self, left: ConditionValueType, right: Union[ConditionValueType, Pr
103107
class ConditionGreaterThan(ConditionComparison):
104108
"""A condition for greater than comparisons."""
105109

106-
def __init__(self, left: ConditionValueType, right: Union[ConditionValueType, PrimitiveType]):
110+
def __init__(
111+
self,
112+
left: Union[ConditionValueType, PrimitiveType],
113+
right: Union[ConditionValueType, PrimitiveType],
114+
):
107115
"""Construct an instance of ConditionGreaterThan for greater than comparisons.
108116
109117
Args:
110-
left (ConditionValueType): The execution variable, parameter,
111-
or property to use in the comparison.
118+
left (Union[ConditionValueType, PrimitiveType]): The execution variable,
119+
parameter, property, or Python primitive value to use in the comparison.
112120
right (Union[ConditionValueType, PrimitiveType]): The execution
113121
variable, parameter, property, or Python primitive value to compare to.
114122
"""
@@ -119,12 +127,16 @@ def __init__(self, left: ConditionValueType, right: Union[ConditionValueType, Pr
119127
class ConditionGreaterThanOrEqualTo(ConditionComparison):
120128
"""A condition for greater than or equal to comparisons."""
121129

122-
def __init__(self, left: ConditionValueType, right: Union[ConditionValueType, PrimitiveType]):
130+
def __init__(
131+
self,
132+
left: Union[ConditionValueType, PrimitiveType],
133+
right: Union[ConditionValueType, PrimitiveType],
134+
):
123135
"""Construct of ConditionGreaterThanOrEqualTo for greater than or equal to comparisons.
124136
125137
Args:
126-
left (ConditionValueType): The execution variable, parameter,
127-
or property to use in the comparison.
138+
left (Union[ConditionValueType, PrimitiveType]): The execution variable,
139+
parameter, property, or Python primitive value to use in the comparison.
128140
right (Union[ConditionValueType, PrimitiveType]): The execution
129141
variable, parameter, property, or Python primitive value to compare to.
130142
"""
@@ -135,12 +147,16 @@ def __init__(self, left: ConditionValueType, right: Union[ConditionValueType, Pr
135147
class ConditionLessThan(ConditionComparison):
136148
"""A condition for less than comparisons."""
137149

138-
def __init__(self, left: ConditionValueType, right: Union[ConditionValueType, PrimitiveType]):
150+
def __init__(
151+
self,
152+
left: Union[ConditionValueType, PrimitiveType],
153+
right: Union[ConditionValueType, PrimitiveType],
154+
):
139155
"""Construct an instance of ConditionLessThan for less than comparisons.
140156
141157
Args:
142-
left (ConditionValueType): The execution variable, parameter,
143-
or property to use in the comparison.
158+
left (Union[ConditionValueType, PrimitiveType]): The execution variable,
159+
parameter, property, or Python primitive value to use in the comparison.
144160
right (Union[ConditionValueType, PrimitiveType]): The execution
145161
variable, parameter, property, or Python primitive value to compare to.
146162
"""
@@ -151,12 +167,16 @@ def __init__(self, left: ConditionValueType, right: Union[ConditionValueType, Pr
151167
class ConditionLessThanOrEqualTo(ConditionComparison):
152168
"""A condition for less than or equal to comparisons."""
153169

154-
def __init__(self, left: ConditionValueType, right: Union[ConditionValueType, PrimitiveType]):
170+
def __init__(
171+
self,
172+
left: Union[ConditionValueType, PrimitiveType],
173+
right: Union[ConditionValueType, PrimitiveType],
174+
):
155175
"""Construct ConditionLessThanOrEqualTo for less than or equal to comparisons.
156176
157177
Args:
158-
left (ConditionValueType): The execution variable, parameter,
159-
or property to use in the comparison.
178+
left (Union[ConditionValueType, PrimitiveType]): The execution variable,
179+
parameter, property, or Python primitive value to use in the comparison.
160180
right (Union[ConditionValueType, PrimitiveType]): The execution
161181
variable, parameter, property, or Python primitive value to compare to.
162182
"""
@@ -168,13 +188,15 @@ class ConditionIn(Condition):
168188
"""A condition to check membership."""
169189

170190
def __init__(
171-
self, value: ConditionValueType, in_values: List[Union[ConditionValueType, PrimitiveType]]
191+
self,
192+
value: Union[ConditionValueType, PrimitiveType],
193+
in_values: List[Union[ConditionValueType, PrimitiveType]],
172194
):
173195
"""Construct a `ConditionIn` condition to check membership.
174196
175197
Args:
176-
value (ConditionValueType): The execution variable,
177-
parameter, or property to use for the in comparison.
198+
value (Union[ConditionValueType, PrimitiveType]): The execution variable,
199+
parameter, property or primitive value to check for membership.
178200
in_values (List[Union[ConditionValueType, PrimitiveType]]): The list
179201
of values to check for membership in.
180202
"""

src/sagemaker/workflow/execution_variables.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,7 @@ def expr(self) -> RequestType:
3737

3838

3939
class ExecutionVariables:
40-
"""Enum-like class for all ExecutionVariable instances.
41-
42-
Considerations to move these as module-level constants should be made.
43-
"""
40+
"""All available ExecutionVariable."""
4441

4542
START_DATETIME = ExecutionVariable("StartDateTime")
4643
CURRENT_DATETIME = ExecutionVariable("CurrentDateTime")

src/sagemaker/workflow/functions.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,19 @@
2525
class Join(Expression):
2626
"""Join together properties.
2727
28+
Examples:
29+
Build a Amazon S3 Uri with bucket name parameter and pipeline execution Id and use it
30+
as training input::
31+
32+
bucket = ParameterString('bucket', default_value='my-bucket')
33+
34+
TrainingInput(
35+
s3_data=Join(on='/', ['s3:/', bucket, ExecutionVariables.PIPELINE_EXECUTION_ID]),
36+
content_type="text/csv")
37+
2838
Attributes:
29-
values (List[Union[PrimitiveType, Parameter]]): The primitive types
30-
and parameters to join.
39+
values (List[Union[PrimitiveType, Parameter, Expression]]):
40+
The primitive type values, parameters, step properties, expressions to join.
3141
on_str (str): The string to join the values on (Defaults to "").
3242
"""
3343

0 commit comments

Comments
 (0)