Skip to content

Commit 8727aa7

Browse files
author
Chuyang Deng
committed
move kms_key to end of arg list
1 parent 01c0490 commit 8727aa7

File tree

3 files changed

+27
-13
lines changed

3 files changed

+27
-13
lines changed

src/sagemaker/processing.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -113,22 +113,20 @@ def __init__(
113113
def run(
114114
self,
115115
inputs=None,
116-
kms_key=None,
117116
outputs=None,
118117
arguments=None,
119118
wait=True,
120119
logs=True,
121120
job_name=None,
122121
experiment_config=None,
122+
kms_key=None,
123123
):
124124
"""Runs a processing job.
125125
126126
Args:
127127
inputs (list[:class:`~sagemaker.processing.ProcessingInput`]): Input files for
128128
the processing job. These must be provided as
129129
:class:`~sagemaker.processing.ProcessingInput` objects (default: None).
130-
kms_key (str): The ARN of the KMS key that is used to encrypt the
131-
user code file (default: None).
132130
outputs (list[:class:`~sagemaker.processing.ProcessingOutput`]): Outputs for
133131
the processing job. These can be specified as either path strings or
134132
:class:`~sagemaker.processing.ProcessingOutput` objects (default: None).
@@ -142,6 +140,8 @@ def run(
142140
experiment_config (dict[str, str]): Experiment management configuration.
143141
Dictionary contains three optional keys:
144142
'ExperimentName', 'TrialName', and 'TrialComponentDisplayName'.
143+
kms_key (str): The ARN of the KMS key that is used to encrypt the
144+
user code file (default: None).
145145
146146
Raises:
147147
ValueError: if ``logs`` is True but ``wait`` is False.
@@ -175,7 +175,13 @@ def _extend_processing_args(self, inputs, outputs, **kwargs): # pylint: disable
175175
return inputs, outputs
176176

177177
def _normalize_args(
178-
self, job_name=None, arguments=None, inputs=None, kms_key=None, outputs=None, code=None
178+
self,
179+
job_name=None,
180+
arguments=None,
181+
inputs=None,
182+
outputs=None,
183+
code=None,
184+
kms_key=None,
179185
):
180186
"""Normalizes the arguments so that they can be passed to the job run
181187
@@ -417,13 +423,13 @@ def run(
417423
self,
418424
code,
419425
inputs=None,
420-
kms_key=None,
421426
outputs=None,
422427
arguments=None,
423428
wait=True,
424429
logs=True,
425430
job_name=None,
426431
experiment_config=None,
432+
kms_key=None,
427433
):
428434
"""Runs a processing job.
429435
@@ -433,8 +439,6 @@ def run(
433439
inputs (list[:class:`~sagemaker.processing.ProcessingInput`]): Input files for
434440
the processing job. These must be provided as
435441
:class:`~sagemaker.processing.ProcessingInput` objects (default: None).
436-
kms_key (str): The ARN of the KMS key that is used to encrypt the
437-
user code file (default: None).
438442
outputs (list[:class:`~sagemaker.processing.ProcessingOutput`]): Outputs for
439443
the processing job. These can be specified as either path strings or
440444
:class:`~sagemaker.processing.ProcessingOutput` objects (default: None).
@@ -448,14 +452,16 @@ def run(
448452
experiment_config (dict[str, str]): Experiment management configuration.
449453
Dictionary contains three optional keys:
450454
'ExperimentName', 'TrialName', and 'TrialComponentDisplayName'.
455+
kms_key (str): The ARN of the KMS key that is used to encrypt the
456+
user code file (default: None).
451457
"""
452458
normalized_inputs, normalized_outputs = self._normalize_args(
453459
job_name=job_name,
454460
arguments=arguments,
455461
inputs=inputs,
456-
kms_key=kms_key,
457462
outputs=outputs,
458463
code=code,
464+
kms_key=kms_key,
459465
)
460466

461467
self.latest_job = ProcessingJob.start_new(

src/sagemaker/spark/processing.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,13 +174,13 @@ def run(
174174
self,
175175
submit_app,
176176
inputs=None,
177-
kms_key=None,
178177
outputs=None,
179178
arguments=None,
180179
wait=True,
181180
logs=True,
182181
job_name=None,
183182
experiment_config=None,
183+
kms_key=None,
184184
):
185185
"""Runs a processing job.
186186
@@ -189,8 +189,6 @@ def run(
189189
inputs (list[:class:`~sagemaker.processing.ProcessingInput`]): Input files for
190190
the processing job. These must be provided as
191191
:class:`~sagemaker.processing.ProcessingInput` objects (default: None).
192-
kms_key (str): The ARN of the KMS key that is used to encrypt the
193-
user code file (default: None).
194192
outputs (list[:class:`~sagemaker.processing.ProcessingOutput`]): Outputs for
195193
the processing job. These can be specified as either path strings or
196194
:class:`~sagemaker.processing.ProcessingOutput` objects (default: None).
@@ -204,19 +202,21 @@ def run(
204202
experiment_config (dict[str, str]): Experiment management configuration.
205203
Dictionary contains three optional keys:
206204
'ExperimentName', 'TrialName', and 'TrialComponentDisplayName'.
205+
kms_key (str): The ARN of the KMS key that is used to encrypt the
206+
user code file (default: None).
207207
"""
208208
self._current_job_name = self._generate_current_job_name(job_name=job_name)
209209

210210
super().run(
211211
submit_app,
212212
inputs,
213-
kms_key,
214213
outputs,
215214
arguments,
216215
wait,
217216
logs,
218217
job_name,
219218
experiment_config,
219+
kms_key,
220220
)
221221

222222
def _extend_processing_args(self, inputs, outputs, **kwargs):
@@ -699,6 +699,7 @@ def run(
699699
experiment_config=None,
700700
configuration=None,
701701
spark_event_logs_s3_uri=None,
702+
kms_key=None,
702703
):
703704
"""Runs a processing job.
704705
@@ -732,6 +733,8 @@ def run(
732733
https://docs.aws.amazon.com/emr/latest/ReleaseGuide/emr-configure-apps.html
733734
spark_event_logs_s3_uri (str): S3 path where spark application events will
734735
be published to.
736+
kms_key (str): The ARN of the KMS key that is used to encrypt the
737+
user code file (default: None).
735738
"""
736739
self._current_job_name = self._generate_current_job_name(job_name=job_name)
737740

@@ -876,6 +879,7 @@ def run(
876879
experiment_config=None,
877880
configuration=None,
878881
spark_event_logs_s3_uri=None,
882+
kms_key=None,
879883
):
880884
"""Runs a processing job.
881885
@@ -909,6 +913,8 @@ def run(
909913
https://docs.aws.amazon.com/emr/latest/ReleaseGuide/emr-configure-apps.html
910914
spark_event_logs_s3_uri (str): S3 path where spark application events will
911915
be published to.
916+
kms_key (str): The ARN of the KMS key that is used to encrypt the
917+
user code file (default: None).
912918
"""
913919
self._current_job_name = self._generate_current_job_name(job_name=job_name)
914920

@@ -934,6 +940,7 @@ def run(
934940
logs=logs,
935941
job_name=self._current_job_name,
936942
experiment_config=experiment_config,
943+
kms_key=kms_key,
937944
)
938945

939946
def _extend_processing_args(self, inputs, outputs, **kwargs):

tests/unit/sagemaker/spark/test_processing.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ def test_configuration_validation(config, expected, sagemaker_session) -> None:
200200
def test_spark_processor_base_run(mock_super_run, spark_processor_base):
201201
spark_processor_base.run(submit_app="app")
202202

203-
mock_super_run.assert_called_with("app", None, None, None, None, True, True, None, None)
203+
mock_super_run.assert_called_with("app", None, None, None, True, True, None, None, None)
204204

205205

206206
@pytest.mark.parametrize(
@@ -854,6 +854,7 @@ def test_spark_jar_processor_run(
854854
logs=True,
855855
job_name="jobName",
856856
experiment_config=None,
857+
kms_key=None,
857858
)
858859

859860

0 commit comments

Comments
 (0)