Skip to content

Commit 63c601d

Browse files
authored
Merge branch 'master' into doc-xgboost-byom
2 parents 002e75a + eec8217 commit 63c601d

38 files changed

+475
-161
lines changed

CHANGELOG.md

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

3+
## v1.71.1 (2020-07-27)
4+
5+
### Bug Fixes and Other Changes
6+
7+
* remove redundant information from the user_agent string.
8+
9+
### Testing and Release Infrastructure
10+
11+
* use unique model name in TFS integ tests
12+
* use pytest-cov instead of coverage
13+
14+
## v1.71.0 (2020-07-23)
15+
16+
### Features
17+
18+
* Add mpi support for mxnet estimator api
19+
20+
### Bug Fixes and Other Changes
21+
22+
* use 'sagemaker' logger instead of root logger
23+
* account for "py36" and "py37" in image tag parsing
24+
325
## v1.70.2 (2020-07-22)
426

527
### Bug Fixes and Other Changes

VERSION

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

buildspec-unittests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ phases:
77
- TOX_PARALLEL_NO_SPINNER=1
88
- PY_COLORS=0
99
- start_time=`date +%s`
10-
- tox -e flake8,pylint,twine,black-check
10+
- tox -e flake8,pylint,twine,black-check --parallel all
1111
- ./ci-scripts/displaytime.sh 'flake8,pylint,twine,black-check' $start_time
1212

1313
- start_time=`date +%s`
14-
- tox -e sphinx,doc8
14+
- tox -e sphinx,doc8 --parallel all
1515
- ./ci-scripts/displaytime.sh 'sphinx,doc8' $start_time
1616

1717
# run unit tests

doc/amazon_sagemaker_processing.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ Amazon SageMaker Processing allows you to run steps for data pre- or post-proces
1010
Background
1111
==========
1212

13-
Amazon SageMaker lets developers and data scientists train and deploy machine learning models. With Amazon SageMaker Processing, you can run processing jobs on for data processing steps in your machine learning pipeline, which accept data from Amazon S3 as input, and put data into Amazon S3 as output.
13+
Amazon SageMaker lets developers and data scientists train and deploy machine learning models. With Amazon SageMaker Processing, you can run processing jobs for data processing steps in your machine learning pipeline. Processing jobs accept data from Amazon S3 as input and store data into Amazon S3 as output.
1414

1515
.. image:: ./amazon_sagemaker_processing_image1.png
1616

1717
Setup
1818
=====
1919

20-
The fastest way to run get started with Amazon SageMaker Processing is by running a Jupyter notebook. You can follow the `Getting Started with Amazon SageMaker`_ guide to start running notebooks on Amazon SageMaker.
20+
The fastest way to get started with Amazon SageMaker Processing is by running a Jupyter notebook. You can follow the `Getting Started with Amazon SageMaker`_ guide to start running notebooks on Amazon SageMaker.
2121

2222
.. _Getting Started with Amazon SageMaker: https://docs.aws.amazon.com/sagemaker/latest/dg/gs.html
2323

src/sagemaker/amazon/amazon_estimator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,7 @@ def get_image_uri(region_name, repo_name, repo_version=1):
665665

666666
def _warn_newer_xgboost_image():
667667
"""Print a warning when there is a newer XGBoost image"""
668-
logging.warning(
668+
logger.warning(
669669
"There is a more up to date SageMaker XGBoost image. "
670670
"To use the newer image, please set 'repo_version'="
671671
"'%s'. For example:\n"

src/sagemaker/analytics.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,12 @@
2323
from sagemaker.session import Session
2424
from sagemaker.utils import DeferredError
2525

26+
logger = logging.getLogger(__name__)
2627

2728
try:
2829
import pandas as pd
2930
except ImportError as e:
30-
logging.warning("pandas failed to import. Analytics features will be impaired or broken.")
31+
logger.warning("pandas failed to import. Analytics features will be impaired or broken.")
3132
# Any subsequent attempt to use pandas will raise the ImportError
3233
pd = DeferredError(e)
3334

@@ -251,15 +252,13 @@ def training_job_summaries(self, force_refresh=False):
251252
output = []
252253
next_args = {}
253254
for count in range(100):
254-
logging.debug("Calling list_training_jobs_for_hyper_parameter_tuning_job %d", count)
255+
logger.debug("Calling list_training_jobs_for_hyper_parameter_tuning_job %d", count)
255256
raw_result = self._sage_client.list_training_jobs_for_hyper_parameter_tuning_job(
256257
HyperParameterTuningJobName=self.name, MaxResults=100, **next_args
257258
)
258259
new_output = raw_result["TrainingJobSummaries"]
259260
output.extend(new_output)
260-
logging.debug(
261-
"Got %d more TrainingJobs. Total so far: %d", len(new_output), len(output)
262-
)
261+
logger.debug("Got %d more TrainingJobs. Total so far: %d", len(new_output), len(output))
263262
if ("NextToken" in raw_result) and (len(new_output) > 0):
264263
next_args["NextToken"] = raw_result["NextToken"]
265264
else:
@@ -373,7 +372,7 @@ def _fetch_metric(self, metric_name):
373372
}
374373
raw_cwm_data = self._cloudwatch.get_metric_statistics(**request)["Datapoints"]
375374
if len(raw_cwm_data) == 0:
376-
logging.warning("Warning: No metrics called %s found", metric_name)
375+
logger.warning("Warning: No metrics called %s found", metric_name)
377376
return
378377

379378
# Process data: normalize to starting time, and sort.

src/sagemaker/estimator.py

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@
5959
from sagemaker.utils import base_name_from_image, name_from_base, get_config_value
6060
from sagemaker import vpc_utils
6161

62+
logger = logging.getLogger(__name__)
63+
6264

6365
class EstimatorBase(with_metaclass(ABCMeta, object)):
6466
"""Handle end-to-end Amazon SageMaker training and deployment tasks.
@@ -510,6 +512,10 @@ def compile_model(
510512
framework_version=None,
511513
compile_max_run=15 * 60,
512514
tags=None,
515+
target_platform_os=None,
516+
target_platform_arch=None,
517+
target_platform_accelerator=None,
518+
compiler_options=None,
513519
**kwargs
514520
):
515521
"""Compile a Neo model using the input model.
@@ -534,6 +540,21 @@ def compile_model(
534540
tags (list[dict]): List of tags for labeling a compilation job. For
535541
more, see
536542
https://docs.aws.amazon.com/sagemaker/latest/dg/API_Tag.html.
543+
target_platform_os (str): Target Platform OS, for example: 'LINUX'.
544+
For allowed strings see
545+
https://docs.aws.amazon.com/sagemaker/latest/dg/API_OutputConfig.html.
546+
It can be used instead of target_instance_family.
547+
target_platform_arch (str): Target Platform Architecture, for example: 'X86_64'.
548+
For allowed strings see
549+
https://docs.aws.amazon.com/sagemaker/latest/dg/API_OutputConfig.html.
550+
It can be used instead of target_instance_family.
551+
target_platform_accelerator (str, optional): Target Platform Accelerator,
552+
for example: 'NVIDIA'. For allowed strings see
553+
https://docs.aws.amazon.com/sagemaker/latest/dg/API_OutputConfig.html.
554+
It can be used instead of target_instance_family.
555+
compiler_options (dict, optional): Additional parameters for compiler.
556+
Compiler Options are TargetPlatform / target_instance_family specific. See
557+
https://docs.aws.amazon.com/sagemaker/latest/dg/API_OutputConfig.html for details.
537558
**kwargs: Passed to invocation of ``create_model()``.
538559
Implementations may customize ``create_model()`` to accept
539560
``**kwargs`` to customize model creation during deploy. For
@@ -563,6 +584,10 @@ def compile_model(
563584
compile_max_run,
564585
framework=framework,
565586
framework_version=framework_version,
587+
target_platform_os=target_platform_os,
588+
target_platform_arch=target_platform_arch,
589+
target_platform_accelerator=target_platform_accelerator,
590+
compiler_options=compiler_options,
566591
)
567592
return self._compiled_models[target_instance_family]
568593

@@ -730,7 +755,7 @@ def model_data(self):
730755
TrainingJobName=self.latest_training_job.name
731756
)["ModelArtifacts"]["S3ModelArtifacts"]
732757
else:
733-
logging.warning(
758+
logger.warning(
734759
"No finished training job found associated with this estimator. Please make sure "
735760
"this estimator is only used for building workflow config"
736761
)
@@ -826,7 +851,7 @@ def delete_endpoint(self):
826851
Raises:
827852
botocore.exceptions.ClientError: If the endpoint does not exist.
828853
"""
829-
logging.warning(
854+
logger.warning(
830855
"estimator.delete_endpoint() will be deprecated in SageMaker Python SDK v2. "
831856
"Please use the delete_endpoint() function on your predictor instead."
832857
)
@@ -908,7 +933,7 @@ def transformer(
908933
tags = tags or self.tags
909934

910935
if self.latest_training_job is None:
911-
logging.warning(
936+
logger.warning(
912937
"No finished training job found associated with this estimator. Please make sure "
913938
"this estimator is only used for building workflow config"
914939
)
@@ -1029,7 +1054,7 @@ def start_new(cls, estimator, inputs, experiment_config):
10291054

10301055
if isinstance(inputs, s3_input):
10311056
if "InputMode" in inputs.config:
1032-
logging.debug(
1057+
logger.debug(
10331058
"Selecting s3_input's input_mode (%s) for TrainingInputMode.",
10341059
inputs.config["InputMode"],
10351060
)
@@ -1279,7 +1304,7 @@ def __init__(
12791304
https://docs.aws.amazon.com/sagemaker/latest/dg/API_AlgorithmSpecification.html#SageMaker-Type-AlgorithmSpecification-EnableSageMakerMetricsTimeSeries
12801305
(default: ``None``).
12811306
"""
1282-
logging.warning(parameter_v2_rename_warning("image_name", "image_uri"))
1307+
logger.warning(parameter_v2_rename_warning("image_name", "image_uri"))
12831308
self.image_name = image_name
12841309
self.hyperparam_dict = hyperparameters.copy() if hyperparameters else {}
12851310
super(Estimator, self).__init__(
@@ -1653,7 +1678,7 @@ def __init__(
16531678
self.code_location = code_location
16541679
self.image_name = image_name
16551680
if image_name is not None:
1656-
logging.warning(parameter_v2_rename_warning("image_name", "image_uri"))
1681+
logger.warning(parameter_v2_rename_warning("image_name", "image_uri"))
16571682

16581683
self.uploaded_code = None
16591684

@@ -2029,7 +2054,7 @@ def transformer(
20292054
if env is not None:
20302055
transform_env.update(env)
20312056
else:
2032-
logging.warning(
2057+
logger.warning(
20332058
"No finished training job found associated with this estimator. Please make sure "
20342059
"this estimator is only used for building workflow config"
20352060
)

src/sagemaker/fw_registry.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,13 @@
1212
# language governing permissions and limitations under the License.
1313
"""Placeholder docstring"""
1414
from __future__ import absolute_import
15+
1516
import logging
1617

1718
from sagemaker.utils import get_ecr_image_uri_prefix
1819

20+
logger = logging.getLogger(__name__)
21+
1922
image_registry_map = {
2023
"us-west-1": {
2124
"sparkml-serving": "746614075791",
@@ -142,7 +145,7 @@ def registry(region_name, framework=None):
142145
account_id = image_registry_map[region_name][framework]
143146
return get_ecr_image_uri_prefix(account_id, region_name)
144147
except KeyError:
145-
logging.error("The specific image or region does not exist")
148+
logger.error("The specific image or region does not exist")
146149
raise
147150

148151

src/sagemaker/fw_utils.py

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,7 @@ def _list_files_to_compress(script, directory):
493493
def framework_name_from_image(image_name):
494494
# noinspection LongLine
495495
"""Extract the framework and Python version from the image name.
496+
496497
Args:
497498
image_name (str): Image URI, which should be one of the following forms:
498499
legacy:
@@ -503,25 +504,32 @@ def framework_name_from_image(image_name):
503504
'<account>.dkr.ecr.<region>.amazonaws.com/sagemaker-<fw>:<fw_version>-<device>-<py_ver>'
504505
current:
505506
'<account>.dkr.ecr.<region>.amazonaws.com/sagemaker-rl-<fw>:<rl_toolkit><rl_version>-<device>-<py_ver>'
507+
current:
508+
'<account>.dkr.ecr.<region>.amazonaws.com/<fw>-<image_scope>:<fw_version>-<device>-<py_ver>'
509+
506510
Returns:
507511
tuple: A tuple containing:
508-
str: The framework name str: The Python version str: The image tag
509-
str: If the image is script mode
510-
"""
512+
513+
- str: The framework name
514+
- str: The Python version
515+
- str: The image tag
516+
- str: If the TensorFlow image is script mode
517+
"""
511518
sagemaker_pattern = re.compile(ECR_URI_PATTERN)
512519
sagemaker_match = sagemaker_pattern.match(image_name)
513520
if sagemaker_match is None:
514521
return None, None, None, None
522+
515523
# extract framework, python version and image tag
516524
# We must support both the legacy and current image name format.
517525
name_pattern = re.compile(
518-
r"^(?:sagemaker(?:-rl)?-)?(tensorflow|mxnet|chainer|pytorch|scikit-learn|xgboost)(?:-)?(scriptmode|training)?:(.*)-(.*?)-(py2|py3)$" # noqa: E501 # pylint: disable=line-too-long
526+
r"""^(?:sagemaker(?:-rl)?-)?
527+
(tensorflow|mxnet|chainer|pytorch|scikit-learn|xgboost)(?:-)?
528+
(scriptmode|training)?
529+
:(.*)-(.*?)-(py2|py3[67]?)$""",
530+
re.VERBOSE,
519531
)
520-
legacy_name_pattern = re.compile(r"^sagemaker-(tensorflow|mxnet)-(py2|py3)-(cpu|gpu):(.*)$")
521-
522532
name_match = name_pattern.match(sagemaker_match.group(9))
523-
legacy_match = legacy_name_pattern.match(sagemaker_match.group(9))
524-
525533
if name_match is not None:
526534
fw, scriptmode, ver, device, py = (
527535
name_match.group(1),
@@ -531,20 +539,25 @@ def framework_name_from_image(image_name):
531539
name_match.group(5),
532540
)
533541
return fw, py, "{}-{}-{}".format(ver, device, py), scriptmode
542+
543+
legacy_name_pattern = re.compile(r"^sagemaker-(tensorflow|mxnet)-(py2|py3)-(cpu|gpu):(.*)$")
544+
legacy_match = legacy_name_pattern.match(sagemaker_match.group(9))
534545
if legacy_match is not None:
535546
return (legacy_match.group(1), legacy_match.group(2), legacy_match.group(4), None)
536547
return None, None, None, None
537548

538549

539550
def framework_version_from_tag(image_tag):
540551
"""Extract the framework version from the image tag.
552+
541553
Args:
542554
image_tag (str): Image tag, which should take the form
543555
'<framework_version>-<device>-<py_version>'
556+
544557
Returns:
545558
str: The framework version.
546559
"""
547-
tag_pattern = re.compile("^(.*)-(cpu|gpu)-(py2|py3)$")
560+
tag_pattern = re.compile("^(.*)-(cpu|gpu)-(py2|py3[67]?)$")
548561
tag_match = tag_pattern.match(image_tag)
549562
return None if tag_match is None else tag_match.group(1)
550563

src/sagemaker/local/entities.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,15 @@
2525
from sagemaker.local.utils import copy_directory_structure, move_to_destination
2626
from sagemaker.utils import DeferredError, get_config_value
2727

28+
logger = logging.getLogger(__name__)
29+
2830
try:
2931
import urllib3
3032
except ImportError as e:
31-
logging.warning("urllib3 failed to import. Local mode features will be impaired or broken.")
33+
logger.warning("urllib3 failed to import. Local mode features will be impaired or broken.")
3234
# Any subsequent attempt to use urllib3 will raise the ImportError
3335
urllib3 = DeferredError(e)
3436

35-
36-
logger = logging.getLogger(__name__)
37-
3837
_UNUSED_ARN = "local:arn-does-not-matter"
3938
HEALTH_CHECK_TIMEOUT_LIMIT = 120
4039

src/sagemaker/local/image.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ def _generate_compose_file(self, command, additional_volumes=None, additional_en
473473
try:
474474
import yaml
475475
except ImportError as e:
476-
logging.error(sagemaker.utils._module_import_error("yaml", "Local mode", "local"))
476+
logger.error(sagemaker.utils._module_import_error("yaml", "Local mode", "local"))
477477
raise e
478478

479479
yaml_content = yaml.dump(content, default_flow_style=False)

src/sagemaker/local/local_session.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ def __init__(self, config=None):
327327
try:
328328
import urllib3
329329
except ImportError as e:
330-
logging.error(_module_import_error("urllib3", "Local mode", "local"))
330+
logger.error(_module_import_error("urllib3", "Local mode", "local"))
331331
raise e
332332

333333
self.http = urllib3.PoolManager()
@@ -423,7 +423,7 @@ def _initialize(self, boto_session, sagemaker_client, sagemaker_runtime_client):
423423
try:
424424
import yaml
425425
except ImportError as e:
426-
logging.error(_module_import_error("yaml", "Local mode", "local"))
426+
logger.error(_module_import_error("yaml", "Local mode", "local"))
427427
raise e
428428

429429
self.config = yaml.load(open(sagemaker_config_file, "r"))

0 commit comments

Comments
 (0)