16
16
import time
17
17
18
18
import pytest
19
+ import tests .integ
19
20
from sagemaker import AutoML , CandidateEstimator , AutoMLInput
20
21
21
22
from sagemaker .exceptions import UnexpectedStatusException
22
23
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
24
25
from tests .integ .timeout import timeout
25
26
26
27
DEV_ACCOUNT = 142577830533
38
39
JOB_NAME = "auto-ml-{}" .format (time .strftime ("%y%m%d-%H%M%S" ))
39
40
40
41
# 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 "
42
43
43
44
EXPECTED_DEFAULT_INPUT_CONFIG = [
44
45
{
62
63
}
63
64
64
65
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
+ )
65
70
def test_auto_ml_fit (sagemaker_session ):
66
71
auto_ml = AutoML (
67
72
role = ROLE ,
@@ -75,6 +80,10 @@ def test_auto_ml_fit(sagemaker_session):
75
80
auto_ml .fit (inputs )
76
81
77
82
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
+ )
78
87
def test_auto_ml_fit_local_input (sagemaker_session ):
79
88
auto_ml = AutoML (
80
89
role = ROLE ,
@@ -88,6 +97,10 @@ def test_auto_ml_fit_local_input(sagemaker_session):
88
97
auto_ml .fit (inputs )
89
98
90
99
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
+ )
91
104
def test_auto_ml_input_object_fit (sagemaker_session ):
92
105
auto_ml = AutoML (
93
106
role = ROLE ,
@@ -101,6 +114,10 @@ def test_auto_ml_input_object_fit(sagemaker_session):
101
114
auto_ml .fit (inputs )
102
115
103
116
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
+ )
104
121
def test_auto_ml_fit_optional_args (sagemaker_session ):
105
122
output_path = "s3://sagemaker-us-east-2-{}/{}" .format (DEV_ACCOUNT , "specified_ouput_path" )
106
123
problem_type = "MulticlassClassification"
@@ -126,6 +143,10 @@ def test_auto_ml_fit_optional_args(sagemaker_session):
126
143
assert auto_ml_desc ["OutputDataConfig" ]["S3OutputPath" ] == output_path
127
144
128
145
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
+ )
129
150
def test_auto_ml_invalid_target_attribute (sagemaker_session ):
130
151
auto_ml = AutoML (
131
152
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):
137
158
auto_ml .fit (inputs )
138
159
139
160
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
+ )
140
165
def test_auto_ml_describe_auto_ml_job (sagemaker_session ):
166
+ auto_ml_utils .create_auto_ml_job_if_not_exist (sagemaker_session )
167
+
141
168
auto_ml = AutoML (
142
169
role = ROLE , target_attribute_name = TARGET_ATTRIBUTE_NAME , sagemaker_session = sagemaker_session
143
170
)
@@ -151,7 +178,13 @@ def test_auto_ml_describe_auto_ml_job(sagemaker_session):
151
178
assert desc ["OutputDataConfig" ] == EXPECTED_DEFAULT_OUTPUT_CONFIG
152
179
153
180
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
+ )
154
185
def test_list_candidates (sagemaker_session ):
186
+ auto_ml_utils .create_auto_ml_job_if_not_exist (sagemaker_session )
187
+
155
188
auto_ml = AutoML (
156
189
role = ROLE , target_attribute_name = TARGET_ATTRIBUTE_NAME , sagemaker_session = sagemaker_session
157
190
)
@@ -160,7 +193,13 @@ def test_list_candidates(sagemaker_session):
160
193
assert len (candidates ) == 3
161
194
162
195
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
+ )
163
200
def test_best_candidate (sagemaker_session ):
201
+ auto_ml_utils .create_auto_ml_job_if_not_exist (sagemaker_session )
202
+
164
203
auto_ml = AutoML (
165
204
role = ROLE , target_attribute_name = TARGET_ATTRIBUTE_NAME , sagemaker_session = sagemaker_session
166
205
)
@@ -170,7 +209,13 @@ def test_best_candidate(sagemaker_session):
170
209
assert best_candidate ["CandidateStatus" ] == "Completed"
171
210
172
211
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
+ )
173
216
def test_deploy_best_candidate (sagemaker_session ):
217
+ auto_ml_utils .create_auto_ml_job_if_not_exist (sagemaker_session )
218
+
174
219
auto_ml = AutoML (
175
220
role = ROLE , target_attribute_name = TARGET_ATTRIBUTE_NAME , sagemaker_session = sagemaker_session
176
221
)
@@ -192,7 +237,13 @@ def test_deploy_best_candidate(sagemaker_session):
192
237
sagemaker_session .sagemaker_client .delete_endpoint (EndpointName = endpoint_name )
193
238
194
239
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
+ )
195
244
def test_candidate_estimator_default_rerun_and_deploy (sagemaker_session ):
245
+ auto_ml_utils .create_auto_ml_job_if_not_exist (sagemaker_session )
246
+
196
247
auto_ml = AutoML (
197
248
role = ROLE , target_attribute_name = TARGET_ATTRIBUTE_NAME , sagemaker_session = sagemaker_session
198
249
)
@@ -219,7 +270,13 @@ def test_candidate_estimator_default_rerun_and_deploy(sagemaker_session):
219
270
sagemaker_session .sagemaker_client .delete_endpoint (EndpointName = endpoint_name )
220
271
221
272
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
+ )
222
277
def test_candidate_estimator_rerun_with_optional_args (sagemaker_session ):
278
+ auto_ml_utils .create_auto_ml_job_if_not_exist (sagemaker_session )
279
+
223
280
auto_ml = AutoML (
224
281
role = ROLE , target_attribute_name = TARGET_ATTRIBUTE_NAME , sagemaker_session = sagemaker_session
225
282
)
@@ -246,7 +303,13 @@ def test_candidate_estimator_rerun_with_optional_args(sagemaker_session):
246
303
sagemaker_session .sagemaker_client .delete_endpoint (EndpointName = endpoint_name )
247
304
248
305
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
+ )
249
310
def test_candidate_estimator_get_steps (sagemaker_session ):
311
+ auto_ml_utils .create_auto_ml_job_if_not_exist (sagemaker_session )
312
+
250
313
auto_ml = AutoML (
251
314
role = ROLE , target_attribute_name = TARGET_ATTRIBUTE_NAME , sagemaker_session = sagemaker_session
252
315
)
0 commit comments