Skip to content

Commit e9e0679

Browse files
authored
Merge branch 'master' into master
2 parents a0a92bd + 13fc68c commit e9e0679

File tree

7 files changed

+140
-47
lines changed

7 files changed

+140
-47
lines changed

CHANGELOG.md

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

3+
## v1.51.1 (2020-03-10)
4+
5+
### Bug Fixes and Other Changes
6+
7+
* skip pytorch ei test in unsupported regions
8+
9+
### Documentation Changes
10+
11+
* correct MultiString/MULTI_STRING docstring
12+
313
## v1.51.0 (2020-03-09)
414

515
### Features

VERSION

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

src/sagemaker/fw_utils.py

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
]
6363
PY2_RESTRICTED_EIA_FRAMEWORKS = ["pytorch-serving"]
6464
VALID_ACCOUNTS_BY_REGION = {"us-gov-west-1": "246785580436", "us-iso-east-1": "744548109606"}
65-
ASIMOV_VALID_ACCOUNTS_BY_REGION = {"us-iso-east-1": "886529160074"}
65+
ASIMOV_VALID_ACCOUNTS_BY_REGION = {"us-gov-west-1": "442386744353", "us-iso-east-1": "886529160074"}
6666
OPT_IN_ACCOUNTS_BY_REGION = {"ap-east-1": "057415533634", "me-south-1": "724002660598"}
6767
ASIMOV_OPT_IN_ACCOUNTS_BY_REGION = {"ap-east-1": "871362719292", "me-south-1": "217643126080"}
6868
DEFAULT_ACCOUNT = "520713654638"
@@ -133,25 +133,6 @@ def _is_dlc_version(framework, framework_version, py_version):
133133
return False
134134

135135

136-
def _use_dlc_image(region, framework, py_version, framework_version):
137-
"""Return if the DLC image should be used for the given framework,
138-
framework version, Python version, and region.
139-
140-
Args:
141-
region (str): The AWS region.
142-
framework (str): The framework name, e.g. "tensorflow-scriptmode".
143-
py_version (str): The Python version, e.g. "py3".
144-
framework_version (str): The framework version.
145-
146-
Returns:
147-
bool: Whether or not to use the corresponding DLC image.
148-
"""
149-
is_gov_region = region in VALID_ACCOUNTS_BY_REGION
150-
is_dlc_version = _is_dlc_version(framework, framework_version, py_version)
151-
152-
return ((not is_gov_region) or region in ASIMOV_VALID_ACCOUNTS_BY_REGION) and is_dlc_version
153-
154-
155136
def _registry_id(region, framework, py_version, account, framework_version):
156137
"""Return the Amazon ECR registry number (or AWS account ID) for
157138
the given framework, framework version, Python version, and region.
@@ -168,7 +149,7 @@ def _registry_id(region, framework, py_version, account, framework_version):
168149
specific one for the framework, framework version, Python version,
169150
and region, then ``account`` is returned.
170151
"""
171-
if _use_dlc_image(region, framework, py_version, framework_version):
152+
if _is_dlc_version(framework, framework_version, py_version):
172153
if region in ASIMOV_OPT_IN_ACCOUNTS_BY_REGION:
173154
return ASIMOV_OPT_IN_ACCOUNTS_BY_REGION.get(region)
174155
if region in ASIMOV_VALID_ACCOUNTS_BY_REGION:
@@ -253,7 +234,7 @@ def create_image_uri(
253234
else:
254235
device_type = "cpu"
255236

256-
use_dlc_image = _use_dlc_image(region, framework, py_version, framework_version)
237+
use_dlc_image = _is_dlc_version(framework, framework_version, py_version)
257238

258239
if not py_version or (use_dlc_image and framework == "tensorflow-serving-eia"):
259240
tag = "{}-{}".format(framework_version, device_type)

src/sagemaker/processing.py

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -648,10 +648,9 @@ def from_processing_name(cls, sagemaker_session, processing_job_name):
648648
"""
649649
job_desc = sagemaker_session.describe_processing_job(job_name=processing_job_name)
650650

651-
return cls(
652-
sagemaker_session=sagemaker_session,
653-
job_name=processing_job_name,
654-
inputs=[
651+
inputs = None
652+
if job_desc.get("ProcessingInputs"):
653+
inputs = [
655654
ProcessingInput(
656655
source=processing_input["S3Input"]["S3Uri"],
657656
destination=processing_input["S3Input"]["LocalPath"],
@@ -664,19 +663,31 @@ def from_processing_name(cls, sagemaker_session, processing_job_name):
664663
s3_compression_type=processing_input["S3Input"].get("S3CompressionType"),
665664
)
666665
for processing_input in job_desc["ProcessingInputs"]
667-
],
668-
outputs=[
666+
]
667+
668+
outputs = None
669+
if job_desc.get("ProcessingOutputConfig") and job_desc["ProcessingOutputConfig"].get(
670+
"Outputs"
671+
):
672+
outputs = [
669673
ProcessingOutput(
670-
source=job_desc["ProcessingOutputConfig"]["Outputs"][0]["S3Output"][
671-
"LocalPath"
672-
],
673-
destination=job_desc["ProcessingOutputConfig"]["Outputs"][0]["S3Output"][
674-
"S3Uri"
675-
],
676-
output_name=job_desc["ProcessingOutputConfig"]["Outputs"][0]["OutputName"],
674+
source=processing_output["S3Output"]["LocalPath"],
675+
destination=processing_output["S3Output"]["S3Uri"],
676+
output_name=processing_output["OutputName"],
677677
)
678-
],
679-
output_kms_key=job_desc["ProcessingOutputConfig"].get("KmsKeyId"),
678+
for processing_output in job_desc["ProcessingOutputConfig"]["Outputs"]
679+
]
680+
681+
output_kms_key = None
682+
if job_desc.get("ProcessingOutputConfig"):
683+
output_kms_key = job_desc["ProcessingOutputConfig"].get("KmsKeyId")
684+
685+
return cls(
686+
sagemaker_session=sagemaker_session,
687+
job_name=processing_job_name,
688+
inputs=inputs,
689+
outputs=outputs,
690+
output_kms_key=output_kms_key,
680691
)
681692

682693
@classmethod

tests/integ/test_auto_ml.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
from __future__ import absolute_import
1414

1515
import os
16-
import time
1716

1817
import pytest
1918
import tests.integ
@@ -34,7 +33,7 @@
3433
TRAINING_DATA = os.path.join(DATA_DIR, "iris_training.csv")
3534
TEST_DATA = os.path.join(DATA_DIR, "iris_test.csv")
3635
PROBLEM_TYPE = "MultiClassClassification"
37-
JOB_NAME = "auto-ml-{}".format(time.strftime("%y%m%d-%H%M%S"))
36+
BASE_JOB_NAME = "auto-ml"
3837

3938
# use a succeeded AutoML job to test describe and list candidates method, otherwise tests will run too long
4039
AUTO_ML_JOB_NAME = "python-sdk-integ-test-base-job"
@@ -119,11 +118,11 @@ def test_auto_ml_fit_optional_args(sagemaker_session):
119118
)
120119
inputs = TRAINING_DATA
121120
with timeout(minutes=AUTO_ML_DEFAULT_TIMEMOUT_MINUTES):
122-
auto_ml.fit(inputs, job_name=JOB_NAME)
121+
auto_ml.fit(inputs, job_name=unique_name_from_base(BASE_JOB_NAME))
123122

124-
auto_ml_desc = auto_ml.describe_auto_ml_job(job_name=JOB_NAME)
123+
auto_ml_desc = auto_ml.describe_auto_ml_job(job_name=auto_ml.latest_auto_ml_job.job_name)
125124
assert auto_ml_desc["AutoMLJobStatus"] == "Completed"
126-
assert auto_ml_desc["AutoMLJobName"] == JOB_NAME
125+
assert auto_ml_desc["AutoMLJobName"] == auto_ml.latest_auto_ml_job.job_name
127126
assert auto_ml_desc["AutoMLJobObjective"] == job_objective
128127
assert auto_ml_desc["ProblemType"] == problem_type
129128
assert auto_ml_desc["OutputDataConfig"]["S3OutputPath"] == output_path

tests/integ/test_processing.py

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,13 @@
2020
from sagemaker import Session
2121
from sagemaker.fw_registry import default_framework_uri
2222

23-
from sagemaker.processing import ProcessingInput, ProcessingOutput, ScriptProcessor, Processor
23+
from sagemaker.processing import (
24+
ProcessingInput,
25+
ProcessingOutput,
26+
ScriptProcessor,
27+
Processor,
28+
ProcessingJob,
29+
)
2430
from sagemaker.sklearn.processing import SKLearnProcessor
2531
from sagemaker.utils import sts_regional_endpoint
2632
from tests.integ import DATA_DIR
@@ -475,6 +481,37 @@ def test_script_processor_with_no_inputs_or_outputs(
475481

476482
assert job_description["StoppingCondition"] == {"MaxRuntimeInSeconds": 3600}
477483

484+
job_from_name = ProcessingJob.from_processing_name(
485+
sagemaker_session=sagemaker_session,
486+
processing_job_name=job_description["ProcessingJobName"],
487+
)
488+
job_description = job_from_name.describe()
489+
490+
assert job_description["ProcessingInputs"][0]["InputName"] == "code"
491+
492+
assert job_description["ProcessingJobName"].startswith("test-script-processor-with-no-inputs")
493+
494+
assert job_description["ProcessingJobStatus"] == "Completed"
495+
496+
assert job_description["ProcessingResources"]["ClusterConfig"]["InstanceCount"] == 1
497+
assert (
498+
job_description["ProcessingResources"]["ClusterConfig"]["InstanceType"] == cpu_instance_type
499+
)
500+
assert job_description["ProcessingResources"]["ClusterConfig"]["VolumeSizeInGB"] == 100
501+
502+
assert job_description["AppSpecification"]["ContainerArguments"] == ["-v"]
503+
assert job_description["AppSpecification"]["ContainerEntrypoint"] == [
504+
"python3",
505+
"/opt/ml/processing/input/code/dummy_script.py",
506+
]
507+
assert job_description["AppSpecification"]["ImageUri"] == image_uri
508+
509+
assert job_description["Environment"] == {"DUMMY_ENVIRONMENT_VARIABLE": "dummy-value"}
510+
511+
assert ROLE in job_description["RoleArn"]
512+
513+
assert job_description["StoppingCondition"] == {"MaxRuntimeInSeconds": 3600}
514+
478515

479516
@pytest.mark.canary_quick
480517
def test_processor(sagemaker_session, image_uri, cpu_instance_type, output_kms_key):

tests/unit/test_fw_utils.py

Lines changed: 58 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ def test_create_image_uri_hkg_override_account():
363363
assert {image_uri == "fake.dkr.ecr.ap-east-1.amazonaws.com/sagemaker-mlfw:1.0rc-gpu-py3"}
364364

365365

366-
def test_create_image_uri_merged():
366+
def test_create_dlc_image_uri():
367367
image_uri = fw_utils.create_image_uri(
368368
"us-west-2", "tensorflow-scriptmode", "ml.p3.2xlarge", "1.14", "py3"
369369
)
@@ -419,7 +419,7 @@ def test_create_image_uri_merged():
419419
)
420420

421421

422-
def test_create_image_uri_merged_py2():
422+
def test_create_dlc_image_uri_py2():
423423
image_uri = fw_utils.create_image_uri(
424424
"us-west-2", "tensorflow-scriptmode", "ml.p3.2xlarge", "1.13.1", "py2"
425425
)
@@ -450,7 +450,7 @@ def test_create_image_uri_merged_py2():
450450
)
451451

452452

453-
def test_create_image_uri_merged_gov_regions():
453+
def test_create_dlc_image_uri_iso_east_1():
454454
image_uri = fw_utils.create_image_uri(
455455
"us-iso-east-1", "tensorflow-scriptmode", "ml.m4.xlarge", "1.13.1", "py3"
456456
)
@@ -493,6 +493,61 @@ def test_create_image_uri_merged_gov_regions():
493493
)
494494

495495

496+
def test_create_dlc_image_uri_gov_west_1():
497+
image_uri = fw_utils.create_image_uri(
498+
"us-gov-west-1", "tensorflow-scriptmode", "ml.m4.xlarge", "1.13.1", "py3"
499+
)
500+
assert (
501+
image_uri
502+
== "442386744353.dkr.ecr.us-gov-west-1.amazonaws.com/tensorflow-training:1.13.1-cpu-py3"
503+
)
504+
505+
image_uri = fw_utils.create_image_uri(
506+
"us-gov-west-1", "tensorflow-scriptmode", "ml.p3.2xlarge", "1.14", "py2"
507+
)
508+
assert (
509+
image_uri
510+
== "442386744353.dkr.ecr.us-gov-west-1.amazonaws.com/tensorflow-training:1.14-gpu-py2"
511+
)
512+
513+
image_uri = fw_utils.create_image_uri(
514+
"us-gov-west-1", "tensorflow-serving", "ml.m4.xlarge", "1.13.0"
515+
)
516+
assert (
517+
image_uri
518+
== "442386744353.dkr.ecr.us-gov-west-1.amazonaws.com/tensorflow-inference:1.13.0-cpu"
519+
)
520+
521+
image_uri = fw_utils.create_image_uri("us-gov-west-1", "mxnet", "ml.p3.2xlarge", "1.4.1", "py3")
522+
assert (
523+
image_uri == "442386744353.dkr.ecr.us-gov-west-1.amazonaws.com/mxnet-training:1.4.1-gpu-py3"
524+
)
525+
526+
image_uri = fw_utils.create_image_uri(
527+
"us-gov-west-1", "mxnet-serving", "ml.c4.2xlarge", "1.4.1", "py3"
528+
)
529+
assert (
530+
image_uri
531+
== "442386744353.dkr.ecr.us-gov-west-1.amazonaws.com/mxnet-inference:1.4.1-cpu-py3"
532+
)
533+
534+
image_uri = fw_utils.create_image_uri(
535+
"us-gov-west-1", "pytorch", "ml.p3.2xlarge", "1.2.0", "py3"
536+
)
537+
assert (
538+
image_uri
539+
== "442386744353.dkr.ecr.us-gov-west-1.amazonaws.com/pytorch-training:1.2.0-gpu-py3"
540+
)
541+
542+
image_uri = fw_utils.create_image_uri(
543+
"us-gov-west-1", "pytorch-serving", "ml.c4.2xlarge", "1.2.0", "py3"
544+
)
545+
assert (
546+
image_uri
547+
== "442386744353.dkr.ecr.us-gov-west-1.amazonaws.com/pytorch-inference:1.2.0-cpu-py3"
548+
)
549+
550+
496551
def test_create_image_uri_pytorch(pytorch_version):
497552
image_uri = fw_utils.create_image_uri(
498553
"us-west-2", "pytorch", "ml.p3.2xlarge", pytorch_version, "py3"

0 commit comments

Comments
 (0)