Skip to content

fix: allow kms_key to be passed for processing step #2779

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/sagemaker/workflow/steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,7 @@ def __init__(
cache_config: CacheConfig = None,
depends_on: Union[List[str], List[Step]] = None,
retry_policies: List[RetryPolicy] = None,
kms_key=None,
):
"""Construct a ProcessingStep, given a `Processor` instance.

Expand All @@ -500,6 +501,8 @@ def __init__(
depends_on (List[str] or List[Step]): A list of step names or step instance
this `sagemaker.workflow.steps.ProcessingStep` depends on
retry_policies (List[RetryPolicy]): A list of retry policy
kms_key (str): The ARN of the KMS key that is used to encrypt the
user code file. Defaults to `None`.
"""
super(ProcessingStep, self).__init__(
name, StepTypeEnum.PROCESSING, display_name, description, depends_on, retry_policies
Expand All @@ -511,6 +514,7 @@ def __init__(
self.code = code
self.property_files = property_files
self.job_name = None
self.kms_key = kms_key

# Examine why run method in sagemaker.processing.Processor mutates the processor instance
# by setting the instance's arguments attribute. Refactor Processor.run, if possible.
Expand Down Expand Up @@ -545,8 +549,8 @@ def arguments(self) -> RequestType:
inputs=self.inputs,
outputs=self.outputs,
code=self.code,
kms_key=self.kms_key,
)

process_args = ProcessingJob._get_process_args(
self.processor, normalized_inputs, normalized_outputs, experiment_config=dict()
)
Expand Down
4 changes: 4 additions & 0 deletions tests/unit/sagemaker/workflow/test_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,7 @@ def test_processing_step_normalizes_args_with_local_code(mock_normalize_args, sc
inputs=step.inputs,
outputs=step.outputs,
code=step.code,
kms_key=None,
)


Expand All @@ -624,6 +625,7 @@ def test_processing_step_normalizes_args_with_s3_code(mock_normalize_args, scrip
outputs=outputs,
job_arguments=["arg1", "arg2"],
cache_config=cache_config,
kms_key="arn:aws:kms:us-west-2:012345678901:key/s3-kms-key",
)
mock_normalize_args.return_value = [step.inputs, step.outputs]
step.to_request()
Expand All @@ -633,6 +635,7 @@ def test_processing_step_normalizes_args_with_s3_code(mock_normalize_args, scrip
inputs=step.inputs,
outputs=step.outputs,
code=step.code,
kms_key=step.kms_key,
)


Expand Down Expand Up @@ -667,6 +670,7 @@ def test_processing_step_normalizes_args_with_no_code(mock_normalize_args, scrip
inputs=step.inputs,
outputs=step.outputs,
code=None,
kms_key=None,
)


Expand Down