Skip to content

Commit 69e6fe0

Browse files
author
Kim
committed
Merge branch 'master' of https://github.com/aws/sagemaker-python-sdk into xgboost_get_image_uri
2 parents 16768ff + 382d86f commit 69e6fe0

27 files changed

+274
-15
lines changed

CHANGELOG.md

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

3+
## v1.58.4 (2020-05-20)
4+
5+
### Bug Fixes and Other Changes
6+
7+
* update AutoML default max_candidate value to use the service default
8+
* add describe_transform_job in session class
9+
10+
### Documentation Changes
11+
12+
* clarify support for requirements.txt in Tensorflow docs
13+
14+
### Testing and Release Infrastructure
15+
16+
* wait for DisassociateTrialComponent to take effect in experiment integ test cleanup
17+
318
## v1.58.3 (2020-05-19)
419

520
### Bug Fixes and Other Changes

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ By using MXNet SageMaker Estimators, you can train and host MXNet models on Amaz
205205

206206
Supported versions of MXNet: ``0.12.1``, ``1.0.0``, ``1.1.0``, ``1.2.1``, ``1.3.0``, ``1.4.0``, ``1.4.1``, ``1.6.0``.
207207

208-
Supported versions of MXNet for Elastic Inference: ``1.3.0``, ``1.4.0``, ``1.4.1``.
208+
Supported versions of MXNet for Elastic Inference: ``1.3.0``, ``1.4.0``, ``1.4.1``, ``1.5.1``.
209209

210210
We recommend that you use the latest supported version, because that's where we focus most of our development efforts.
211211

VERSION

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

doc/overview.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -732,6 +732,26 @@ You can install all necessary for this feature dependencies using pip:
732732

733733
pip install 'sagemaker[local]' --upgrade
734734

735+
If you want to keep everything local, and not use Amazon S3 either, you can enable "local code" in one of two ways:
736+
737+
- Create a file at ``~/.sagemaker/config.yaml`` that contains:
738+
739+
.. code:: yaml
740+
741+
local:
742+
local_code: true
743+
744+
- Create a ``LocalSession`` and configure it directly:
745+
746+
.. code:: python
747+
748+
from sagemaker.local import LocalSession
749+
750+
sagemaker_session = LocalSession()
751+
sagemaker_session.config = {'local': {'local_code': True}}
752+
753+
# pass sagemaker_session to your estimator or model
754+
735755
We can take the example in `Using Estimators <#using-estimators>`__ , and use either ``local`` or ``local_gpu`` as the instance type.
736756

737757
.. code:: python

src/sagemaker/__init__.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
"""Placeholder docstring"""
1414
from __future__ import absolute_import
1515

16+
import logging
17+
import sys
1618
import importlib_metadata
1719

1820
from sagemaker import estimator, parameter, tuner # noqa: F401
@@ -61,3 +63,10 @@
6163
from sagemaker.automl.candidate_estimator import CandidateEstimator, CandidateStep # noqa: F401
6264

6365
__version__ = importlib_metadata.version("sagemaker")
66+
67+
if sys.version[0] == "2":
68+
logging.getLogger("sagemaker").warning(
69+
"SageMaker Python SDK v2 will no longer support Python 2. "
70+
"Please see https://github.com/aws/sagemaker-python-sdk/issues/1459 "
71+
"for more information"
72+
)

src/sagemaker/amazon/amazon_estimator.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -616,6 +616,11 @@ def get_image_uri(region_name, repo_name, repo_version=1):
616616
repo_name:
617617
repo_version:
618618
"""
619+
logger.warning(
620+
"'get_image_uri' method will be deprecated in favor of 'ImageURIProvider' class "
621+
"in SageMaker Python SDK v2."
622+
)
623+
619624
repo_version = str(repo_version)
620625

621626
if repo_name == XGBOOST_NAME:

src/sagemaker/estimator.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
UploadedCode,
4040
validate_source_dir,
4141
_region_supports_debugger,
42+
parameter_v2_rename_warning,
4243
)
4344
from sagemaker.job import _Job
4445
from sagemaker.local import LocalSession
@@ -1273,6 +1274,7 @@ def __init__(
12731274
https://docs.aws.amazon.com/sagemaker/latest/dg/API_AlgorithmSpecification.html#SageMaker-Type-AlgorithmSpecification-EnableSageMakerMetricsTimeSeries
12741275
(default: ``None``).
12751276
"""
1277+
logging.warning(parameter_v2_rename_warning("image_name", "image_uri"))
12761278
self.image_name = image_name
12771279
self.hyperparam_dict = hyperparameters.copy() if hyperparameters else {}
12781280
super(Estimator, self).__init__(
@@ -1637,6 +1639,8 @@ def __init__(
16371639
self.container_log_level = container_log_level
16381640
self.code_location = code_location
16391641
self.image_name = image_name
1642+
if image_name is not None:
1643+
logging.warning(parameter_v2_rename_warning("image_name", "image_uri"))
16401644

16411645
self.uploaded_code = None
16421646

@@ -1722,11 +1726,14 @@ def _stage_user_code_in_s3(self):
17221726
code_bucket = self.sagemaker_session.default_bucket()
17231727
code_s3_prefix = "{}/{}".format(self._current_job_name, "source")
17241728
kms_key = None
1725-
17261729
elif self.code_location is None:
17271730
code_bucket, _ = parse_s3_url(self.output_path)
17281731
code_s3_prefix = "{}/{}".format(self._current_job_name, "source")
17291732
kms_key = self.output_kms_key
1733+
elif local_mode:
1734+
code_bucket, key_prefix = parse_s3_url(self.code_location)
1735+
code_s3_prefix = "/".join(filter(None, [key_prefix, self._current_job_name, "source"]))
1736+
kms_key = None
17301737
else:
17311738
code_bucket, key_prefix = parse_s3_url(self.code_location)
17321739
code_s3_prefix = "/".join(filter(None, [key_prefix, self._current_job_name, "source"]))

src/sagemaker/fw_utils.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@
3434
instantiated with positional or keyword arguments.
3535
"""
3636

37-
EMPTY_FRAMEWORK_VERSION_WARNING = "No framework_version specified, defaulting to version {}."
37+
EMPTY_FRAMEWORK_VERSION_WARNING = (
38+
"No framework_version specified, defaulting to version {}. "
39+
"framework_version will be required in SageMaker Python SDK v2."
40+
)
3841
LATER_FRAMEWORK_VERSION_WARNING = (
3942
"This is not the latest supported version. "
4043
"If you would like to use version {latest}, "
@@ -52,6 +55,10 @@
5255
"fully leverage all GPU cores; the parameter server will be configured to run "
5356
"only one worker per host regardless of the number of GPUs."
5457
)
58+
PARAMETER_V2_RENAME_WARNING = (
59+
"Parameter {v1_parameter_name} will be renamed to {v2_parameter_name} "
60+
"in SageMaker Python SDK v2."
61+
)
5562

5663

5764
EMPTY_FRAMEWORK_VERSION_ERROR = (
@@ -253,6 +260,11 @@ def create_image_uri(
253260
Returns:
254261
str: The appropriate image URI based on the given parameters.
255262
"""
263+
logger.warning(
264+
"'create_image_uri' will be deprecated in favor of 'ImageURIProvider' class "
265+
"in SageMaker Python SDK v2."
266+
)
267+
256268
optimized_families = optimized_families or []
257269

258270
if py_version and py_version not in VALID_PY_VERSIONS:
@@ -647,6 +659,17 @@ def python_deprecation_warning(framework, latest_supported_version):
647659
)
648660

649661

662+
def parameter_v2_rename_warning(v1_parameter_name, v2_parameter_name):
663+
"""
664+
Args:
665+
v1_parameter_name: parameter name used in SageMaker Python SDK v1
666+
v2_parameter_name: parameter name used in SageMaker Python SDK v2
667+
"""
668+
return PARAMETER_V2_RENAME_WARNING.format(
669+
v1_parameter_name=v1_parameter_name, v2_parameter_name=v2_parameter_name
670+
)
671+
672+
650673
def _region_supports_debugger(region_name):
651674
"""Returns boolean indicating whether the region supports Amazon SageMaker Debugger.
652675

src/sagemaker/inputs.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,13 @@
1313
"""Amazon SageMaker channel configurations for S3 data sources and file system data sources"""
1414
from __future__ import absolute_import, print_function
1515

16+
import logging
17+
1618
FILE_SYSTEM_TYPES = ["FSxLustre", "EFS"]
1719
FILE_SYSTEM_ACCESS_MODES = ["ro", "rw"]
1820

21+
logger = logging.getLogger("sagemaker")
22+
1923

2024
class s3_input(object):
2125
"""Amazon SageMaker channel configurations for S3 data sources.
@@ -76,6 +80,9 @@ def __init__(
7680
this channel. See the SageMaker API documentation for more info:
7781
https://docs.aws.amazon.com/sagemaker/latest/dg/API_ShuffleConfig.html
7882
"""
83+
logger.warning(
84+
"'s3_input' class will be renamed to 'TrainingInput' in SageMaker Python SDK v2."
85+
)
7986

8087
self.config = {
8188
"DataSource": {"S3DataSource": {"S3DataType": s3_data_type, "S3Uri": s3_data}}

src/sagemaker/model.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ def __init__(
108108
model_kms_key (str): KMS key ARN used to encrypt the repacked
109109
model archive file if the model is repacked
110110
"""
111+
LOGGER.warning(fw_utils.parameter_v2_rename_warning("image", "image_uri"))
112+
111113
self.model_data = model_data
112114
self.image = image
113115
self.role = role

src/sagemaker/mxnet/README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ With the SageMaker Python SDK, you can train and host MXNet models on Amazon Sag
66

77
Supported versions of MXNet: ``0.12.1``, ``1.0.0``, ``1.1.0``, ``1.2.1``, ``1.3.0``, ``1.4.0``, ``1.4.1``, ``1.6.0``.
88

9-
Supported versions of MXNet for Elastic Inference: ``1.3.0``, ``1.4.0``, ``1.4.1``.
9+
Supported versions of MXNet for Elastic Inference: ``1.3.0``, ``1.4.0``, ``1.4.1``, ``1.5.1``.
1010

1111
Supported versions of MXNet for Inferentia: ``1.5.1``.
1212

src/sagemaker/mxnet/estimator.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
framework_version_from_tag,
2222
empty_framework_version_warning,
2323
python_deprecation_warning,
24+
parameter_v2_rename_warning,
2425
is_version_equal_or_higher,
2526
warn_if_parameter_server_with_multi_gpu,
2627
)
@@ -129,6 +130,7 @@ def __init__(
129130
)
130131

131132
if distributions is not None:
133+
logger.warning(parameter_v2_rename_warning("distributions", "distribution"))
132134
train_instance_type = kwargs.get("train_instance_type")
133135
warn_if_parameter_server_with_multi_gpu(
134136
training_instance_type=train_instance_type, distributions=distributions

src/sagemaker/s3.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,27 @@
1313
"""This module contains Enums and helper methods related to S3."""
1414
from __future__ import print_function, absolute_import
1515

16+
import logging
1617
import os
1718

1819
from six.moves.urllib.parse import urlparse
1920
from sagemaker.session import Session
2021

22+
logger = logging.getLogger("sagemaker")
23+
24+
SESSION_V2_RENAME_MESSAGE = (
25+
"Parameter 'session' will be renamed to 'sagemaker_session' in SageMaker Python SDK v2."
26+
)
27+
28+
29+
def _session_v2_rename_warning(session):
30+
"""
31+
Args:
32+
session (sagemaker.session.Session):
33+
"""
34+
if session is not None:
35+
logger.warning(SESSION_V2_RENAME_MESSAGE)
36+
2137

2238
def parse_s3_url(url):
2339
"""Returns an (s3 bucket, key name/prefix) tuple from a url with an s3
@@ -54,6 +70,9 @@ def upload(local_path, desired_s3_uri, kms_key=None, session=None):
5470
The S3 uri of the uploaded file(s).
5571
5672
"""
73+
if session is not None:
74+
_session_v2_rename_warning(session)
75+
5776
sagemaker_session = session or Session()
5877
bucket, key_prefix = parse_s3_url(url=desired_s3_uri)
5978
if kms_key is not None:
@@ -80,6 +99,9 @@ def upload_string_as_file_body(body, desired_s3_uri=None, kms_key=None, session=
8099
str: The S3 uri of the uploaded file(s).
81100
82101
"""
102+
if session is not None:
103+
_session_v2_rename_warning(session)
104+
83105
sagemaker_session = session or Session()
84106
bucket, key = parse_s3_url(desired_s3_uri)
85107

@@ -107,6 +129,9 @@ def download(s3_uri, local_path, kms_key=None, session=None):
107129
using the default AWS configuration chain.
108130
109131
"""
132+
if session is not None:
133+
_session_v2_rename_warning(session)
134+
110135
sagemaker_session = session or Session()
111136
bucket, key_prefix = parse_s3_url(url=s3_uri)
112137
if kms_key is not None:
@@ -131,6 +156,9 @@ def read_file(s3_uri, session=None):
131156
str: The body of the file.
132157
133158
"""
159+
if session is not None:
160+
_session_v2_rename_warning(session)
161+
134162
sagemaker_session = session or Session()
135163
bucket, key_prefix = parse_s3_url(url=s3_uri)
136164

@@ -149,6 +177,9 @@ def list(s3_uri, session=None):
149177
[str]: The list of S3 URIs in the given S3 base uri.
150178
151179
"""
180+
if session is not None:
181+
_session_v2_rename_warning(session)
182+
152183
sagemaker_session = session or Session()
153184
bucket, key_prefix = parse_s3_url(url=s3_uri)
154185

src/sagemaker/session.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,12 @@ def upload_data(self, path, bucket=None, key_prefix="data", extra_args=None):
181181
``s3://{bucket name}/{key_prefix}``.
182182
"""
183183
# Generate a tuple for each file that we want to upload of the form (local_path, s3_key).
184+
LOGGER.warning(
185+
"'upload_data' method will be deprecated in favor of 'S3Uploader' class "
186+
"(https://sagemaker.readthedocs.io/en/stable/s3.html#sagemaker.s3.S3Uploader) "
187+
"in SageMaker Python SDK v2."
188+
)
189+
184190
files = []
185191
key_suffix = None
186192
if os.path.isdir(path):
@@ -230,6 +236,12 @@ def upload_string_as_file_body(self, body, bucket, key, kms_key=None):
230236
str: The S3 URI of the uploaded file.
231237
The URI format is: ``s3://{bucket name}/{key}``.
232238
"""
239+
LOGGER.warning(
240+
"'upload_string_as_file_body' method will be deprecated in favor of 'S3Uploader' class "
241+
"(https://sagemaker.readthedocs.io/en/stable/s3.html#sagemaker.s3.S3Uploader) "
242+
"in SageMaker Python SDK v2."
243+
)
244+
233245
if self.s3_resource is None:
234246
s3 = self.boto_session.resource("s3", region_name=self.boto_region_name)
235247
else:
@@ -3323,6 +3335,7 @@ def get_execution_role(sagemaker_session=None):
33233335
Returns:
33243336
(str): The role ARN
33253337
"""
3338+
33263339
if not sagemaker_session:
33273340
sagemaker_session = Session()
33283341
arn = sagemaker_session.get_caller_identity_arn()

src/sagemaker/tensorflow/estimator.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,7 @@ def __init__(
311311
)
312312

313313
if distributions is not None:
314+
logger.warning(fw.parameter_v2_rename_warning("distribution", distributions))
314315
train_instance_type = kwargs.get("train_instance_type")
315316
fw.warn_if_parameter_server_with_multi_gpu(
316317
training_instance_type=train_instance_type, distributions=distributions
@@ -385,7 +386,9 @@ def _validate_args(
385386

386387
if (not self._script_mode_enabled()) and self._only_script_mode_supported():
387388
logger.warning(
388-
"Legacy mode is deprecated in versions 1.13 and higher. Using script mode instead."
389+
"Legacy mode is deprecated in versions 1.13 and higher. Using script mode instead. "
390+
"Legacy mode and its training parameters will be deprecated in "
391+
"SageMaker Python SDK v2. Please use TF 1.13 or higher and script mode."
389392
)
390393
self.script_mode = True
391394

src/sagemaker/transformer.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ def transform(
135135
136136
* 'ManifestFile' - the S3 URI points to a single manifest file listing each S3
137137
object to use as an input for the transform job.
138+
138139
content_type (str): MIME type of the input data (default: None).
139140
compression_type (str): Compression type of the input data, if
140141
compressed (default: None). Valid values: 'Gzip', None.

0 commit comments

Comments
 (0)