Skip to content

Commit 17b4faf

Browse files
author
Payton Staub
committed
Address PR comments
1 parent 87c1cf5 commit 17b4faf

File tree

4 files changed

+30
-44
lines changed

4 files changed

+30
-44
lines changed

src/sagemaker/processing.py

Lines changed: 21 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
import os
2222
import pathlib
23+
import attr
2324

2425
from six.moves.urllib.parse import urlparse
2526
from six.moves.urllib.request import url2pathname
@@ -207,13 +208,13 @@ def _normalize_args(
207208
inputs (list[:class:`~sagemaker.processing.ProcessingInput`]): Input files for
208209
the processing job. These must be provided as
209210
:class:`~sagemaker.processing.ProcessingInput` objects (default: None).
210-
kms_key (str): The ARN of the KMS key that is used to encrypt the
211-
user code file (default: None).
212211
outputs (list[:class:`~sagemaker.processing.ProcessingOutput`]): Outputs for
213212
the processing job. These can be specified as either path strings or
214213
:class:`~sagemaker.processing.ProcessingOutput` objects (default: None).
215214
code (str): This can be an S3 URI or a local path to a file with the framework
216215
script to run (default: None). A no op in the base class.
216+
kms_key (str): The ARN of the KMS key that is used to encrypt the
217+
user code file (default: None).
217218
"""
218219
self._current_job_name = self._generate_current_job_name(job_name=job_name)
219220

@@ -444,7 +445,7 @@ def __init__(
444445

445446
def get_run_args(
446447
self,
447-
code=None,
448+
code,
448449
inputs=None,
449450
outputs=None,
450451
arguments=None,
@@ -1172,39 +1173,31 @@ def _to_request_dict(self):
11721173
return s3_output_request
11731174

11741175

1176+
@attr.s
11751177
class RunArgs(object):
11761178
"""Accepts parameters that correspond to ScriptProcessors.
11771179
11781180
An instance of this class is returned from the ``get_run_args()`` method on processors,
11791181
and is used for normalizing the arguments so that they can be passed to
11801182
:class:`~sagemaker.workflow.steps.ProcessingStep`
1181-
"""
11821183
1183-
def __init__(
1184-
self,
1185-
code=None,
1186-
inputs=None,
1187-
outputs=None,
1188-
arguments=None,
1189-
):
1190-
"""Initializes a ``RunArgs`` instance.
1184+
Args:
1185+
code (str): This can be an S3 URI or a local path to a file with the framework
1186+
script to run.
1187+
inputs (list[:class:`~sagemaker.processing.ProcessingInput`]): Input files for
1188+
the processing job. These must be provided as
1189+
:class:`~sagemaker.processing.ProcessingInput` objects (default: None).
1190+
outputs (list[:class:`~sagemaker.processing.ProcessingOutput`]): Outputs for
1191+
the processing job. These can be specified as either path strings or
1192+
:class:`~sagemaker.processing.ProcessingOutput` objects (default: None).
1193+
arguments (list[str]): A list of string arguments to be passed to a
1194+
processing job (default: None).
1195+
"""
11911196

1192-
Args:
1193-
code (str): This can be an S3 URI or a local path to a file with the framework
1194-
script to run.
1195-
inputs (list[:class:`~sagemaker.processing.ProcessingInput`]): Input files for
1196-
the processing job. These must be provided as
1197-
:class:`~sagemaker.processing.ProcessingInput` objects (default: None).
1198-
outputs (list[:class:`~sagemaker.processing.ProcessingOutput`]): Outputs for
1199-
the processing job. These can be specified as either path strings or
1200-
:class:`~sagemaker.processing.ProcessingOutput` objects (default: None).
1201-
arguments (list[str]): A list of string arguments to be passed to a
1202-
processing job (default: None).
1203-
"""
1204-
self.inputs = inputs
1205-
self.outputs = outputs
1206-
self.code = code
1207-
self.arguments = arguments
1197+
code = attr.ib()
1198+
inputs = attr.ib(default=None)
1199+
outputs = attr.ib(default=None)
1200+
arguments = attr.ib(default=None)
12081201

12091202

12101203
class FeatureStoreOutput(ApiObject):

src/sagemaker/spark/processing.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ def __init__(
173173

174174
def get_run_args(
175175
self,
176-
code=None,
176+
code,
177177
inputs=None,
178178
outputs=None,
179179
arguments=None,
@@ -768,8 +768,8 @@ def get_run_args(
768768
raise ValueError("submit_app is required")
769769

770770
extended_inputs, extended_outputs = self._extend_processing_args(
771-
inputs,
772-
outputs,
771+
inputs=inputs,
772+
outputs=outputs,
773773
submit_py_files=submit_py_files,
774774
submit_jars=submit_jars,
775775
submit_files=submit_files,
@@ -842,8 +842,8 @@ def run(
842842
raise ValueError("submit_app is required")
843843

844844
extended_inputs, extended_outputs = self._extend_processing_args(
845-
inputs,
846-
outputs,
845+
inputs=inputs,
846+
outputs=outputs,
847847
submit_py_files=submit_py_files,
848848
submit_jars=submit_jars,
849849
submit_files=submit_files,
@@ -1016,8 +1016,8 @@ def get_run_args(
10161016
raise ValueError("submit_app is required")
10171017

10181018
extended_inputs, extended_outputs = self._extend_processing_args(
1019-
inputs,
1020-
outputs,
1019+
inputs=inputs,
1020+
outputs=outputs,
10211021
submit_class=submit_class,
10221022
submit_jars=submit_jars,
10231023
submit_files=submit_files,
@@ -1090,8 +1090,8 @@ def run(
10901090
raise ValueError("submit_app is required")
10911091

10921092
extended_inputs, extended_outputs = self._extend_processing_args(
1093-
inputs,
1094-
outputs,
1093+
inputs=inputs,
1094+
outputs=outputs,
10951095
submit_class=submit_class,
10961096
submit_jars=submit_jars,
10971097
submit_files=submit_files,

src/sagemaker/workflow/steps.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,6 @@ def __init__(
320320
code: str = None,
321321
property_files: List[PropertyFile] = None,
322322
cache_config: CacheConfig = None,
323-
kms_key=None,
324323
):
325324
"""Construct a ProcessingStep, given a `Processor` instance.
326325
@@ -341,8 +340,6 @@ def __init__(
341340
property_files (List[PropertyFile]): A list of property files that workflow looks
342341
for and resolves from the configured processing output list.
343342
cache_config (CacheConfig): A `sagemaker.workflow.steps.CacheConfig` instance.
344-
kms_key (str): The ARN of the KMS key that is used to encrypt the
345-
user code file (default: None)
346343
"""
347344
super(ProcessingStep, self).__init__(name, StepTypeEnum.PROCESSING)
348345
self.processor = processor
@@ -351,7 +348,6 @@ def __init__(
351348
self.job_arguments = job_arguments
352349
self.code = code
353350
self.property_files = property_files
354-
self.kms_key = kms_key
355351

356352
# Examine why run method in sagemaker.processing.Processor mutates the processor instance
357353
# by setting the instance's arguments attribute. Refactor Processor.run, if possible.
@@ -374,7 +370,6 @@ def arguments(self) -> RequestType:
374370
inputs=self.inputs,
375371
outputs=self.outputs,
376372
code=self.code,
377-
kms_key=self.kms_key,
378373
)
379374

380375
process_args = ProcessingJob._get_process_args(

tests/unit/sagemaker/workflow/test_steps.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,6 @@ def test_processing_step_normalizes_args(mock_normalize_args, sagemaker_session)
262262
outputs=outputs,
263263
job_arguments=["arg1", "arg2"],
264264
cache_config=cache_config,
265-
kms_key="key",
266265
)
267266
mock_normalize_args.return_value = [step.inputs, step.outputs]
268267
step.to_request()
@@ -271,7 +270,6 @@ def test_processing_step_normalizes_args(mock_normalize_args, sagemaker_session)
271270
inputs=step.inputs,
272271
outputs=step.outputs,
273272
code=step.code,
274-
kms_key=step.kms_key,
275273
)
276274

277275

0 commit comments

Comments
 (0)