@@ -205,14 +205,14 @@ def _normalize_args(
205
205
"""
206
206
self ._current_job_name = self ._generate_current_job_name (job_name = job_name )
207
207
208
- inputs_with_code = self ._include_code_in_inputs (inputs , code )
208
+ inputs_with_code = self ._include_code_in_inputs (inputs , code , kms_key )
209
209
normalized_inputs = self ._normalize_inputs (inputs_with_code , kms_key )
210
210
normalized_outputs = self ._normalize_outputs (outputs )
211
211
self .arguments = arguments
212
212
213
213
return normalized_inputs , normalized_outputs
214
214
215
- def _include_code_in_inputs (self , inputs , _code ):
215
+ def _include_code_in_inputs (self , inputs , _code , kms_key = None ):
216
216
"""A no op in the base class to include code in the processing job inputs.
217
217
218
218
Args:
@@ -475,7 +475,7 @@ def run(
475
475
if wait :
476
476
self .latest_job .wait (logs = logs )
477
477
478
- def _include_code_in_inputs (self , inputs , code ):
478
+ def _include_code_in_inputs (self , inputs , code , kms_key = None ):
479
479
"""Converts code to appropriate input and includes in input list.
480
480
481
481
Side effects include:
@@ -493,7 +493,7 @@ def _include_code_in_inputs(self, inputs, code):
493
493
list[:class:`~sagemaker.processing.ProcessingInput`]: inputs together with the
494
494
code as `ProcessingInput`.
495
495
"""
496
- user_code_s3_uri = self ._handle_user_code_url (code )
496
+ user_code_s3_uri = self ._handle_user_code_url (code , kms_key )
497
497
user_script_name = self ._get_user_code_name (code )
498
498
499
499
inputs_with_code = self ._convert_code_and_add_to_inputs (inputs , user_code_s3_uri )
@@ -515,7 +515,7 @@ def _get_user_code_name(self, code):
515
515
code_url = urlparse (code )
516
516
return os .path .basename (code_url .path )
517
517
518
- def _handle_user_code_url (self , code ):
518
+ def _handle_user_code_url (self , code , kms_key = None ):
519
519
"""Gets the S3 URL containing the user's code.
520
520
521
521
Inspects the scheme the customer passed in ("s3://" for code in S3, "file://" or nothing
@@ -551,7 +551,7 @@ def _handle_user_code_url(self, code):
551
551
code
552
552
)
553
553
)
554
- user_code_s3_uri = self ._upload_code (code_path )
554
+ user_code_s3_uri = self ._upload_code (code_path , kms_key )
555
555
else :
556
556
raise ValueError (
557
557
"code {} url scheme {} is not recognized. Please pass a file path or S3 url" .format (
@@ -560,7 +560,7 @@ def _handle_user_code_url(self, code):
560
560
)
561
561
return user_code_s3_uri
562
562
563
- def _upload_code (self , code ):
563
+ def _upload_code (self , code , kms_key = None ):
564
564
"""Uploads a code file or directory specified as a string
565
565
and returns the S3 URI.
566
566
@@ -579,7 +579,7 @@ def _upload_code(self, code):
579
579
self ._CODE_CONTAINER_INPUT_NAME ,
580
580
)
581
581
return s3 .S3Uploader .upload (
582
- local_path = code , desired_s3_uri = desired_s3_uri , sagemaker_session = self .sagemaker_session
582
+ local_path = code , desired_s3_uri = desired_s3_uri , sagemaker_session = self .sagemaker_session , kms_key = kms_key
583
583
)
584
584
585
585
def _convert_code_and_add_to_inputs (self , inputs , s3_uri ):
0 commit comments