21
21
from sagemaker .sklearn import SKLearn
22
22
from sagemaker .sklearn import SKLearnModel
23
23
from sagemaker .utils import sagemaker_timestamp , unique_name_from_base
24
- from tests .integ import DATA_DIR , PYTHON_VERSION , TRAINING_DEFAULT_TIMEOUT_MINUTES
24
+ from tests .integ import DATA_DIR , TRAINING_DEFAULT_TIMEOUT_MINUTES
25
25
from tests .integ .timeout import timeout , timeout_and_delete_endpoint_by_name
26
26
27
27
30
30
reason = "This test has always failed, but the failure was masked by a bug. "
31
31
"This test should be fixed. Details in https://github.com/aws/sagemaker-python-sdk/pull/968"
32
32
)
33
- def sklearn_training_job (sagemaker_session , sklearn_full_version , cpu_instance_type ):
34
- return _run_mnist_training_job (sagemaker_session , cpu_instance_type , sklearn_full_version )
33
+ def sklearn_training_job (
34
+ sagemaker_session , sklearn_full_version , sklearn_full_py_version , cpu_instance_type
35
+ ):
36
+ return _run_mnist_training_job (
37
+ sagemaker_session , cpu_instance_type , sklearn_full_version , sklearn_full_py_version
38
+ )
35
39
sagemaker_session .boto_region_name
36
40
37
41
38
- @pytest .mark .skipif (PYTHON_VERSION != "py3" , reason = "Scikit-learn image supports only Python 3." )
39
42
def test_training_with_additional_hyperparameters (
40
- sagemaker_session , sklearn_full_version , cpu_instance_type
43
+ sagemaker_session , sklearn_full_version , sklearn_full_py_version , cpu_instance_type
41
44
):
42
45
with timeout (minutes = TRAINING_DEFAULT_TIMEOUT_MINUTES ):
43
46
script_path = os .path .join (DATA_DIR , "sklearn_mnist" , "mnist.py" )
@@ -48,7 +51,7 @@ def test_training_with_additional_hyperparameters(
48
51
role = "SageMakerRole" ,
49
52
train_instance_type = cpu_instance_type ,
50
53
framework_version = sklearn_full_version ,
51
- py_version = PYTHON_VERSION ,
54
+ py_version = sklearn_full_py_version ,
52
55
sagemaker_session = sagemaker_session ,
53
56
hyperparameters = {"epochs" : 1 },
54
57
)
@@ -65,9 +68,8 @@ def test_training_with_additional_hyperparameters(
65
68
return sklearn .latest_training_job .name
66
69
67
70
68
- @pytest .mark .skipif (PYTHON_VERSION != "py3" , reason = "Scikit-learn image supports only Python 3." )
69
71
def test_training_with_network_isolation (
70
- sagemaker_session , sklearn_full_version , cpu_instance_type
72
+ sagemaker_session , sklearn_full_version , sklearn_full_py_version , cpu_instance_type
71
73
):
72
74
with timeout (minutes = TRAINING_DEFAULT_TIMEOUT_MINUTES ):
73
75
script_path = os .path .join (DATA_DIR , "sklearn_mnist" , "mnist.py" )
@@ -78,7 +80,7 @@ def test_training_with_network_isolation(
78
80
role = "SageMakerRole" ,
79
81
train_instance_type = cpu_instance_type ,
80
82
framework_version = sklearn_full_version ,
81
- py_version = PYTHON_VERSION ,
83
+ py_version = sklearn_full_py_version ,
82
84
sagemaker_session = sagemaker_session ,
83
85
hyperparameters = {"epochs" : 1 },
84
86
enable_network_isolation = True ,
@@ -101,7 +103,6 @@ def test_training_with_network_isolation(
101
103
102
104
@pytest .mark .canary_quick
103
105
@pytest .mark .regional_testing
104
- @pytest .mark .skipif (PYTHON_VERSION != "py3" , reason = "Scikit-learn image supports only python 3." )
105
106
@pytest .mark .skip (
106
107
reason = "This test has always failed, but the failure was masked by a bug. "
107
108
"This test should be fixed. Details in https://github.com/aws/sagemaker-python-sdk/pull/968"
@@ -115,13 +116,16 @@ def test_attach_deploy(sklearn_training_job, sagemaker_session, cpu_instance_typ
115
116
_predict_and_assert (predictor )
116
117
117
118
118
- @pytest .mark .skipif (PYTHON_VERSION != "py3" , reason = "Scikit-learn image supports only python 3." )
119
119
@pytest .mark .skip (
120
120
reason = "This test has always failed, but the failure was masked by a bug. "
121
121
"This test should be fixed. Details in https://github.com/aws/sagemaker-python-sdk/pull/968"
122
122
)
123
123
def test_deploy_model (
124
- sklearn_training_job , sagemaker_session , cpu_instance_type , sklearn_full_version
124
+ sklearn_training_job ,
125
+ sagemaker_session ,
126
+ cpu_instance_type ,
127
+ sklearn_full_version ,
128
+ sklearn_full_py_version ,
125
129
):
126
130
endpoint_name = "test-sklearn-deploy-model-{}" .format (sagemaker_timestamp ())
127
131
with timeout_and_delete_endpoint_by_name (endpoint_name , sagemaker_session ):
@@ -141,12 +145,13 @@ def test_deploy_model(
141
145
_predict_and_assert (predictor )
142
146
143
147
144
- @pytest .mark .skipif (PYTHON_VERSION != "py3" , reason = "Scikit-learn image supports only python 3." )
145
148
@pytest .mark .skip (
146
149
reason = "This test has always failed, but the failure was masked by a bug. "
147
150
"This test should be fixed. Details in https://github.com/aws/sagemaker-python-sdk/pull/968"
148
151
)
149
- def test_async_fit (sagemaker_session , cpu_instance_type , sklearn_full_version ):
152
+ def test_async_fit (
153
+ sagemaker_session , cpu_instance_type , sklearn_full_version , sklearn_full_py_version
154
+ ):
150
155
endpoint_name = "test-sklearn-attach-deploy-{}" .format (sagemaker_timestamp ())
151
156
152
157
with timeout (minutes = 5 ):
@@ -169,8 +174,9 @@ def test_async_fit(sagemaker_session, cpu_instance_type, sklearn_full_version):
169
174
_predict_and_assert (predictor )
170
175
171
176
172
- @pytest .mark .skipif (PYTHON_VERSION != "py3" , reason = "Scikit-learn image supports only python 3." )
173
- def test_failed_training_job (sagemaker_session , sklearn_full_version , cpu_instance_type ):
177
+ def test_failed_training_job (
178
+ sagemaker_session , sklearn_full_version , sklearn_full_py_version , cpu_instance_type
179
+ ):
174
180
with timeout (minutes = TRAINING_DEFAULT_TIMEOUT_MINUTES ):
175
181
script_path = os .path .join (DATA_DIR , "sklearn_mnist" , "failure_script.py" )
176
182
data_path = os .path .join (DATA_DIR , "sklearn_mnist" )
@@ -179,7 +185,7 @@ def test_failed_training_job(sagemaker_session, sklearn_full_version, cpu_instan
179
185
entry_point = script_path ,
180
186
role = "SageMakerRole" ,
181
187
framework_version = sklearn_full_version ,
182
- py_version = PYTHON_VERSION ,
188
+ py_version = sklearn_full_py_version ,
183
189
train_instance_count = 1 ,
184
190
train_instance_type = cpu_instance_type ,
185
191
sagemaker_session = sagemaker_session ,
@@ -194,7 +200,9 @@ def test_failed_training_job(sagemaker_session, sklearn_full_version, cpu_instan
194
200
sklearn .fit (train_input , job_name = job_name )
195
201
196
202
197
- def _run_mnist_training_job (sagemaker_session , instance_type , sklearn_full_version , wait = True ):
203
+ def _run_mnist_training_job (
204
+ sagemaker_session , instance_type , sklearn_version , py_version , wait = True
205
+ ):
198
206
with timeout (minutes = TRAINING_DEFAULT_TIMEOUT_MINUTES ):
199
207
200
208
script_path = os .path .join (DATA_DIR , "sklearn_mnist" , "mnist.py" )
@@ -204,8 +212,8 @@ def _run_mnist_training_job(sagemaker_session, instance_type, sklearn_full_versi
204
212
sklearn = SKLearn (
205
213
entry_point = script_path ,
206
214
role = "SageMakerRole" ,
207
- framework_version = sklearn_full_version ,
208
- py_version = PYTHON_VERSION ,
215
+ framework_version = sklearn_version ,
216
+ py_version = py_version ,
209
217
train_instance_type = instance_type ,
210
218
sagemaker_session = sagemaker_session ,
211
219
hyperparameters = {"epochs" : 1 },
0 commit comments