31
31
from sagemaker .sklearn .processing import SKLearnProcessor
32
32
from sagemaker .network import NetworkConfig
33
33
from sagemaker .processing import FeatureStoreOutput
34
+ from sagemaker .fw_utils import UploadedCode
34
35
35
36
BUCKET_NAME = "mybucket"
36
37
REGION = "us-west-2"
@@ -67,6 +68,14 @@ def sagemaker_session():
67
68
return session_mock
68
69
69
70
71
+ @pytest .fixture ()
72
+ def uploaded_code (
73
+ s3_prefix = "s3://mocked_s3_uri_from_upload_data/my_job_name/source/sourcedir.tar.gz" ,
74
+ script_name = "processing_code.py" ,
75
+ ):
76
+ return UploadedCode (s3_prefix = s3_prefix , script_name = script_name )
77
+
78
+
70
79
@patch ("sagemaker.utils._botocore_resolver" )
71
80
@patch ("os.path.exists" , return_value = True )
72
81
@patch ("os.path.isfile" , return_value = True )
@@ -99,7 +108,7 @@ def test_sklearn_processor_with_required_parameters(
99
108
@patch ("os.path.exists" , return_value = True )
100
109
@patch ("os.path.isfile" , return_value = True )
101
110
def test_sklearn_with_all_parameters (
102
- exists_mock , isfile_mock , botocore_resolver , sklearn_version , sagemaker_session
111
+ exists_mock , isfile_mock , botocore_resolver , sklearn_version , sagemaker_session , uploaded_code
103
112
):
104
113
botocore_resolver .return_value .construct_endpoint .return_value = {"hostname" : ECR_HOSTNAME }
105
114
@@ -126,17 +135,19 @@ def test_sklearn_with_all_parameters(
126
135
sagemaker_session = sagemaker_session ,
127
136
)
128
137
129
- processor .run (
130
- entry_point = "/local/path/to/processing_code.py" ,
131
- # TODO: Add a source_dir in a way that the processor can validate it (fictional won't do)
132
- inputs = _get_data_inputs_all_parameters (),
133
- outputs = _get_data_outputs_all_parameters (),
134
- arguments = ["--drop-columns" , "'SelfEmployed'" ],
135
- wait = True ,
136
- logs = False ,
137
- job_name = "my_job_name" ,
138
- experiment_config = {"ExperimentName" : "AnExperiment" },
139
- )
138
+ with patch ("sagemaker.estimator.tar_and_upload_dir" , return_value = uploaded_code ):
139
+ processor .run (
140
+ entry_point = "processing_code.py" ,
141
+ source_dir = "/local/path/to/source_dir" ,
142
+ dependencies = ["/local/path/to/dep_01" ],
143
+ inputs = _get_data_inputs_all_parameters (),
144
+ outputs = _get_data_outputs_all_parameters (),
145
+ arguments = ["--drop-columns" , "'SelfEmployed'" ],
146
+ wait = True ,
147
+ logs = False ,
148
+ job_name = "my_job_name" ,
149
+ experiment_config = {"ExperimentName" : "AnExperiment" },
150
+ )
140
151
141
152
expected_args = _get_expected_args_all_parameters_modular_code (processor ._current_job_name )
142
153
sklearn_image_uri = (
0 commit comments