@@ -99,9 +99,7 @@ def tar_and_upload_dir(session, bucket, s3_key_prefix, script, *args, **kwargs):
99
99
def test_sklearn_processor_with_required_parameters (
100
100
exists_mock , isfile_mock , botocore_resolver , sagemaker_session , sklearn_version
101
101
):
102
- botocore_resolver .return_value .construct_endpoint .return_value = {
103
- "hostname" : ECR_HOSTNAME
104
- }
102
+ botocore_resolver .return_value .construct_endpoint .return_value = {"hostname" : ECR_HOSTNAME }
105
103
processor = SKLearnProcessor (
106
104
role = ROLE ,
107
105
instance_type = "ml.m4.xlarge" ,
@@ -127,9 +125,7 @@ def test_sklearn_processor_with_required_parameters(
127
125
def test_sklearn_with_all_parameters (
128
126
exists_mock , isfile_mock , botocore_resolver , sklearn_version , sagemaker_session
129
127
):
130
- botocore_resolver .return_value .construct_endpoint .return_value = {
131
- "hostname" : ECR_HOSTNAME
132
- }
128
+ botocore_resolver .return_value .construct_endpoint .return_value = {"hostname" : ECR_HOSTNAME }
133
129
134
130
processor = SKLearnProcessor (
135
131
role = ROLE ,
@@ -196,9 +192,7 @@ def test_local_mode_disables_local_code_by_default(localsession_mock):
196
192
def test_sklearn_with_all_parameters_via_run_args (
197
193
exists_mock , isfile_mock , botocore_resolver , sklearn_version , sagemaker_session
198
194
):
199
- botocore_resolver .return_value .construct_endpoint .return_value = {
200
- "hostname" : ECR_HOSTNAME
201
- }
195
+ botocore_resolver .return_value .construct_endpoint .return_value = {"hostname" : ECR_HOSTNAME }
202
196
203
197
processor = SKLearnProcessor (
204
198
role = ROLE ,
@@ -257,9 +251,7 @@ def test_sklearn_with_all_parameters_via_run_args(
257
251
def test_sklearn_with_all_parameters_via_run_args_called_twice (
258
252
exists_mock , isfile_mock , botocore_resolver , sklearn_version , sagemaker_session
259
253
):
260
- botocore_resolver .return_value .construct_endpoint .return_value = {
261
- "hostname" : ECR_HOSTNAME
262
- }
254
+ botocore_resolver .return_value .construct_endpoint .return_value = {"hostname" : ECR_HOSTNAME }
263
255
264
256
processor = SKLearnProcessor (
265
257
role = ROLE ,
@@ -324,9 +316,7 @@ def test_normalize_args_prepares_framework_processor(
324
316
sagemaker_session ,
325
317
mock_fw_tar_and_upload_dir ,
326
318
):
327
- botocore_resolver .return_value .construct_endpoint .return_value = {
328
- "hostname" : ECR_HOSTNAME
329
- }
319
+ botocore_resolver .return_value .construct_endpoint .return_value = {"hostname" : ECR_HOSTNAME }
330
320
331
321
processor = PyTorchProcessor (
332
322
role = ROLE ,
@@ -361,9 +351,7 @@ def test_normalize_args_prepares_framework_processor(
361
351
assert code_inputs [0 ].source == "/" .join (
362
352
("s3:/" , BUCKET_NAME , process_args ["job_name" ], "source/sourcedir.tar.gz" )
363
353
)
364
- entrypoint_inputs = list (
365
- filter (lambda i : i .input_name == "entrypoint" , normalized_inputs )
366
- )
354
+ entrypoint_inputs = list (filter (lambda i : i .input_name == "entrypoint" , normalized_inputs ))
367
355
assert len (entrypoint_inputs ) == 1
368
356
369
357
# Outputs should be as per raw:
@@ -390,9 +378,7 @@ def test_pytorch_processor_with_all_parameters(
390
378
pytorch_training_py_version ,
391
379
mock_fw_tar_and_upload_dir ,
392
380
):
393
- botocore_resolver .return_value .construct_endpoint .return_value = {
394
- "hostname" : ECR_HOSTNAME
395
- }
381
+ botocore_resolver .return_value .construct_endpoint .return_value = {"hostname" : ECR_HOSTNAME }
396
382
397
383
processor = PyTorchProcessor (
398
384
role = ROLE ,
@@ -437,12 +423,16 @@ def test_pytorch_processor_with_all_parameters(
437
423
)
438
424
439
425
if version .parse (pytorch_training_version ) < version .parse ("1.2" ):
440
- pytorch_image_uri = "520713654638.dkr.ecr.us-west-2.amazonaws.com/sagemaker-pytorch:{}-cpu-{}" .format (
441
- pytorch_training_version , pytorch_training_py_version
426
+ pytorch_image_uri = (
427
+ "520713654638.dkr.ecr.us-west-2.amazonaws.com/sagemaker-pytorch:{}-cpu-{}" .format (
428
+ pytorch_training_version , pytorch_training_py_version
429
+ )
442
430
)
443
431
else :
444
- pytorch_image_uri = "763104351884.dkr.ecr.us-west-2.amazonaws.com/pytorch-training:{}-cpu-{}" .format (
445
- pytorch_training_version , pytorch_training_py_version
432
+ pytorch_image_uri = (
433
+ "763104351884.dkr.ecr.us-west-2.amazonaws.com/pytorch-training:{}-cpu-{}" .format (
434
+ pytorch_training_version , pytorch_training_py_version
435
+ )
446
436
)
447
437
448
438
expected_args ["app_specification" ]["ImageUri" ] = pytorch_image_uri
@@ -461,9 +451,7 @@ def test_xgboost_processor_with_source_dir_bundle(
461
451
xgboost_framework_version ,
462
452
mock_fw_tar_and_upload_dir ,
463
453
):
464
- botocore_resolver .return_value .construct_endpoint .return_value = {
465
- "hostname" : ECR_HOSTNAME
466
- }
454
+ botocore_resolver .return_value .construct_endpoint .return_value = {"hostname" : ECR_HOSTNAME }
467
455
468
456
processor = XGBoostProcessor (
469
457
role = ROLE ,
@@ -506,9 +494,7 @@ def test_mxnet_processor_via_run_args(
506
494
mxnet_training_py_version ,
507
495
mock_fw_tar_and_upload_dir ,
508
496
):
509
- botocore_resolver .return_value .construct_endpoint .return_value = {
510
- "hostname" : ECR_HOSTNAME
511
- }
497
+ botocore_resolver .return_value .construct_endpoint .return_value = {"hostname" : ECR_HOSTNAME }
512
498
513
499
processor = MXNetProcessor (
514
500
role = ROLE ,
@@ -591,9 +577,7 @@ def test_tensorflow_processor_with_required_parameters(
591
577
mock_fw_tar_and_upload_dir ,
592
578
):
593
579
594
- botocore_resolver .return_value .construct_endpoint .return_value = {
595
- "hostname" : ECR_HOSTNAME
596
- }
580
+ botocore_resolver .return_value .construct_endpoint .return_value = {"hostname" : ECR_HOSTNAME }
597
581
598
582
if version .parse (tensorflow_training_version ) <= version .parse ("1.13.1" ):
599
583
@@ -637,19 +621,15 @@ def test_tensorflow_processor_with_required_parameters(
637
621
638
622
639
623
@patch ("os.path.exists" , return_value = False )
640
- def test_script_processor_errors_with_nonexistent_local_code (
641
- exists_mock , sagemaker_session
642
- ):
624
+ def test_script_processor_errors_with_nonexistent_local_code (exists_mock , sagemaker_session ):
643
625
processor = _get_script_processor (sagemaker_session )
644
626
with pytest .raises (ValueError ):
645
627
processor .run (code = "/local/path/to/processing_code.py" )
646
628
647
629
648
630
@patch ("os.path.exists" , return_value = True )
649
631
@patch ("os.path.isfile" , return_value = False )
650
- def test_script_processor_errors_with_code_directory (
651
- exists_mock , isfile_mock , sagemaker_session
652
- ):
632
+ def test_script_processor_errors_with_code_directory (exists_mock , isfile_mock , sagemaker_session ):
653
633
processor = _get_script_processor (sagemaker_session )
654
634
with pytest .raises (ValueError ):
655
635
processor .run (code = "/local/path/to/code" )
@@ -715,16 +695,12 @@ def test_script_processor_works_with_file_code_url_scheme(
715
695
716
696
@patch ("os.path.exists" , return_value = True )
717
697
@patch ("os.path.isfile" , return_value = True )
718
- def test_script_processor_works_with_s3_code_url (
719
- exists_mock , isfile_mock , sagemaker_session
720
- ):
698
+ def test_script_processor_works_with_s3_code_url (exists_mock , isfile_mock , sagemaker_session ):
721
699
processor = _get_script_processor (sagemaker_session )
722
700
processor .run (code = "s3://bucket/path/to/processing_code.py" )
723
701
724
702
expected_args = _get_expected_args (processor ._current_job_name )
725
- expected_args ["inputs" ][0 ]["S3Input" ][
726
- "S3Uri"
727
- ] = "s3://bucket/path/to/processing_code.py"
703
+ expected_args ["inputs" ][0 ]["S3Input" ]["S3Uri" ] = "s3://bucket/path/to/processing_code.py"
728
704
sagemaker_session .process .assert_called_with (** expected_args )
729
705
730
706
@@ -735,9 +711,7 @@ def test_script_processor_with_one_input(exists_mock, isfile_mock, sagemaker_ses
735
711
processor .run (
736
712
code = "/local/path/to/processing_code.py" ,
737
713
inputs = [
738
- ProcessingInput (
739
- source = "/local/path/to/my/dataset/census.csv" , destination = "/data/"
740
- )
714
+ ProcessingInput (source = "/local/path/to/my/dataset/census.csv" , destination = "/data/" )
741
715
],
742
716
)
743
717
@@ -771,9 +745,7 @@ def test_script_processor_with_one_input(exists_mock, isfile_mock, sagemaker_ses
771
745
772
746
@patch ("os.path.exists" , return_value = True )
773
747
@patch ("os.path.isfile" , return_value = True )
774
- def test_script_processor_with_required_parameters (
775
- exists_mock , isfile_mock , sagemaker_session
776
- ):
748
+ def test_script_processor_with_required_parameters (exists_mock , isfile_mock , sagemaker_session ):
777
749
processor = _get_script_processor (sagemaker_session )
778
750
779
751
processor .run (code = "/local/path/to/processing_code.py" )
@@ -784,9 +756,7 @@ def test_script_processor_with_required_parameters(
784
756
785
757
@patch ("os.path.exists" , return_value = True )
786
758
@patch ("os.path.isfile" , return_value = True )
787
- def test_script_processor_with_all_parameters (
788
- exists_mock , isfile_mock , sagemaker_session
789
- ):
759
+ def test_script_processor_with_all_parameters (exists_mock , isfile_mock , sagemaker_session ):
790
760
processor = ScriptProcessor (
791
761
role = ROLE ,
792
762
image_uri = CUSTOM_IMAGE_URI ,
@@ -994,18 +964,14 @@ def test_processing_job_from_processing_arn(sagemaker_session):
994
964
995
965
assert isinstance (processing_job , ProcessingJob )
996
966
assert [
997
- processing_input ._to_request_dict ()
998
- for processing_input in processing_job .inputs
967
+ processing_input ._to_request_dict () for processing_input in processing_job .inputs
999
968
] == _get_describe_response_inputs_and_ouputs ()["ProcessingInputs" ]
1000
969
assert [
1001
- processing_output ._to_request_dict ()
1002
- for processing_output in processing_job .outputs
970
+ processing_output ._to_request_dict () for processing_output in processing_job .outputs
1003
971
] == _get_describe_response_inputs_and_ouputs ()["ProcessingOutputConfig" ]["Outputs" ]
1004
972
assert (
1005
973
processing_job .output_kms_key
1006
- == _get_describe_response_inputs_and_ouputs ()["ProcessingOutputConfig" ][
1007
- "KmsKeyId"
1008
- ]
974
+ == _get_describe_response_inputs_and_ouputs ()["ProcessingOutputConfig" ]["KmsKeyId" ]
1009
975
)
1010
976
1011
977
@@ -1215,9 +1181,7 @@ def _get_data_outputs_all_parameters():
1215
1181
ProcessingOutput (
1216
1182
output_name = "feature_store_output" ,
1217
1183
app_managed = True ,
1218
- feature_store_output = FeatureStoreOutput (
1219
- feature_group_name = "FeatureGroupName"
1220
- ),
1184
+ feature_store_output = FeatureStoreOutput (feature_group_name = "FeatureGroupName" ),
1221
1185
),
1222
1186
]
1223
1187
@@ -1514,7 +1478,5 @@ def _get_expected_args_all_parameters(job_name, code_location=None):
1514
1478
def _get_describe_response_inputs_and_ouputs ():
1515
1479
return {
1516
1480
"ProcessingInputs" : _get_expected_args_all_parameters (None )["inputs" ],
1517
- "ProcessingOutputConfig" : _get_expected_args_all_parameters (None )[
1518
- "output_config"
1519
- ],
1481
+ "ProcessingOutputConfig" : _get_expected_args_all_parameters (None )["output_config" ],
1520
1482
}
0 commit comments