Skip to content

Commit 4836fc9

Browse files
authored
fix: update with aws:master
update with aws:master
2 parents ee2c345 + b4e6f3d commit 4836fc9

File tree

5 files changed

+117
-4
lines changed

5 files changed

+117
-4
lines changed

src/sagemaker/tensorflow/estimator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ class TensorFlow(Framework):
203203
_LOWEST_SCRIPT_MODE_ONLY_VERSION = [1, 13]
204204
# 1.15.0 still supports py2
205205
# we will need to update this version number if future versions still support py2
206-
_HIGHEST_PYTHON_2_VERSION = [1, 15]
206+
_HIGHEST_PYTHON_2_VERSION = [1, 15, 0]
207207

208208
def __init__(
209209
self,
@@ -371,7 +371,7 @@ def _only_script_mode_supported(self):
371371

372372
def _only_python_3_supported(self):
373373
"""Placeholder docstring"""
374-
return [int(s) for s in self.framework_version.split(".")] >= self._HIGHEST_PYTHON_2_VERSION
374+
return [int(s) for s in self.framework_version.split(".")] > self._HIGHEST_PYTHON_2_VERSION
375375

376376
def _validate_requirements_file(self, requirements_file):
377377
"""Placeholder docstring"""

tests/integ/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676

7777
NO_LDA_REGIONS = ["eu-west-3", "eu-north-1", "sa-east-1", "ap-east-1", "me-south-1"]
7878
NO_MARKET_PLACE_REGIONS = ["eu-west-3", "eu-north-1", "sa-east-1", "ap-east-1", "me-south-1"]
79+
NO_AUTO_ML_REGIONS = ["sa-east-1", "me-south-1", "ap-east-1", "eu-west-3"]
7980

8081
EFS_TEST_ENABLED_REGION = []
8182

tests/integ/auto_ml_utils.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License"). You
4+
# may not use this file except in compliance with the License. A copy of
5+
# the License is located at
6+
#
7+
# http://aws.amazon.com/apache2.0/
8+
#
9+
# or in the "license" file accompanying this file. This file is
10+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11+
# ANY KIND, either express or implied. See the License for the specific
12+
# language governing permissions and limitations under the License.
13+
from __future__ import absolute_import
14+
15+
import os
16+
17+
from sagemaker import AutoML
18+
from tests.integ import DATA_DIR, AUTO_ML_DEFAULT_TIMEMOUT_MINUTES
19+
from tests.integ.timeout import timeout
20+
21+
ROLE = "SageMakerRole"
22+
DATA_DIR = os.path.join(DATA_DIR, "automl", "data")
23+
PREFIX = "sagemaker/beta-automl-xgboost"
24+
TRAINING_DATA = os.path.join(DATA_DIR, "iris_training.csv")
25+
TARGET_ATTRIBUTE_NAME = "virginica"
26+
27+
28+
def create_auto_ml_job_if_not_exist(sagemaker_session):
29+
auto_ml_job_name = "python-sdk-integ-test-base-job"
30+
auto_ml = AutoML(
31+
role=ROLE,
32+
target_attribute_name=TARGET_ATTRIBUTE_NAME,
33+
sagemaker_session=sagemaker_session,
34+
max_candidates=3,
35+
)
36+
37+
try:
38+
auto_ml.describe_auto_ml_job(job_name=auto_ml_job_name)
39+
except Exception as e: # noqa: F841
40+
inputs = sagemaker_session.upload_data(path=TRAINING_DATA, key_prefix=PREFIX + "/input")
41+
with timeout(minutes=AUTO_ML_DEFAULT_TIMEMOUT_MINUTES):
42+
auto_ml.fit(inputs, job_name=auto_ml_job_name)

tests/integ/test_auto_ml.py

Lines changed: 65 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@
1616
import time
1717

1818
import pytest
19+
import tests.integ
1920
from sagemaker import AutoML, CandidateEstimator, AutoMLInput
2021

2122
from sagemaker.exceptions import UnexpectedStatusException
2223
from sagemaker.utils import unique_name_from_base
23-
from tests.integ import DATA_DIR, AUTO_ML_DEFAULT_TIMEMOUT_MINUTES
24+
from tests.integ import DATA_DIR, AUTO_ML_DEFAULT_TIMEMOUT_MINUTES, auto_ml_utils
2425
from tests.integ.timeout import timeout
2526

2627
DEV_ACCOUNT = 142577830533
@@ -38,7 +39,7 @@
3839
JOB_NAME = "auto-ml-{}".format(time.strftime("%y%m%d-%H%M%S"))
3940

4041
# use a succeeded AutoML job to test describe and list candidates method, otherwise tests will run too long
41-
AUTO_ML_JOB_NAME = "sagemaker-auto-gamma-ml-test"
42+
AUTO_ML_JOB_NAME = "python-sdk-integ-test-base-job"
4243

4344
EXPECTED_DEFAULT_INPUT_CONFIG = [
4445
{
@@ -62,6 +63,10 @@
6263
}
6364

6465

66+
@pytest.mark.skipif(
67+
tests.integ.test_region() in tests.integ.NO_AUTO_ML_REGIONS,
68+
reason="AutoML is not supported in the region yet.",
69+
)
6570
def test_auto_ml_fit(sagemaker_session):
6671
auto_ml = AutoML(
6772
role=ROLE,
@@ -75,6 +80,10 @@ def test_auto_ml_fit(sagemaker_session):
7580
auto_ml.fit(inputs)
7681

7782

83+
@pytest.mark.skipif(
84+
tests.integ.test_region() in tests.integ.NO_AUTO_ML_REGIONS,
85+
reason="AutoML is not supported in the region yet.",
86+
)
7887
def test_auto_ml_fit_local_input(sagemaker_session):
7988
auto_ml = AutoML(
8089
role=ROLE,
@@ -88,6 +97,10 @@ def test_auto_ml_fit_local_input(sagemaker_session):
8897
auto_ml.fit(inputs)
8998

9099

100+
@pytest.mark.skipif(
101+
tests.integ.test_region() in tests.integ.NO_AUTO_ML_REGIONS,
102+
reason="AutoML is not supported in the region yet.",
103+
)
91104
def test_auto_ml_input_object_fit(sagemaker_session):
92105
auto_ml = AutoML(
93106
role=ROLE,
@@ -101,6 +114,10 @@ def test_auto_ml_input_object_fit(sagemaker_session):
101114
auto_ml.fit(inputs)
102115

103116

117+
@pytest.mark.skipif(
118+
tests.integ.test_region() in tests.integ.NO_AUTO_ML_REGIONS,
119+
reason="AutoML is not supported in the region yet.",
120+
)
104121
def test_auto_ml_fit_optional_args(sagemaker_session):
105122
output_path = "s3://sagemaker-us-east-2-{}/{}".format(DEV_ACCOUNT, "specified_ouput_path")
106123
problem_type = "MulticlassClassification"
@@ -126,6 +143,10 @@ def test_auto_ml_fit_optional_args(sagemaker_session):
126143
assert auto_ml_desc["OutputDataConfig"]["S3OutputPath"] == output_path
127144

128145

146+
@pytest.mark.skipif(
147+
tests.integ.test_region() in tests.integ.NO_AUTO_ML_REGIONS,
148+
reason="AutoML is not supported in the region yet.",
149+
)
129150
def test_auto_ml_invalid_target_attribute(sagemaker_session):
130151
auto_ml = AutoML(
131152
role=ROLE, target_attribute_name="y", sagemaker_session=sagemaker_session, max_candidates=1
@@ -137,7 +158,13 @@ def test_auto_ml_invalid_target_attribute(sagemaker_session):
137158
auto_ml.fit(inputs)
138159

139160

161+
@pytest.mark.skipif(
162+
tests.integ.test_region() in tests.integ.NO_AUTO_ML_REGIONS,
163+
reason="AutoML is not supported in the region yet.",
164+
)
140165
def test_auto_ml_describe_auto_ml_job(sagemaker_session):
166+
auto_ml_utils.create_auto_ml_job_if_not_exist(sagemaker_session)
167+
141168
auto_ml = AutoML(
142169
role=ROLE, target_attribute_name=TARGET_ATTRIBUTE_NAME, sagemaker_session=sagemaker_session
143170
)
@@ -151,7 +178,13 @@ def test_auto_ml_describe_auto_ml_job(sagemaker_session):
151178
assert desc["OutputDataConfig"] == EXPECTED_DEFAULT_OUTPUT_CONFIG
152179

153180

181+
@pytest.mark.skipif(
182+
tests.integ.test_region() in tests.integ.NO_AUTO_ML_REGIONS,
183+
reason="AutoML is not supported in the region yet.",
184+
)
154185
def test_list_candidates(sagemaker_session):
186+
auto_ml_utils.create_auto_ml_job_if_not_exist(sagemaker_session)
187+
155188
auto_ml = AutoML(
156189
role=ROLE, target_attribute_name=TARGET_ATTRIBUTE_NAME, sagemaker_session=sagemaker_session
157190
)
@@ -160,7 +193,13 @@ def test_list_candidates(sagemaker_session):
160193
assert len(candidates) == 3
161194

162195

196+
@pytest.mark.skipif(
197+
tests.integ.test_region() in tests.integ.NO_AUTO_ML_REGIONS,
198+
reason="AutoML is not supported in the region yet.",
199+
)
163200
def test_best_candidate(sagemaker_session):
201+
auto_ml_utils.create_auto_ml_job_if_not_exist(sagemaker_session)
202+
164203
auto_ml = AutoML(
165204
role=ROLE, target_attribute_name=TARGET_ATTRIBUTE_NAME, sagemaker_session=sagemaker_session
166205
)
@@ -170,7 +209,13 @@ def test_best_candidate(sagemaker_session):
170209
assert best_candidate["CandidateStatus"] == "Completed"
171210

172211

212+
@pytest.mark.skipif(
213+
tests.integ.test_region() in tests.integ.NO_AUTO_ML_REGIONS,
214+
reason="AutoML is not supported in the region yet.",
215+
)
173216
def test_deploy_best_candidate(sagemaker_session):
217+
auto_ml_utils.create_auto_ml_job_if_not_exist(sagemaker_session)
218+
174219
auto_ml = AutoML(
175220
role=ROLE, target_attribute_name=TARGET_ATTRIBUTE_NAME, sagemaker_session=sagemaker_session
176221
)
@@ -192,7 +237,13 @@ def test_deploy_best_candidate(sagemaker_session):
192237
sagemaker_session.sagemaker_client.delete_endpoint(EndpointName=endpoint_name)
193238

194239

240+
@pytest.mark.skipif(
241+
tests.integ.test_region() in tests.integ.NO_AUTO_ML_REGIONS,
242+
reason="AutoML is not supported in the region yet.",
243+
)
195244
def test_candidate_estimator_default_rerun_and_deploy(sagemaker_session):
245+
auto_ml_utils.create_auto_ml_job_if_not_exist(sagemaker_session)
246+
196247
auto_ml = AutoML(
197248
role=ROLE, target_attribute_name=TARGET_ATTRIBUTE_NAME, sagemaker_session=sagemaker_session
198249
)
@@ -219,7 +270,13 @@ def test_candidate_estimator_default_rerun_and_deploy(sagemaker_session):
219270
sagemaker_session.sagemaker_client.delete_endpoint(EndpointName=endpoint_name)
220271

221272

273+
@pytest.mark.skipif(
274+
tests.integ.test_region() in tests.integ.NO_AUTO_ML_REGIONS,
275+
reason="AutoML is not supported in the region yet.",
276+
)
222277
def test_candidate_estimator_rerun_with_optional_args(sagemaker_session):
278+
auto_ml_utils.create_auto_ml_job_if_not_exist(sagemaker_session)
279+
223280
auto_ml = AutoML(
224281
role=ROLE, target_attribute_name=TARGET_ATTRIBUTE_NAME, sagemaker_session=sagemaker_session
225282
)
@@ -246,7 +303,13 @@ def test_candidate_estimator_rerun_with_optional_args(sagemaker_session):
246303
sagemaker_session.sagemaker_client.delete_endpoint(EndpointName=endpoint_name)
247304

248305

306+
@pytest.mark.skipif(
307+
tests.integ.test_region() in tests.integ.NO_AUTO_ML_REGIONS,
308+
reason="AutoML is not supported in the region yet.",
309+
)
249310
def test_candidate_estimator_get_steps(sagemaker_session):
311+
auto_ml_utils.create_auto_ml_job_if_not_exist(sagemaker_session)
312+
250313
auto_ml = AutoML(
251314
role=ROLE, target_attribute_name=TARGET_ATTRIBUTE_NAME, sagemaker_session=sagemaker_session
252315
)

tests/unit/test_tf_estimator.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -988,6 +988,13 @@ def test_py2_version_deprecated(sagemaker_session):
988988
assert msg in str(e.value)
989989

990990

991+
def test_py2_version_is_not_deprecated(sagemaker_session):
992+
estimator = _build_tf(
993+
sagemaker_session=sagemaker_session, framework_version="1.15.0", py_version="py2"
994+
)
995+
assert estimator.py_version == "py2"
996+
997+
991998
def test_py3_is_default_version_before_tf1_14(sagemaker_session):
992999
estimator = _build_tf(sagemaker_session=sagemaker_session, framework_version="1.13")
9931000

0 commit comments

Comments
 (0)