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
ROLE = "SageMakerRole"
37
38
JOB_NAME = "auto-ml-{}" .format (time .strftime ("%y%m%d-%H%M%S" ))
38
39
39
40
# use a succeeded AutoML job to test describe and list candidates method, otherwise tests will run too long
40
- AUTO_ML_JOB_NAME = "sagemaker-auto-gamma-ml- test"
41
+ AUTO_ML_JOB_NAME = "python-sdk-integ- test-base-job "
41
42
42
43
EXPECTED_DEFAULT_JOB_CONFIG = {
43
44
"CompletionCriteria" : {"MaxCandidates" : 3 },
44
45
"SecurityConfig" : {"EnableInterContainerTrafficEncryption" : False },
45
46
}
46
47
47
48
49
+ @pytest .mark .skipif (
50
+ tests .integ .test_region () in tests .integ .NO_AUTO_ML_REGIONS ,
51
+ reason = "AutoML is not supported in the region yet." ,
52
+ )
48
53
def test_auto_ml_fit (sagemaker_session ):
49
54
auto_ml = AutoML (
50
55
role = ROLE ,
@@ -58,6 +63,10 @@ def test_auto_ml_fit(sagemaker_session):
58
63
auto_ml .fit (inputs )
59
64
60
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
+ )
61
70
def test_auto_ml_fit_local_input (sagemaker_session ):
62
71
auto_ml = AutoML (
63
72
role = ROLE ,
@@ -71,6 +80,10 @@ def test_auto_ml_fit_local_input(sagemaker_session):
71
80
auto_ml .fit (inputs )
72
81
73
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
+ )
74
87
def test_auto_ml_input_object_fit (sagemaker_session ):
75
88
auto_ml = AutoML (
76
89
role = ROLE ,
@@ -84,6 +97,10 @@ def test_auto_ml_input_object_fit(sagemaker_session):
84
97
auto_ml .fit (inputs )
85
98
86
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
+ )
87
104
def test_auto_ml_fit_optional_args (sagemaker_session ):
88
105
output_path = "s3://{}/{}" .format (sagemaker_session .default_bucket (), "specified_ouput_path" )
89
106
problem_type = "MulticlassClassification"
@@ -109,6 +126,10 @@ def test_auto_ml_fit_optional_args(sagemaker_session):
109
126
assert auto_ml_desc ["OutputDataConfig" ]["S3OutputPath" ] == output_path
110
127
111
128
129
+ @pytest .mark .skipif (
130
+ tests .integ .test_region () in tests .integ .NO_AUTO_ML_REGIONS ,
131
+ reason = "AutoML is not supported in the region yet." ,
132
+ )
112
133
def test_auto_ml_invalid_target_attribute (sagemaker_session ):
113
134
auto_ml = AutoML (
114
135
role = ROLE , target_attribute_name = "y" , sagemaker_session = sagemaker_session , max_candidates = 1
@@ -120,6 +141,10 @@ def test_auto_ml_invalid_target_attribute(sagemaker_session):
120
141
auto_ml .fit (inputs )
121
142
122
143
144
+ @pytest .mark .skipif (
145
+ tests .integ .test_region () in tests .integ .NO_AUTO_ML_REGIONS ,
146
+ reason = "AutoML is not supported in the region yet." ,
147
+ )
123
148
def test_auto_ml_describe_auto_ml_job (sagemaker_session ):
124
149
expected_default_input_config = [
125
150
{
@@ -138,6 +163,7 @@ def test_auto_ml_describe_auto_ml_job(sagemaker_session):
138
163
"S3OutputPath" : "s3://{}/" .format (sagemaker_session .default_bucket ())
139
164
}
140
165
166
+ auto_ml_utils .create_auto_ml_job_if_not_exist (sagemaker_session )
141
167
auto_ml = AutoML (
142
168
role = ROLE , target_attribute_name = TARGET_ATTRIBUTE_NAME , sagemaker_session = sagemaker_session
143
169
)
@@ -151,7 +177,13 @@ def test_auto_ml_describe_auto_ml_job(sagemaker_session):
151
177
assert desc ["OutputDataConfig" ] == expected_default_output_config
152
178
153
179
180
+ @pytest .mark .skipif (
181
+ tests .integ .test_region () in tests .integ .NO_AUTO_ML_REGIONS ,
182
+ reason = "AutoML is not supported in the region yet." ,
183
+ )
154
184
def test_list_candidates (sagemaker_session ):
185
+ auto_ml_utils .create_auto_ml_job_if_not_exist (sagemaker_session )
186
+
155
187
auto_ml = AutoML (
156
188
role = ROLE , target_attribute_name = TARGET_ATTRIBUTE_NAME , sagemaker_session = sagemaker_session
157
189
)
@@ -160,7 +192,13 @@ def test_list_candidates(sagemaker_session):
160
192
assert len (candidates ) == 3
161
193
162
194
195
+ @pytest .mark .skipif (
196
+ tests .integ .test_region () in tests .integ .NO_AUTO_ML_REGIONS ,
197
+ reason = "AutoML is not supported in the region yet." ,
198
+ )
163
199
def test_best_candidate (sagemaker_session ):
200
+ auto_ml_utils .create_auto_ml_job_if_not_exist (sagemaker_session )
201
+
164
202
auto_ml = AutoML (
165
203
role = ROLE , target_attribute_name = TARGET_ATTRIBUTE_NAME , sagemaker_session = sagemaker_session
166
204
)
@@ -170,7 +208,13 @@ def test_best_candidate(sagemaker_session):
170
208
assert best_candidate ["CandidateStatus" ] == "Completed"
171
209
172
210
211
+ @pytest .mark .skipif (
212
+ tests .integ .test_region () in tests .integ .NO_AUTO_ML_REGIONS ,
213
+ reason = "AutoML is not supported in the region yet." ,
214
+ )
173
215
def test_deploy_best_candidate (sagemaker_session ):
216
+ auto_ml_utils .create_auto_ml_job_if_not_exist (sagemaker_session )
217
+
174
218
auto_ml = AutoML (
175
219
role = ROLE , target_attribute_name = TARGET_ATTRIBUTE_NAME , sagemaker_session = sagemaker_session
176
220
)
@@ -192,7 +236,13 @@ def test_deploy_best_candidate(sagemaker_session):
192
236
sagemaker_session .sagemaker_client .delete_endpoint (EndpointName = endpoint_name )
193
237
194
238
239
+ @pytest .mark .skipif (
240
+ tests .integ .test_region () in tests .integ .NO_AUTO_ML_REGIONS ,
241
+ reason = "AutoML is not supported in the region yet." ,
242
+ )
195
243
def test_candidate_estimator_default_rerun_and_deploy (sagemaker_session ):
244
+ auto_ml_utils .create_auto_ml_job_if_not_exist (sagemaker_session )
245
+
196
246
auto_ml = AutoML (
197
247
role = ROLE , target_attribute_name = TARGET_ATTRIBUTE_NAME , sagemaker_session = sagemaker_session
198
248
)
@@ -219,7 +269,13 @@ def test_candidate_estimator_default_rerun_and_deploy(sagemaker_session):
219
269
sagemaker_session .sagemaker_client .delete_endpoint (EndpointName = endpoint_name )
220
270
221
271
272
+ @pytest .mark .skipif (
273
+ tests .integ .test_region () in tests .integ .NO_AUTO_ML_REGIONS ,
274
+ reason = "AutoML is not supported in the region yet." ,
275
+ )
222
276
def test_candidate_estimator_rerun_with_optional_args (sagemaker_session ):
277
+ auto_ml_utils .create_auto_ml_job_if_not_exist (sagemaker_session )
278
+
223
279
auto_ml = AutoML (
224
280
role = ROLE , target_attribute_name = TARGET_ATTRIBUTE_NAME , sagemaker_session = sagemaker_session
225
281
)
@@ -246,7 +302,13 @@ def test_candidate_estimator_rerun_with_optional_args(sagemaker_session):
246
302
sagemaker_session .sagemaker_client .delete_endpoint (EndpointName = endpoint_name )
247
303
248
304
305
+ @pytest .mark .skipif (
306
+ tests .integ .test_region () in tests .integ .NO_AUTO_ML_REGIONS ,
307
+ reason = "AutoML is not supported in the region yet." ,
308
+ )
249
309
def test_candidate_estimator_get_steps (sagemaker_session ):
310
+ auto_ml_utils .create_auto_ml_job_if_not_exist (sagemaker_session )
311
+
250
312
auto_ml = AutoML (
251
313
role = ROLE , target_attribute_name = TARGET_ATTRIBUTE_NAME , sagemaker_session = sagemaker_session
252
314
)
0 commit comments