18
18
import pytest
19
19
import numpy
20
20
21
- from sagemaker .sklearn import SKLearn
22
- from sagemaker .sklearn import SKLearnModel
21
+ from sagemaker .sklearn import SKLearn , SKLearnModel , SKLearnProcessor
23
22
from sagemaker .utils import sagemaker_timestamp , unique_name_from_base
24
23
from tests .integ import DATA_DIR , TRAINING_DEFAULT_TIMEOUT_MINUTES
25
24
from tests .integ .timeout import timeout , timeout_and_delete_endpoint_by_name
26
25
26
+ ROLE = "SageMakerRole"
27
+
27
28
28
29
@pytest .fixture (scope = "module" )
29
30
@pytest .mark .skip (
@@ -45,6 +46,20 @@ def sklearn_training_job(
45
46
sagemaker_session .boto_region_name
46
47
47
48
49
+ def test_framework_processing_job_with_deps (
50
+ sagemaker_session ,
51
+ sklearn_latest_version ,
52
+ sklearn_latest_py_version ,
53
+ cpu_instance_type ,
54
+ ):
55
+ return _run_processing_job (
56
+ sagemaker_session ,
57
+ cpu_instance_type ,
58
+ sklearn_latest_version ,
59
+ sklearn_latest_py_version ,
60
+ )
61
+
62
+
48
63
def test_training_with_additional_hyperparameters (
49
64
sagemaker_session ,
50
65
sklearn_latest_version ,
@@ -57,7 +72,7 @@ def test_training_with_additional_hyperparameters(
57
72
58
73
sklearn = SKLearn (
59
74
entry_point = script_path ,
60
- role = "SageMakerRole" ,
75
+ role = ROLE ,
61
76
instance_type = cpu_instance_type ,
62
77
framework_version = sklearn_latest_version ,
63
78
py_version = sklearn_latest_py_version ,
@@ -88,7 +103,7 @@ def test_training_with_network_isolation(
88
103
89
104
sklearn = SKLearn (
90
105
entry_point = script_path ,
91
- role = "SageMakerRole" ,
106
+ role = ROLE ,
92
107
instance_type = cpu_instance_type ,
93
108
framework_version = sklearn_latest_version ,
94
109
py_version = sklearn_latest_py_version ,
@@ -145,7 +160,7 @@ def test_deploy_model(
145
160
script_path = os .path .join (DATA_DIR , "sklearn_mnist" , "mnist.py" )
146
161
model = SKLearnModel (
147
162
model_data ,
148
- "SageMakerRole" ,
163
+ ROLE ,
149
164
entry_point = script_path ,
150
165
framework_version = sklearn_latest_version ,
151
166
sagemaker_session = sagemaker_session ,
@@ -198,7 +213,7 @@ def test_failed_training_job(
198
213
199
214
sklearn = SKLearn (
200
215
entry_point = script_path ,
201
- role = "SageMakerRole" ,
216
+ role = ROLE ,
202
217
framework_version = sklearn_latest_version ,
203
218
py_version = sklearn_latest_py_version ,
204
219
instance_count = 1 ,
@@ -215,6 +230,33 @@ def test_failed_training_job(
215
230
sklearn .fit (train_input , job_name = job_name )
216
231
217
232
233
+ def _run_processing_job (
234
+ sagemaker_session , instance_type , sklearn_version , py_version , wait = True
235
+ ):
236
+ with timeout (minutes = TRAINING_DEFAULT_TIMEOUT_MINUTES ):
237
+
238
+ code_path = os .path .join (DATA_DIR , "dummy_code_bundle_with_reqs" )
239
+ entry_point = "main_script.py"
240
+
241
+ processor = SKLearnProcessor (
242
+ framework_version = sklearn_version ,
243
+ py_version = py_version ,
244
+ role = ROLE ,
245
+ instance_count = 1 ,
246
+ instance_type = instance_type ,
247
+ sagemaker_session = sagemaker_session ,
248
+ base_job_name = "test-sklearn" ,
249
+ )
250
+
251
+ processor .run (
252
+ code = entry_point ,
253
+ source_dir = code_path ,
254
+ inputs = [],
255
+ wait = wait ,
256
+ )
257
+ return processor .latest_job .name
258
+
259
+
218
260
def _run_mnist_training_job (
219
261
sagemaker_session , instance_type , sklearn_version , py_version , wait = True
220
262
):
@@ -226,7 +268,7 @@ def _run_mnist_training_job(
226
268
227
269
sklearn = SKLearn (
228
270
entry_point = script_path ,
229
- role = "SageMakerRole" ,
271
+ role = ROLE ,
230
272
framework_version = sklearn_version ,
231
273
py_version = py_version ,
232
274
instance_type = instance_type ,
0 commit comments