32
32
from sagemaker .experiments .trial_component import _TrialComponent
33
33
from sagemaker .sklearn import SKLearn
34
34
from sagemaker .utils import retry_with_backoff , unique_name_from_base
35
- from tests .integ .sagemaker .experiments .helpers import name , cleanup_exp_resources
35
+ from tests .integ .sagemaker .experiments .helpers import name , cleanup_exp_resources , clear_run_context
36
36
from sagemaker .experiments .run import (
37
37
RUN_NAME_BASE ,
38
38
DELIMITER ,
@@ -55,7 +55,7 @@ def artifact_file_path(tempdir):
55
55
metric_name = "Test-Local-Init-Log-Metric"
56
56
57
57
58
- def test_local_run_with_load (sagemaker_session , artifact_file_path ):
58
+ def test_local_run_with_load (sagemaker_session , artifact_file_path , clear_run_context ):
59
59
exp_name = f"My-Local-Exp-{ name ()} "
60
60
with cleanup_exp_resources (exp_names = [exp_name ], sagemaker_session = sagemaker_session ):
61
61
# Run name is not provided, will create a new TC
@@ -86,7 +86,9 @@ def verify_load_run():
86
86
retry_with_backoff (verify_load_run , 4 )
87
87
88
88
89
- def test_two_local_run_init_with_same_run_name_and_different_exp_names (sagemaker_session ):
89
+ def test_two_local_run_init_with_same_run_name_and_different_exp_names (
90
+ sagemaker_session , clear_run_context
91
+ ):
90
92
exp_name1 = f"my-two-local-exp1-{ name ()} "
91
93
exp_name2 = f"my-two-local-exp2-{ name ()} "
92
94
run_name = "test-run"
@@ -124,7 +126,9 @@ def test_two_local_run_init_with_same_run_name_and_different_exp_names(sagemaker
124
126
("my-test4" , "test-run" , "run-display-name-test" ), # with supplied display name
125
127
],
126
128
)
127
- def test_run_name_vs_trial_component_name_edge_cases (sagemaker_session , input_names ):
129
+ def test_run_name_vs_trial_component_name_edge_cases (
130
+ sagemaker_session , input_names , clear_run_context
131
+ ):
128
132
exp_name , run_name , run_display_name = input_names
129
133
with cleanup_exp_resources (exp_names = [exp_name ], sagemaker_session = sagemaker_session ):
130
134
with Run (
@@ -177,6 +181,7 @@ def test_run_from_local_and_train_job_and_all_exp_cfg_match(
177
181
execution_role ,
178
182
sagemaker_client_config ,
179
183
sagemaker_metrics_config ,
184
+ clear_run_context ,
180
185
):
181
186
# Notes:
182
187
# 1. The 1st Run created locally and its exp config was auto passed to the job
@@ -277,6 +282,7 @@ def test_run_from_local_and_train_job_and_exp_cfg_not_match(
277
282
execution_role ,
278
283
sagemaker_client_config ,
279
284
sagemaker_metrics_config ,
285
+ clear_run_context ,
280
286
):
281
287
# Notes:
282
288
# 1. The 1st Run created locally and its exp config was auto passed to the job
@@ -363,6 +369,7 @@ def test_run_from_train_job_only(
363
369
execution_role ,
364
370
sagemaker_client_config ,
365
371
sagemaker_metrics_config ,
372
+ clear_run_context ,
366
373
):
367
374
# Notes:
368
375
# 1. No Run created locally or specified in experiment config
@@ -413,6 +420,7 @@ def test_run_from_processing_job_and_override_default_exp_config(
413
420
execution_role ,
414
421
sagemaker_client_config ,
415
422
sagemaker_metrics_config ,
423
+ clear_run_context ,
416
424
):
417
425
# Notes:
418
426
# 1. The 1st Run (run) created locally
@@ -492,6 +500,7 @@ def test_run_from_transform_job(
492
500
execution_role ,
493
501
sagemaker_client_config ,
494
502
sagemaker_metrics_config ,
503
+ clear_run_context ,
495
504
):
496
505
# Notes:
497
506
# 1. The 1st Run (run) created locally
@@ -573,6 +582,7 @@ def test_load_run_auto_pass_in_exp_config_to_job(
573
582
execution_role ,
574
583
sagemaker_client_config ,
575
584
sagemaker_metrics_config ,
585
+ clear_run_context ,
576
586
):
577
587
# Notes:
578
588
# 1. In local side, load the Run created previously and invoke a job under the load context
@@ -621,7 +631,7 @@ def test_load_run_auto_pass_in_exp_config_to_job(
621
631
)
622
632
623
633
624
- def test_list (run_obj , sagemaker_session ):
634
+ def test_list (run_obj , sagemaker_session , clear_run_context ):
625
635
tc1 = _TrialComponent .create (
626
636
trial_component_name = f"non-run-tc1-{ name ()} " ,
627
637
sagemaker_session = sagemaker_session ,
@@ -643,7 +653,7 @@ def test_list(run_obj, sagemaker_session):
643
653
assert run_tcs [0 ].experiment_config == run_obj .experiment_config
644
654
645
655
646
- def test_list_twice (run_obj , sagemaker_session ):
656
+ def test_list_twice (run_obj , sagemaker_session , clear_run_context ):
647
657
tc1 = _TrialComponent .create (
648
658
trial_component_name = f"non-run-tc1-{ name ()} " ,
649
659
sagemaker_session = sagemaker_session ,
0 commit comments