37
37
ROLE = "arn:aws:iam::012345678901:role/SageMakerRole"
38
38
ECR_HOSTNAME = "ecr.us-west-2.amazonaws.com"
39
39
CUSTOM_IMAGE_URI = "012345678901.dkr.ecr.us-west-2.amazonaws.com/my-custom-image-uri"
40
+ MOCKED_S3_URI = "s3://mocked_s3_uri_from_upload_data"
40
41
41
42
42
43
@pytest .fixture (autouse = True )
@@ -57,9 +58,7 @@ def sagemaker_session():
57
58
)
58
59
session_mock .default_bucket = Mock (name = "default_bucket" , return_value = BUCKET_NAME )
59
60
60
- session_mock .upload_data = Mock (
61
- name = "upload_data" , return_value = "mocked_s3_uri_from_upload_data"
62
- )
61
+ session_mock .upload_data = Mock (name = "upload_data" , return_value = MOCKED_S3_URI )
63
62
session_mock .download_data = Mock (name = "download_data" )
64
63
session_mock .expand_role .return_value = ROLE
65
64
session_mock .describe_processing_job = MagicMock (
@@ -77,7 +76,7 @@ def test_sklearn_processor_with_required_parameters(
77
76
botocore_resolver .return_value .construct_endpoint .return_value = {"hostname" : ECR_HOSTNAME }
78
77
79
78
processor = SKLearnProcessor (
80
- s3_prefix = "s3://abcd/ef" ,
79
+ s3_prefix = MOCKED_S3_URI ,
81
80
role = ROLE ,
82
81
instance_type = "ml.m4.xlarge" ,
83
82
framework_version = sklearn_version ,
@@ -87,7 +86,7 @@ def test_sklearn_processor_with_required_parameters(
87
86
88
87
processor .run (entry_point = "/local/path/to/processing_code.py" )
89
88
90
- expected_args = _get_expected_args (processor ._current_job_name , "s3://abcd/ef" )
89
+ expected_args = _get_expected_args_modular_code (processor ._current_job_name )
91
90
92
91
sklearn_image_uri = (
93
92
"246618743249.dkr.ecr.us-west-2.amazonaws.com/sagemaker-scikit-learn:{}-cpu-py3"
@@ -619,7 +618,45 @@ def _get_script_processor(sagemaker_session):
619
618
)
620
619
621
620
622
- def _get_expected_args (job_name , code_s3_uri = "mocked_s3_uri_from_upload_data" ):
621
+ def _get_expected_args (job_name , code_s3_uri = MOCKED_S3_URI ):
622
+ return {
623
+ "inputs" : [
624
+ {
625
+ "InputName" : "code" ,
626
+ "AppManaged" : False ,
627
+ "S3Input" : {
628
+ "S3Uri" : code_s3_uri ,
629
+ "LocalPath" : "/opt/ml/processing/input/code" ,
630
+ "S3DataType" : "S3Prefix" ,
631
+ "S3InputMode" : "File" ,
632
+ "S3DataDistributionType" : "FullyReplicated" ,
633
+ "S3CompressionType" : "None" ,
634
+ },
635
+ },
636
+ ],
637
+ "output_config" : {"Outputs" : []},
638
+ "job_name" : job_name ,
639
+ "resources" : {
640
+ "ClusterConfig" : {
641
+ "InstanceType" : "ml.m4.xlarge" ,
642
+ "InstanceCount" : 1 ,
643
+ "VolumeSizeInGB" : 30 ,
644
+ }
645
+ },
646
+ "stopping_condition" : None ,
647
+ "app_specification" : {
648
+ "ImageUri" : CUSTOM_IMAGE_URI ,
649
+ "ContainerEntrypoint" : ["python3" , "/opt/ml/processing/input/code/processing_code.py" ],
650
+ },
651
+ "environment" : None ,
652
+ "network_config" : None ,
653
+ "role_arn" : ROLE ,
654
+ "tags" : None ,
655
+ "experiment_config" : None ,
656
+ }
657
+
658
+
659
+ def _get_expected_args_modular_code (job_name , code_s3_uri = MOCKED_S3_URI ):
623
660
return {
624
661
"inputs" : [
625
662
{
@@ -674,7 +711,7 @@ def _get_data_input():
674
711
"InputName" : "input-1" ,
675
712
"AppManaged" : False ,
676
713
"S3Input" : {
677
- "S3Uri" : "mocked_s3_uri_from_upload_data" ,
714
+ "S3Uri" : MOCKED_S3_URI ,
678
715
"LocalPath" : "/data/" ,
679
716
"S3DataType" : "S3Prefix" ,
680
717
"S3InputMode" : "File" ,
@@ -835,7 +872,7 @@ def _get_expected_args_all_parameters(job_name):
835
872
"InputName" : "code" ,
836
873
"AppManaged" : False ,
837
874
"S3Input" : {
838
- "S3Uri" : "mocked_s3_uri_from_upload_data" ,
875
+ "S3Uri" : MOCKED_S3_URI ,
839
876
"LocalPath" : "/opt/ml/processing/input/code" ,
840
877
"S3DataType" : "S3Prefix" ,
841
878
"S3InputMode" : "File" ,
0 commit comments