Skip to content

Commit 1e81d4f

Browse files
authored
Merge branch 'master' into docs-clickable
2 parents f911c20 + afa0b42 commit 1e81d4f

File tree

6 files changed

+41
-23
lines changed

6 files changed

+41
-23
lines changed

doc/overview.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,7 @@ You can install all necessary for this feature dependencies using pip:
672672
For more detailed examples of running hyperparameter tuning jobs, see:
673673

674674
- `Using the TensorFlow estimator with hyperparameter tuning <https://github.com/awslabs/amazon-sagemaker-examples/blob/master/hyperparameter_tuning/tensorflow_mnist/hpo_tensorflow_mnist.ipynb>`__
675-
- `Bringing your own estimator for hyperparameter tuning <https://github.com/awslabs/amazon-sagemaker-examples/blob/master/hyperparameter_tuning/r_bring_your_own/hpo_r_bring_your_own.ipynb>`__
675+
- `Bringing your own estimator for hyperparameter tuning <https://github.com/awslabs/amazon-sagemaker-examples/blob/master/hyperparameter_tuning/r_bring_your_own/tune_r_bring_your_own.ipynb>`__
676676
- `Analyzing results <https://github.com/awslabs/amazon-sagemaker-examples/blob/master/hyperparameter_tuning/analyze_results/HPO_Analyze_TuningJob_Results.ipynb>`__
677677

678678
You can also find these notebooks in the **Hyperprameter Tuning** section of the **SageMaker Examples** section in a notebook instance.

src/sagemaker/deprecations.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,22 +51,24 @@ def renamed_warning(phrase):
5151
_warn(f"{phrase} has been renamed")
5252

5353

54-
def renamed_kwargs(name, default, kwargs):
54+
def renamed_kwargs(old_name, new_name, value, kwargs):
5555
"""Checks if the deprecated argument is in kwargs
5656
5757
Raises warning, if present.
5858
5959
Args:
60-
name: name of deprecated argument
61-
default: default value to use, if not present
60+
old_name: name of deprecated argument
61+
new_name: name of the new argument
62+
value: value associated with new name, if supplied
6263
kwargs: keyword arguments dict
6364
6465
Returns:
6566
value of the keyword argument, if present
6667
"""
67-
value = kwargs.get(name, default)
68-
if value != default:
69-
renamed_warning(name)
68+
if old_name in kwargs:
69+
value = kwargs.get(old_name, value)
70+
kwargs[new_name] = value
71+
renamed_warning(old_name)
7072
return value
7173

7274

src/sagemaker/estimator.py

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,8 @@ def __init__(
207207
:class:`~sagemaker.debugger.Rule` objects used to define
208208
rules for continuous analysis with SageMaker Debugger
209209
(default: ``None``). For more, see
210-
https://sagemaker.readthedocs.io/en/stable/amazon_sagemaker_debugger.html#continuous-analyses-through-rules
210+
https://sagemaker.readthedocs.io/en/stable/amazon_sagemaker_debugger.html#
211+
continuous-analyses-through-rules
211212
debugger_hook_config (:class:`~sagemaker.debugger.DebuggerHookConfig` or bool):
212213
Configuration for how debugging information is emitted with
213214
SageMaker Debugger. If not specified, a default one is created using
@@ -218,24 +219,34 @@ def __init__(
218219
tensorboard_output_config (:class:`~sagemaker.debugger.TensorBoardOutputConfig`):
219220
Configuration for customizing debugging visualization using TensorBoard
220221
(default: ``None``). For more, see
221-
https://sagemaker.readthedocs.io/en/stable/amazon_sagemaker_debugger.html#capture-real-time-tensorboard-data-from-the-debugging-hook
222+
https://sagemaker.readthedocs.io/en/stable/amazon_sagemaker_debugger.html#
223+
capture-real-time-tensorboard-data-from-the-debugging-hook
222224
enable_sagemaker_metrics (bool): Enables SageMaker Metrics Time
223225
Series. For more information see:
224-
https://docs.aws.amazon.com/sagemaker/latest/dg/API_AlgorithmSpecification.html#SageMaker-Type-AlgorithmSpecification-EnableSageMakerMetricsTimeSeries
226+
https://docs.aws.amazon.com/sagemaker/latest/dg/API_AlgorithmSpecification.html#
227+
SageMaker-Type-AlgorithmSpecification-EnableSageMakerMetricsTimeSeries
225228
(default: ``None``).
226229
enable_network_isolation (bool): Specifies whether container will
227230
run in network isolation mode (default: ``False``). Network
228231
isolation mode restricts the container access to outside networks
229232
(such as the Internet). The container does not make any inbound or
230233
outbound network calls. Also known as Internet-free mode.
231234
"""
232-
instance_count = renamed_kwargs("train_instance_count", instance_count, kwargs)
233-
instance_type = renamed_kwargs("train_instance_type", instance_type, kwargs)
234-
max_run = renamed_kwargs("train_max_run", max_run, kwargs)
235-
use_spot_instances = renamed_kwargs("train_use_spot_instances", use_spot_instances, kwargs)
236-
max_wait = renamed_kwargs("train_max_run_wait", max_wait, kwargs)
237-
volume_size = renamed_kwargs("train_volume_size", volume_size, kwargs)
238-
volume_kms_key = renamed_kwargs("train_volume_kms_key", volume_kms_key, kwargs)
235+
instance_count = renamed_kwargs(
236+
"train_instance_count", "instance_count", instance_count, kwargs
237+
)
238+
instance_type = renamed_kwargs(
239+
"train_instance_type", "instance_type", instance_type, kwargs
240+
)
241+
max_run = renamed_kwargs("train_max_run", "max_run", max_run, kwargs)
242+
use_spot_instances = renamed_kwargs(
243+
"train_use_spot_instances", "use_spot_instances", use_spot_instances, kwargs
244+
)
245+
max_wait = renamed_kwargs("train_max_run_wait", "max_wait", max_wait, kwargs)
246+
volume_size = renamed_kwargs("train_volume_size", "volume_size", volume_size, kwargs)
247+
volume_kms_key = renamed_kwargs(
248+
"train_volume_kms_key", "volume_kms_key", volume_kms_key, kwargs
249+
)
239250

240251
if instance_count is None or instance_type is None:
241252
raise ValueError("Both instance_count and instance_type are required.")

src/sagemaker/mxnet/estimator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ def __init__(
149149
:class:`~sagemaker.estimator.Framework` and
150150
:class:`~sagemaker.estimator.EstimatorBase`.
151151
"""
152-
distribution = renamed_kwargs("distributions", distribution, kwargs)
152+
distribution = renamed_kwargs("distributions", "distribution", distribution, kwargs)
153153
validate_version_or_image_args(framework_version, py_version, image_uri)
154154
if py_version == "py2":
155155
logger.warning(

src/sagemaker/predictor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def __init__(
8080
"""
8181
removed_kwargs("content_type", kwargs)
8282
removed_kwargs("accept", kwargs)
83-
endpoint_name = renamed_kwargs("endpoint", endpoint_name, kwargs)
83+
endpoint_name = renamed_kwargs("endpoint", "endpoint_name", endpoint_name, kwargs)
8484
self.endpoint_name = endpoint_name
8585
self.sagemaker_session = sagemaker_session or Session()
8686
self.serializer = serializer

tests/unit/test_deprecations.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,19 @@
2727

2828

2929
def test_renamed_kwargs():
30-
kwargs, b = {"a": 1}, 2
31-
val = renamed_kwargs("b", default=b, kwargs=kwargs)
30+
kwargs, c = {"a": 1}, 2
31+
val = renamed_kwargs("b", new_name="c", value=c, kwargs=kwargs)
32+
assert val == 2
33+
34+
kwargs, c = {"a": 1, "c": 2}, 2
35+
val = renamed_kwargs("b", new_name="c", value=c, kwargs=kwargs)
3236
assert val == 2
3337

3438
with pytest.warns(DeprecationWarning):
35-
kwargs, b = {"a": 1, "b": 3}, 2
36-
val = renamed_kwargs("b", default=b, kwargs=kwargs)
39+
kwargs, c = {"a": 1, "b": 3}, 2
40+
val = renamed_kwargs("b", new_name="c", value=c, kwargs=kwargs)
3741
assert val == 3
42+
assert kwargs == {"a": 1, "b": 3, "c": 3}
3843

3944

4045
def test_removed_arg():

0 commit comments

Comments
 (0)