-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feature: add support for Std:Join for pipelines #2103
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
+160
−21
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
449684e
feature: add support for Std:Join for pipelines
metrizable 9e626f2
Merge branch 'master' into std-join
metrizable 641f940
Update src/sagemaker/workflow/functions.py
metrizable fbdac3f
Update tests/unit/sagemaker/workflow/test_functions.py
metrizable ccca21f
fix: ensure region is specified for workflow client
metrizable 5bc5d16
feature: Map image name to image uri (#2100)
ndodda-amazon fc83d96
Merge branch 'master' into std-join
metrizable File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"). You | ||
# may not use this file except in compliance with the License. A copy of | ||
# the License is located at | ||
# | ||
# http://aws.amazon.com/apache2.0/ | ||
# | ||
# or in the "license" file accompanying this file. This file is | ||
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF | ||
# ANY KIND, either express or implied. See the License for the specific | ||
# language governing permissions and limitations under the License. | ||
"""The step definitions for workflow.""" | ||
from __future__ import absolute_import | ||
|
||
from typing import List | ||
|
||
import attr | ||
|
||
from sagemaker.workflow.entities import Expression | ||
|
||
|
||
@attr.s | ||
class Join(Expression): | ||
"""Join together properties. | ||
|
||
Attributes: | ||
values (List[Union[PrimitiveType, Parameter]]): The primitive types | ||
and parameters to join. | ||
on_str (str): The string to join the values on (Defaults to ""). | ||
""" | ||
|
||
on: str = attr.ib(factory=str) | ||
values: List = attr.ib(factory=list) | ||
|
||
@property | ||
def expr(self): | ||
"""The expression dict for a `Join` function.""" | ||
return { | ||
"Std:Join": { | ||
"On": self.on, | ||
"Values": [ | ||
value.expr if hasattr(value, "expr") else value for value in self.values | ||
], | ||
}, | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"). You | ||
# may not use this file except in compliance with the License. A copy of | ||
# the License is located at | ||
# | ||
# http://aws.amazon.com/apache2.0/ | ||
# | ||
# or in the "license" file accompanying this file. This file is | ||
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF | ||
# ANY KIND, either express or implied. See the License for the specific | ||
# language governing permissions and limitations under the License. | ||
# language governing permissions and limitations under the License. | ||
from __future__ import absolute_import | ||
|
||
from sagemaker.workflow.execution_variables import ExecutionVariables | ||
from sagemaker.workflow.functions import Join | ||
from sagemaker.workflow.parameters import ( | ||
ParameterFloat, | ||
ParameterInteger, | ||
ParameterString, | ||
) | ||
from sagemaker.workflow.properties import Properties | ||
|
||
|
||
def test_join_primitives_default_on(): | ||
assert Join(values=[1, "a", False, 1.1]).expr == { | ||
"Std:Join": { | ||
"On": "", | ||
"Values": [1, "a", False, 1.1], | ||
}, | ||
} | ||
|
||
|
||
def test_join_primitives(): | ||
assert Join(on=",", values=[1, "a", False, 1.1]).expr == { | ||
"Std:Join": { | ||
"On": ",", | ||
"Values": [1, "a", False, 1.1], | ||
}, | ||
} | ||
|
||
|
||
def test_join_expressions(): | ||
assert Join( | ||
values=[ | ||
"foo", | ||
ParameterFloat(name="MyFloat"), | ||
ParameterInteger(name="MyInt"), | ||
ParameterString(name="MyStr"), | ||
Properties(path="Steps.foo.OutputPath.S3Uri"), | ||
ExecutionVariables.PIPELINE_EXECUTION_ID, | ||
Join(on=",", values=[1, "a", False, 1.1]), | ||
] | ||
).expr == { | ||
"Std:Join": { | ||
"On": "", | ||
"Values": [ | ||
"foo", | ||
{"Get": "Parameters.MyFloat"}, | ||
{"Get": "Parameters.MyInt"}, | ||
{"Get": "Parameters.MyStr"}, | ||
{"Get": "Steps.foo.OutputPath.S3Uri"}, | ||
{"Get": "Execution.PipelineExecutionId"}, | ||
{"Std:Join": {"On": ",", "Values": [1, "a", False, 1.1]}}, | ||
], | ||
}, | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.