Skip to content

fix: support idempotency for framework and spark processors #3460

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 9 commits into from
Dec 5, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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
9 changes: 7 additions & 2 deletions src/sagemaker/processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1827,14 +1827,19 @@ def _patch_inputs_with_payload(self, inputs, s3_payload) -> List[ProcessingInput
# a7399455f5386d83ddc5cb15c0db00c04bd518ec/src/sagemaker/processing.py#L425-L426
if inputs is None:
inputs = []
inputs.append(

# make a shallow copy of user inputs
patched_inputs = []
for user_input in inputs:
patched_inputs.append(user_input)
patched_inputs.append(
ProcessingInput(
input_name="code",
source=s3_payload,
destination="/opt/ml/processing/input/code/",
)
)
return inputs
return patched_inputs

def _set_entrypoint(self, command, user_script_name):
"""Framework processor override for setting processing job entrypoint.
Expand Down
21 changes: 19 additions & 2 deletions src/sagemaker/spark/processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -940,9 +940,18 @@ def _extend_processing_args(self, inputs, outputs, **kwargs):
outputs: Processing outputs.
kwargs: Additional keyword arguments passed to `super()`.
"""

if inputs is None:
inputs = []

# make a shallow copy of user inputs
extended_inputs = []
for user_input in inputs:
extended_inputs.append(user_input)

self.command = [_SparkProcessorBase._default_command]
extended_inputs = self._handle_script_dependencies(
inputs, kwargs.get("submit_py_files"), FileType.PYTHON
extended_inputs, kwargs.get("submit_py_files"), FileType.PYTHON
)
extended_inputs = self._handle_script_dependencies(
extended_inputs, kwargs.get("submit_jars"), FileType.JAR
Expand Down Expand Up @@ -1199,8 +1208,16 @@ def _extend_processing_args(self, inputs, outputs, **kwargs):
else:
raise ValueError("submit_class is required")

if inputs is None:
inputs = []

# make a shallow copy of user inputs
extended_inputs = []
for user_input in inputs:
extended_inputs.append(user_input)

extended_inputs = self._handle_script_dependencies(
inputs, kwargs.get("submit_jars"), FileType.JAR
extended_inputs, kwargs.get("submit_jars"), FileType.JAR
)
extended_inputs = self._handle_script_dependencies(
extended_inputs, kwargs.get("submit_files"), FileType.FILE
Expand Down
4 changes: 2 additions & 2 deletions src/sagemaker/workflow/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def get_processing_code_hash(code: str, source_dir: str, dependencies: List[str]
str: A hash string representing the unique code artifact(s) for the step
"""

# FrameworkProcessor
# If FrameworkProcessor contains source_dir
if source_dir:
source_dir_url = urlparse(source_dir)
if source_dir_url.scheme == "" or source_dir_url.scheme == "file":
Expand Down Expand Up @@ -400,5 +400,5 @@ def execute_job_functions(step_args: _StepArguments):
"""

chained_args = step_args.func(*step_args.func_args, **step_args.func_kwargs)
if chained_args:
if isinstance(chained_args, _StepArguments):
execute_job_functions(chained_args)
Binary file added tests/data/spark/code/java/TestJarFile.jar
Binary file not shown.
Binary file not shown.
Loading