1616import time
1717
1818import pytest
19+ import tests .integ
1920from sagemaker import AutoML , CandidateEstimator , AutoMLInput
2021
2122from sagemaker .exceptions import UnexpectedStatusException
2223from 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
2425from tests .integ .timeout import timeout
2526
2627DEV_ACCOUNT = 142577830533
3839JOB_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
4344EXPECTED_DEFAULT_INPUT_CONFIG = [
4445 {
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+ )
6570def 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+ )
7887def 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+ )
91104def 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+ )
104121def 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+ )
129150def 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+ )
140165def 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+ )
154185def 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+ )
163200def 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+ )
173216def 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+ )
195244def 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+ )
222277def 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+ )
249310def 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 )
0 commit comments