|
14 | 14 |
|
15 | 15 | import os
|
16 | 16 |
|
17 |
| -import boto3 |
18 | 17 | import pytest
|
19 |
| -from botocore.config import Config |
20 |
| -from sagemaker import Session |
21 | 18 | from sagemaker.fw_registry import default_framework_uri
|
22 | 19 |
|
23 | 20 | from sagemaker.processing import ProcessingInput, ProcessingOutput, ScriptProcessor, Processor
|
|
26 | 23 | from tests.integ.kms_utils import get_or_create_kms_key
|
27 | 24 |
|
28 | 25 | ROLE = "SageMakerRole"
|
29 |
| -DEFAULT_REGION = "us-west-2" |
30 |
| -CUSTOM_BUCKET_PATH = "sagemaker-custom-bucket" |
31 |
| - |
32 |
| - |
33 |
| -@pytest.fixture(scope="module") |
34 |
| -def sagemaker_session_with_custom_bucket( |
35 |
| - boto_config, sagemaker_client_config, sagemaker_runtime_config |
36 |
| -): |
37 |
| - boto_session = ( |
38 |
| - boto3.Session(**boto_config) if boto_config else boto3.Session(region_name=DEFAULT_REGION) |
39 |
| - ) |
40 |
| - sagemaker_client_config.setdefault("config", Config(retries=dict(max_attempts=10))) |
41 |
| - sagemaker_client = ( |
42 |
| - boto_session.client("sagemaker", **sagemaker_client_config) |
43 |
| - if sagemaker_client_config |
44 |
| - else None |
45 |
| - ) |
46 |
| - runtime_client = ( |
47 |
| - boto_session.client("sagemaker-runtime", **sagemaker_runtime_config) |
48 |
| - if sagemaker_runtime_config |
49 |
| - else None |
50 |
| - ) |
51 |
| - |
52 |
| - return Session( |
53 |
| - boto_session=boto_session, |
54 |
| - sagemaker_client=sagemaker_client, |
55 |
| - sagemaker_runtime_client=runtime_client, |
56 |
| - default_bucket=CUSTOM_BUCKET_PATH, |
57 |
| - ) |
58 | 26 |
|
59 | 27 |
|
60 | 28 | @pytest.fixture(scope="module")
|
@@ -202,90 +170,6 @@ def test_sklearn_with_customizations(
|
202 | 170 | assert job_description["StoppingCondition"] == {"MaxRuntimeInSeconds": 3600}
|
203 | 171 |
|
204 | 172 |
|
205 |
| -def test_sklearn_with_custom_default_bucket( |
206 |
| - sagemaker_session_with_custom_bucket, |
207 |
| - image_uri, |
208 |
| - sklearn_full_version, |
209 |
| - cpu_instance_type, |
210 |
| - output_kms_key, |
211 |
| -): |
212 |
| - |
213 |
| - input_file_path = os.path.join(DATA_DIR, "dummy_input.txt") |
214 |
| - |
215 |
| - sklearn_processor = SKLearnProcessor( |
216 |
| - framework_version=sklearn_full_version, |
217 |
| - role=ROLE, |
218 |
| - command=["python3"], |
219 |
| - instance_type=cpu_instance_type, |
220 |
| - instance_count=1, |
221 |
| - volume_size_in_gb=100, |
222 |
| - volume_kms_key=None, |
223 |
| - output_kms_key=output_kms_key, |
224 |
| - max_runtime_in_seconds=3600, |
225 |
| - base_job_name="test-sklearn-with-customizations", |
226 |
| - env={"DUMMY_ENVIRONMENT_VARIABLE": "dummy-value"}, |
227 |
| - tags=[{"Key": "dummy-tag", "Value": "dummy-tag-value"}], |
228 |
| - sagemaker_session=sagemaker_session_with_custom_bucket, |
229 |
| - ) |
230 |
| - |
231 |
| - sklearn_processor.run( |
232 |
| - code=os.path.join(DATA_DIR, "dummy_script.py"), |
233 |
| - inputs=[ |
234 |
| - ProcessingInput( |
235 |
| - source=input_file_path, |
236 |
| - destination="/opt/ml/processing/input/container/path/", |
237 |
| - input_name="dummy_input", |
238 |
| - s3_data_type="S3Prefix", |
239 |
| - s3_input_mode="File", |
240 |
| - s3_data_distribution_type="FullyReplicated", |
241 |
| - s3_compression_type="None", |
242 |
| - ) |
243 |
| - ], |
244 |
| - outputs=[ |
245 |
| - ProcessingOutput( |
246 |
| - source="/opt/ml/processing/output/container/path/", |
247 |
| - output_name="dummy_output", |
248 |
| - s3_upload_mode="EndOfJob", |
249 |
| - ) |
250 |
| - ], |
251 |
| - arguments=["-v"], |
252 |
| - wait=True, |
253 |
| - logs=True, |
254 |
| - ) |
255 |
| - |
256 |
| - job_description = sklearn_processor.latest_job.describe() |
257 |
| - |
258 |
| - assert job_description["ProcessingInputs"][0]["InputName"] == "dummy_input" |
259 |
| - assert CUSTOM_BUCKET_PATH in job_description["ProcessingInputs"][0]["S3Input"]["S3Uri"] |
260 |
| - |
261 |
| - assert job_description["ProcessingInputs"][1]["InputName"] == "code" |
262 |
| - assert CUSTOM_BUCKET_PATH in job_description["ProcessingInputs"][1]["S3Input"]["S3Uri"] |
263 |
| - |
264 |
| - assert job_description["ProcessingJobName"].startswith("test-sklearn-with-customizations") |
265 |
| - |
266 |
| - assert job_description["ProcessingJobStatus"] == "Completed" |
267 |
| - |
268 |
| - assert job_description["ProcessingOutputConfig"]["KmsKeyId"] == output_kms_key |
269 |
| - assert job_description["ProcessingOutputConfig"]["Outputs"][0]["OutputName"] == "dummy_output" |
270 |
| - |
271 |
| - assert job_description["ProcessingResources"] == { |
272 |
| - "ClusterConfig": {"InstanceCount": 1, "InstanceType": "ml.m4.xlarge", "VolumeSizeInGB": 100} |
273 |
| - } |
274 |
| - |
275 |
| - assert job_description["AppSpecification"]["ContainerArguments"] == ["-v"] |
276 |
| - assert job_description["AppSpecification"]["ContainerEntrypoint"] == [ |
277 |
| - "python3", |
278 |
| - "/opt/ml/processing/input/code/dummy_script.py", |
279 |
| - ] |
280 |
| - assert job_description["AppSpecification"]["ImageUri"] == image_uri |
281 |
| - |
282 |
| - assert job_description["Environment"] == {"DUMMY_ENVIRONMENT_VARIABLE": "dummy-value"} |
283 |
| - |
284 |
| - assert ROLE in job_description["RoleArn"] |
285 |
| - |
286 |
| - assert job_description["StoppingCondition"] == {"MaxRuntimeInSeconds": 3600} |
287 |
| - |
288 |
| - |
289 | 173 | def test_sklearn_with_no_inputs_or_outputs(
|
290 | 174 | sagemaker_session, image_uri, sklearn_full_version, cpu_instance_type
|
291 | 175 | ):
|
|
0 commit comments