49
49
50
50
51
51
# use a succeeded AutoML job to test describe and list candidates method, otherwise tests will run too long
52
- # reusable- job will be created once if it doesn't exist, and be reused in relevant tests.
52
+ # test-session- job will be created once per session if it doesn't exist, and be reused in relevant tests.
53
53
@pytest .fixture (scope = "module" )
54
- def reusable_job_name ():
55
- job_name = unique_name_from_base ("reusable -job" , max_length = 32 )
54
+ def test_session_job_name ():
55
+ job_name = unique_name_from_base ("test-session -job" , max_length = 32 )
56
56
return job_name
57
57
58
58
@@ -199,7 +199,7 @@ def test_auto_ml_invalid_target_attribute(sagemaker_session):
199
199
tests .integ .test_region () in tests .integ .NO_AUTO_ML_REGIONS ,
200
200
reason = "AutoML is not supported in the region yet." ,
201
201
)
202
- def test_auto_ml_describe_auto_ml_job (sagemaker_session , reusable_job_name ):
202
+ def test_auto_ml_describe_auto_ml_job (sagemaker_session , test_session_job_name ):
203
203
expected_default_input_config = [
204
204
{
205
205
"DataSource" : {
@@ -221,13 +221,13 @@ def test_auto_ml_describe_auto_ml_job(sagemaker_session, reusable_job_name):
221
221
)
222
222
}
223
223
224
- auto_ml_utils .create_auto_ml_job_if_not_exist (sagemaker_session , reusable_job_name )
224
+ auto_ml_utils .create_auto_ml_job_if_not_exist (sagemaker_session , test_session_job_name )
225
225
auto_ml = AutoML (
226
226
role = ROLE , target_attribute_name = TARGET_ATTRIBUTE_NAME , sagemaker_session = sagemaker_session
227
227
)
228
228
229
- desc = auto_ml .describe_auto_ml_job (job_name = reusable_job_name )
230
- assert desc ["AutoMLJobName" ] == reusable_job_name
229
+ desc = auto_ml .describe_auto_ml_job (job_name = test_session_job_name )
230
+ assert desc ["AutoMLJobName" ] == test_session_job_name
231
231
assert desc ["AutoMLJobStatus" ] == "Completed"
232
232
assert isinstance (desc ["BestCandidate" ], dict )
233
233
assert desc ["InputDataConfig" ] == expected_default_input_config
@@ -239,7 +239,7 @@ def test_auto_ml_describe_auto_ml_job(sagemaker_session, reusable_job_name):
239
239
tests .integ .test_region () in tests .integ .NO_AUTO_ML_REGIONS ,
240
240
reason = "AutoML is not supported in the region yet." ,
241
241
)
242
- def test_auto_ml_attach (sagemaker_session , reusable_job_name ):
242
+ def test_auto_ml_attach (sagemaker_session , test_session_job_name ):
243
243
expected_default_input_config = [
244
244
{
245
245
"DataSource" : {
@@ -261,13 +261,13 @@ def test_auto_ml_attach(sagemaker_session, reusable_job_name):
261
261
)
262
262
}
263
263
264
- auto_ml_utils .create_auto_ml_job_if_not_exist (sagemaker_session , reusable_job_name )
264
+ auto_ml_utils .create_auto_ml_job_if_not_exist (sagemaker_session , test_session_job_name )
265
265
266
266
attached_automl_job = AutoML .attach (
267
- auto_ml_job_name = reusable_job_name , sagemaker_session = sagemaker_session
267
+ auto_ml_job_name = test_session_job_name , sagemaker_session = sagemaker_session
268
268
)
269
269
attached_desc = attached_automl_job .describe_auto_ml_job ()
270
- assert attached_desc ["AutoMLJobName" ] == reusable_job_name
270
+ assert attached_desc ["AutoMLJobName" ] == test_session_job_name
271
271
assert attached_desc ["AutoMLJobStatus" ] == "Completed"
272
272
assert isinstance (attached_desc ["BestCandidate" ], dict )
273
273
assert attached_desc ["InputDataConfig" ] == expected_default_input_config
@@ -279,28 +279,28 @@ def test_auto_ml_attach(sagemaker_session, reusable_job_name):
279
279
tests .integ .test_region () in tests .integ .NO_AUTO_ML_REGIONS ,
280
280
reason = "AutoML is not supported in the region yet." ,
281
281
)
282
- def test_list_candidates (sagemaker_session , reusable_job_name ):
283
- auto_ml_utils .create_auto_ml_job_if_not_exist (sagemaker_session , reusable_job_name )
282
+ def test_list_candidates (sagemaker_session , test_session_job_name ):
283
+ auto_ml_utils .create_auto_ml_job_if_not_exist (sagemaker_session , test_session_job_name )
284
284
285
285
auto_ml = AutoML (
286
286
role = ROLE , target_attribute_name = TARGET_ATTRIBUTE_NAME , sagemaker_session = sagemaker_session
287
287
)
288
288
289
- candidates = auto_ml .list_candidates (job_name = reusable_job_name )
289
+ candidates = auto_ml .list_candidates (job_name = test_session_job_name )
290
290
assert len (candidates ) == 3
291
291
292
292
293
293
@pytest .mark .skipif (
294
294
tests .integ .test_region () in tests .integ .NO_AUTO_ML_REGIONS ,
295
295
reason = "AutoML is not supported in the region yet." ,
296
296
)
297
- def test_best_candidate (sagemaker_session , reusable_job_name ):
298
- auto_ml_utils .create_auto_ml_job_if_not_exist (sagemaker_session , reusable_job_name )
297
+ def test_best_candidate (sagemaker_session , test_session_job_name ):
298
+ auto_ml_utils .create_auto_ml_job_if_not_exist (sagemaker_session , test_session_job_name )
299
299
300
300
auto_ml = AutoML (
301
301
role = ROLE , target_attribute_name = TARGET_ATTRIBUTE_NAME , sagemaker_session = sagemaker_session
302
302
)
303
- best_candidate = auto_ml .best_candidate (job_name = reusable_job_name )
303
+ best_candidate = auto_ml .best_candidate (job_name = test_session_job_name )
304
304
assert len (best_candidate ["InferenceContainers" ]) == 3
305
305
assert len (best_candidate ["CandidateSteps" ]) == 4
306
306
assert best_candidate ["CandidateStatus" ] == "Completed"
@@ -311,13 +311,13 @@ def test_best_candidate(sagemaker_session, reusable_job_name):
311
311
reason = "AutoML is not supported in the region yet." ,
312
312
)
313
313
@pytest .mark .release
314
- def test_deploy_best_candidate (sagemaker_session , cpu_instance_type , reusable_job_name ):
315
- auto_ml_utils .create_auto_ml_job_if_not_exist (sagemaker_session , reusable_job_name )
314
+ def test_deploy_best_candidate (sagemaker_session , cpu_instance_type , test_session_job_name ):
315
+ auto_ml_utils .create_auto_ml_job_if_not_exist (sagemaker_session , test_session_job_name )
316
316
317
317
auto_ml = AutoML (
318
318
role = ROLE , target_attribute_name = TARGET_ATTRIBUTE_NAME , sagemaker_session = sagemaker_session
319
319
)
320
- best_candidate = auto_ml .best_candidate (job_name = reusable_job_name )
320
+ best_candidate = auto_ml .best_candidate (job_name = test_session_job_name )
321
321
endpoint_name = unique_name_from_base ("sagemaker-auto-ml-best-candidate-test" )
322
322
323
323
with timeout (minutes = AUTO_ML_DEFAULT_TIMEMOUT_MINUTES ):
@@ -343,15 +343,15 @@ def test_deploy_best_candidate(sagemaker_session, cpu_instance_type, reusable_jo
343
343
reason = "" ,
344
344
)
345
345
def test_candidate_estimator_default_rerun_and_deploy (
346
- sagemaker_session , cpu_instance_type , reusable_job_name
346
+ sagemaker_session , cpu_instance_type , test_session_job_name
347
347
):
348
- auto_ml_utils .create_auto_ml_job_if_not_exist (sagemaker_session , reusable_job_name )
348
+ auto_ml_utils .create_auto_ml_job_if_not_exist (sagemaker_session , test_session_job_name )
349
349
350
350
auto_ml = AutoML (
351
351
role = ROLE , target_attribute_name = TARGET_ATTRIBUTE_NAME , sagemaker_session = sagemaker_session
352
352
)
353
353
354
- candidates = auto_ml .list_candidates (job_name = reusable_job_name )
354
+ candidates = auto_ml .list_candidates (job_name = test_session_job_name )
355
355
candidate = candidates [1 ]
356
356
357
357
candidate_estimator = CandidateEstimator (candidate , sagemaker_session )
@@ -377,13 +377,13 @@ def test_candidate_estimator_default_rerun_and_deploy(
377
377
tests .integ .test_region () in tests .integ .NO_AUTO_ML_REGIONS ,
378
378
reason = "AutoML is not supported in the region yet." ,
379
379
)
380
- def test_candidate_estimator_get_steps (sagemaker_session , reusable_job_name ):
381
- auto_ml_utils .create_auto_ml_job_if_not_exist (sagemaker_session , reusable_job_name )
380
+ def test_candidate_estimator_get_steps (sagemaker_session , test_session_job_name ):
381
+ auto_ml_utils .create_auto_ml_job_if_not_exist (sagemaker_session , test_session_job_name )
382
382
383
383
auto_ml = AutoML (
384
384
role = ROLE , target_attribute_name = TARGET_ATTRIBUTE_NAME , sagemaker_session = sagemaker_session
385
385
)
386
- candidates = auto_ml .list_candidates (job_name = reusable_job_name )
386
+ candidates = auto_ml .list_candidates (job_name = test_session_job_name )
387
387
candidate = candidates [1 ]
388
388
389
389
candidate_estimator = CandidateEstimator (candidate , sagemaker_session )
0 commit comments