Skip to content

feature: support for custom pipeline execution name #2335

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 2 commits into from
May 21, 2021
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
5 changes: 4 additions & 1 deletion src/sagemaker/workflow/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

import attr
import botocore

from botocore.exceptions import ClientError

from sagemaker._studio import _append_project_tags
Expand Down Expand Up @@ -197,13 +196,15 @@ def delete(self) -> Dict[str, Any]:
def start(
self,
parameters: Dict[str, Any] = None,
execution_display_name: str = None,
execution_description: str = None,
):
"""Starts a Pipeline execution in the Workflow service.
Args:
parameters (List[Dict[str, str]]): A list of parameter dicts of the form
{"Name": "string", "Value": "string"}.
execution_display_name (str): The display name of the pipeline execution.
execution_description (str): A description of the execution.
Returns:
Expand All @@ -220,11 +221,13 @@ def start(
"This pipeline is not associated with a Pipeline in SageMaker. "
"Please invoke create() first before attempting to invoke start()."
)

kwargs = dict(PipelineName=self.name)
update_args(
kwargs,
PipelineParameters=format_start_parameters(parameters),
PipelineExecutionDescription=execution_description,
PipelineExecutionDisplayName=execution_display_name,
)
response = self.sagemaker_session.sagemaker_client.start_pipeline_execution(**kwargs)
return _PipelineExecution(
Expand Down
6 changes: 6 additions & 0 deletions tests/unit/sagemaker/workflow/test_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,12 @@ def test_pipeline_start(sagemaker_session_mock):
assert sagemaker_session_mock.start_pipeline_execution.called_with(
PipelineName="MyPipeline",
)

pipeline.start(execution_display_name="pipeline-execution")
assert sagemaker_session_mock.start_pipeline_execution.called_with(
PipelineName="MyPipeline", PipelineExecutionDisplayName="pipeline-execution"
)

pipeline.start(parameters=dict(alpha="epsilon"))
assert sagemaker_session_mock.start_pipeline_execution.called_with(
PipelineName="MyPipeline", PipelineParameters=[{"Name": "alpha", "Value": "epsilon"}]
Expand Down