-
Notifications
You must be signed in to change notification settings - Fork 89
feat: Support placeholders for input_path and output_path for all States (except Fail) and items_path for MapState #158
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
base: main
Are you sure you want to change the base?
Changes from 2 commits
f5800cb
788c148
c975274
d20a883
1c397df
ca42a7a
0e81c29
a0d70c7
d174bab
77bdab3
3fef23b
1798d7a
bd7c271
6dcfbaf
9942f95
b4ddbbd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ | |
import pytest | ||
|
||
from stepfunctions.steps import Pass, Succeed, Fail, Wait, Choice, ChoiceRule, Parallel, Map, Task, Retry, Catch, Chain, Graph | ||
from stepfunctions.inputs import ExecutionInput, StepInput | ||
from stepfunctions.inputs import ExecutionInput, MapItemValue, MapItemIndex | ||
|
||
def test_workflow_input_placeholder(): | ||
|
||
|
@@ -214,6 +214,64 @@ def test_map_state_with_placeholders(): | |
result = Graph(workflow_definition).to_dict() | ||
assert result == expected_repr | ||
|
||
|
||
def test_map_state_with_placeholders(): | ||
map_item_value = MapItemValue(schema={ | ||
'name': str, | ||
'age': str | ||
}) | ||
|
||
map_item_index = MapItemIndex() | ||
ca-nguyen marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
map_state = Map( | ||
'MapState01', | ||
parameters={ | ||
"MapIndex": map_item_index, | ||
shivlaks marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
"Name": map_item_value['name'], | ||
"Age": map_item_value['age'] | ||
} | ||
) | ||
iterator_state = Pass( | ||
'TrainIterator', | ||
parameters={ | ||
'ParamA': map_state.output()['X']["Y"] | ||
} | ||
) | ||
|
||
map_state.attach_iterator(iterator_state) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. question: what happens with this? - does it become part of the workflow definition somewhere? I thought the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ItemsPath is optional. Similar to InputPath and OutputPath, the default is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The iterator is added to the Map State here and will be added to the workflow definition when the Map state itself is added to the workflow definition The docstring will need to be updated - it seems like
This can be done in another PR to avoid making the scope larger |
||
workflow_definition = Chain([map_state]) | ||
|
||
expected_repr = { | ||
"StartAt": "MapState01", | ||
"States": { | ||
"MapState01": { | ||
"Type": "Map", | ||
"End": True, | ||
"Iterator": { | ||
"StartAt": "TrainIterator", | ||
"States": { | ||
"TrainIterator": { | ||
"Parameters": { | ||
"ParamA.$": "$['X']['Y']" | ||
}, | ||
"Type": "Pass", | ||
"End": True | ||
} | ||
} | ||
}, | ||
"Parameters": { | ||
"Age.$": "$$.Map.Item.Value['age']", | ||
"MapIndex.$": "$$.Map.Item.Index", | ||
"Name.$": "$$.Map.Item.Value['name']" | ||
}, | ||
} | ||
} | ||
} | ||
|
||
result = Graph(workflow_definition).to_dict() | ||
assert result == expected_repr | ||
|
||
|
||
def test_parallel_state_with_placeholders(): | ||
workflow_input = ExecutionInput() | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.