19
19
20
20
from tests .integ .sagemaker .workflow .helpers import wait_pipeline_execution
21
21
from sagemaker .processing import ProcessingInput
22
- from sagemaker .session import get_execution_role
23
22
from sagemaker .sklearn .processing import SKLearnProcessor
24
23
from sagemaker .dataset_definition .inputs import DatasetDefinition , AthenaDatasetDefinition
25
24
from sagemaker .workflow .execution_variables import ExecutionVariables
33
32
from tests .integ import DATA_DIR
34
33
35
34
36
- @pytest .fixture (scope = "module" )
37
- def region_name (sagemaker_session ):
38
- return sagemaker_session .boto_session .region_name
39
-
40
-
41
- @pytest .fixture (scope = "module" )
42
- def role (sagemaker_session ):
43
- return get_execution_role (sagemaker_session )
44
-
45
-
46
- @pytest .fixture (scope = "module" )
47
- def script_dir ():
48
- return os .path .join (DATA_DIR , "sklearn_processing" )
49
-
50
-
51
35
@pytest .fixture
52
36
def pipeline_name ():
53
37
return f"my-pipeline-{ int (time .time () * 10 ** 7 )} "
54
38
55
39
56
40
@pytest .fixture
57
- def smclient (sagemaker_session ):
58
- return sagemaker_session .boto_session .client ("sagemaker" )
59
-
60
-
61
- @pytest .fixture
62
- def athena_dataset_definition (sagemaker_session ):
41
+ def athena_dataset_definition (sagemaker_session_for_pipeline ):
63
42
return DatasetDefinition (
64
43
local_path = "/opt/ml/processing/input/add" ,
65
44
data_distribution_type = "FullyReplicated" ,
@@ -69,15 +48,15 @@ def athena_dataset_definition(sagemaker_session):
69
48
database = "default" ,
70
49
work_group = "workgroup" ,
71
50
query_string = 'SELECT * FROM "default"."s3_test_table_$STAGE_$REGIONUNDERSCORED";' ,
72
- output_s3_uri = f"s3://{ sagemaker_session .default_bucket ()} /add" ,
51
+ output_s3_uri = f"s3://{ sagemaker_session_for_pipeline .default_bucket ()} /add" ,
73
52
output_format = "JSON" ,
74
53
output_compression = "GZIP" ,
75
54
),
76
55
)
77
56
78
57
79
58
def test_pipeline_execution_with_default_experiment_config (
80
- sagemaker_session ,
59
+ sagemaker_session_for_pipeline ,
81
60
smclient ,
82
61
role ,
83
62
sklearn_latest_version ,
@@ -99,7 +78,7 @@ def test_pipeline_execution_with_default_experiment_config(
99
78
instance_type = cpu_instance_type ,
100
79
instance_count = instance_count ,
101
80
command = ["python3" ],
102
- sagemaker_session = sagemaker_session ,
81
+ sagemaker_session = sagemaker_session_for_pipeline ,
103
82
base_job_name = "test-sklearn" ,
104
83
)
105
84
@@ -113,7 +92,7 @@ def test_pipeline_execution_with_default_experiment_config(
113
92
name = pipeline_name ,
114
93
parameters = [instance_count ],
115
94
steps = [step_sklearn ],
116
- sagemaker_session = sagemaker_session ,
95
+ sagemaker_session = sagemaker_session_for_pipeline ,
117
96
)
118
97
119
98
try :
@@ -142,7 +121,7 @@ def test_pipeline_execution_with_default_experiment_config(
142
121
143
122
144
123
def test_pipeline_execution_with_custom_experiment_config (
145
- sagemaker_session ,
124
+ sagemaker_session_for_pipeline ,
146
125
smclient ,
147
126
role ,
148
127
sklearn_latest_version ,
@@ -164,7 +143,7 @@ def test_pipeline_execution_with_custom_experiment_config(
164
143
instance_type = cpu_instance_type ,
165
144
instance_count = instance_count ,
166
145
command = ["python3" ],
167
- sagemaker_session = sagemaker_session ,
146
+ sagemaker_session = sagemaker_session_for_pipeline ,
168
147
base_job_name = "test-sklearn" ,
169
148
)
170
149
@@ -185,7 +164,7 @@ def test_pipeline_execution_with_custom_experiment_config(
185
164
trial_name = Join (on = "-" , values = ["my-trial" , ExecutionVariables .PIPELINE_EXECUTION_ID ]),
186
165
),
187
166
steps = [step_sklearn ],
188
- sagemaker_session = sagemaker_session ,
167
+ sagemaker_session = sagemaker_session_for_pipeline ,
189
168
)
190
169
191
170
try :
0 commit comments