Skip to content

Commit 851fc0e

Browse files
author
Daniel Yoo
committed
Add result selector support for EventBridgePutEventsStep
1 parent 8667c37 commit 851fc0e

File tree

2 files changed

+60
-59
lines changed

2 files changed

+60
-59
lines changed

src/stepfunctions/steps/service.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ def __init__(self, state_id, wait_for_callback=False, **kwargs):
101101
heartbeat_seconds_path (str, optional): Path specifying the state's heartbeat value in seconds from the state input. When resolved, the path must select a field whose value is a positive integer.
102102
input_path (str, optional): Path applied to the state’s raw input to select some or all of it; that selection is used by the state. (default: '$')
103103
parameters (dict, optional): The value of this field becomes the effective input for the state.
104+
result_selector (dict, optional): The value of this field becomes the effective result of the state.
104105
result_path (str, optional): Path specifying the raw input’s combination with or replacement by the state’s result. (default: '$')
105106
output_path (str, optional): Path applied to the state’s output after the application of `result_path`, producing the effective output which serves as the raw input for the next state. (default: '$')
106107
"""

tests/unit/test_placeholders_with_steps.py

Lines changed: 59 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ def test_workflow_input_placeholder():
2121

2222
workflow_input = ExecutionInput()
2323
test_step = Pass(
24-
state_id='StateOne',
24+
state_id="StateOne",
2525
parameters={
26-
'ParamA': 'SampleValueA',
27-
'ParamB': workflow_input,
28-
'ParamC': workflow_input['Key01'],
29-
'ParamD': workflow_input['Key02']['Key03'],
30-
'ParamE': workflow_input['Key01']['Key03'],
26+
"ParamA": "SampleValueA",
27+
"ParamB": workflow_input,
28+
"ParamC": workflow_input["Key01"],
29+
"ParamD": workflow_input["Key02"]["Key03"],
30+
"ParamE": workflow_input["Key01"]["Key03"],
3131
}
3232
)
3333

@@ -48,14 +48,14 @@ def test_workflow_input_placeholder():
4848
def test_step_input_placeholder():
4949

5050
test_step_01 = Pass(
51-
state_id='StateOne'
51+
state_id="StateOne"
5252
)
5353

5454
test_step_02 = Pass(
55-
state_id='StateTwo',
55+
state_id="StateTwo",
5656
parameters={
57-
'ParamA': test_step_01.output(),
58-
'ParamB': test_step_01.output()["Response"]["Key02"],
57+
"ParamA": test_step_01.output(),
58+
"ParamB": test_step_01.output()["Response"]["Key02"],
5959
"ParamC": "SampleValueC"
6060
}
6161
)
@@ -77,26 +77,26 @@ def test_workflow_with_placeholders():
7777
workflow_input = ExecutionInput()
7878

7979
test_step_01 = Pass(
80-
state_id='StateOne',
80+
state_id="StateOne",
8181
parameters={
82-
'ParamA': workflow_input['Key02']['Key03'],
83-
'ParamD': workflow_input['Key01']['Key03'],
82+
"ParamA": workflow_input["Key02"]["Key03"],
83+
"ParamD": workflow_input["Key01"]["Key03"],
8484
}
8585
)
8686

8787
test_step_02 = Pass(
88-
state_id='StateTwo',
88+
state_id="StateTwo",
8989
parameters={
90-
'ParamC': workflow_input["Key05"],
90+
"ParamC": workflow_input["Key05"],
9191
"ParamB": "SampleValueB",
9292
"ParamE": test_step_01.output()["Response"]["Key04"]
9393
}
9494
)
9595

9696
test_step_03 = Pass(
97-
state_id='StateThree',
97+
state_id="StateThree",
9898
parameters={
99-
'ParamG': "SampleValueG",
99+
"ParamG": "SampleValueG",
100100
"ParamF": workflow_input["Key06"],
101101
"ParamH": "SampleValueH"
102102
}
@@ -144,26 +144,26 @@ def test_step_input_order_validation():
144144
workflow_input = ExecutionInput()
145145

146146
test_step_01 = Pass(
147-
state_id='StateOne',
147+
state_id="StateOne",
148148
parameters={
149-
'ParamA': workflow_input['Key02']['Key03'],
150-
'ParamD': workflow_input['Key01']['Key03'],
149+
"ParamA": workflow_input["Key02"]["Key03"],
150+
"ParamD": workflow_input["Key01"]["Key03"],
151151
}
152152
)
153153

154154
test_step_02 = Pass(
155-
state_id='StateTwo',
155+
state_id="StateTwo",
156156
parameters={
157-
'ParamC': workflow_input["Key05"],
157+
"ParamC": workflow_input["Key05"],
158158
"ParamB": "SampleValueB",
159159
"ParamE": test_step_01.output()["Response"]["Key04"]
160160
}
161161
)
162162

163163
test_step_03 = Pass(
164-
state_id='StateThree',
164+
state_id="StateThree",
165165
parameters={
166-
'ParamG': "SampleValueG",
166+
"ParamG": "SampleValueG",
167167
"ParamF": workflow_input["Key06"],
168168
"ParamH": "SampleValueH"
169169
}
@@ -179,17 +179,17 @@ def test_map_state_with_placeholders():
179179
step_result = StepResult()
180180

181181
map_state = Map(
182-
state_id='MapState01',
182+
state_id="MapState01",
183183
result_selector={
184-
'foo': step_result['foo'],
185-
'bar': step_result['bar1']['bar2']
184+
"foo": step_result["foo"],
185+
"bar": step_result["bar1"]["bar2"]
186186
}
187187
)
188188
iterator_state = Pass(
189-
'TrainIterator',
189+
"TrainIterator",
190190
parameters={
191-
'ParamA': map_state.output()['X']["Y"],
192-
'ParamB': workflow_input["Key01"]["Key02"]["Key03"]
191+
"ParamA": map_state.output()["X"]["Y"],
192+
"ParamB": workflow_input["Key01"]["Key02"]["Key03"]
193193
})
194194

195195
map_state.attach_iterator(iterator_state)
@@ -230,32 +230,32 @@ def test_parallel_state_with_placeholders():
230230
step_result = StepResult()
231231

232232
parallel_state = Parallel(
233-
state_id='ParallelState01',
233+
state_id="ParallelState01",
234234
result_selector={
235-
'foo': step_result['foo'],
236-
'bar': step_result['bar1']['bar2']
235+
"foo": step_result["foo"],
236+
"bar": step_result["bar1"]["bar2"]
237237
}
238238
)
239239

240240
branch_A = Pass(
241-
'Branch_A',
241+
"Branch_A",
242242
parameters={
243-
'ParamA': parallel_state.output()['A']["B"],
244-
'ParamB': workflow_input["Key01"]
243+
"ParamA": parallel_state.output()["A"]["B"],
244+
"ParamB": workflow_input["Key01"]
245245
})
246246

247247
branch_B = Pass(
248-
'Branch_B',
248+
"Branch_B",
249249
parameters={
250-
'ParamA': "TestValue",
251-
'ParamB': parallel_state.output()["Response"]["Key"]["State"]
250+
"ParamA": "TestValue",
251+
"ParamB": parallel_state.output()["Response"]["Key"]["State"]
252252
})
253253

254254
branch_C = Pass(
255-
'Branch_C',
255+
"Branch_C",
256256
parameters={
257-
'ParamA': parallel_state.output()['A']["B"].get("C", float),
258-
'ParamB': "HelloWorld"
257+
"ParamA": parallel_state.output()["A"]["B"].get("C", float),
258+
"ParamB": "HelloWorld"
259259
})
260260

261261
parallel_state.add_branch(branch_A)
@@ -325,13 +325,13 @@ def test_parallel_state_with_placeholders():
325325

326326
def test_choice_state_with_placeholders():
327327

328-
first_state = Task('FirstState', resource='arn:aws:lambda:us-east-1:1234567890:function:FirstState')
329-
retry = Chain([Pass('Retry'), Pass('Cleanup'), first_state])
328+
first_state = Task("FirstState", resource="arn:aws:lambda:us-east-1:1234567890:function:FirstState")
329+
retry = Chain([Pass("Retry"), Pass("Cleanup"), first_state])
330330

331-
choice_state = Choice('Is Completed?')
331+
choice_state = Choice("Is Completed?")
332332
choice_state.add_choice(
333333
ChoiceRule.BooleanEquals(choice_state.output()["Completed"], True),
334-
Succeed('Complete')
334+
Succeed("Complete")
335335
)
336336
choice_state.add_choice(
337337
ChoiceRule.BooleanEquals(choice_state.output()["Completed"], False),
@@ -384,7 +384,7 @@ def test_choice_state_with_placeholders():
384384
def test_schema_validation_for_step_input():
385385

386386
test_step_01 = Pass(
387-
state_id='StateOne',
387+
state_id="StateOne",
388388
output_schema={
389389
"Response": {
390390
"Key01": str
@@ -394,18 +394,18 @@ def test_schema_validation_for_step_input():
394394

395395
with pytest.raises(ValueError):
396396
test_step_02 = Pass(
397-
state_id='StateTwo',
397+
state_id="StateTwo",
398398
parameters={
399-
'ParamA': test_step_01.output()["Response"]["Key02"],
399+
"ParamA": test_step_01.output()["Response"]["Key02"],
400400
"ParamB": "SampleValueB"
401401
}
402402
)
403403

404404
with pytest.raises(ValueError):
405405
test_step_03 = Pass(
406-
state_id='StateTwo',
406+
state_id="StateTwo",
407407
parameters={
408-
'ParamA': test_step_01.output()["Response"].get("Key01", float),
408+
"ParamA": test_step_01.output()["Response"].get("Key01", float),
409409
"ParamB": "SampleValueB"
410410
}
411411
)
@@ -414,9 +414,9 @@ def test_step_result_placeholder():
414414
step_result = StepResult()
415415

416416
test_step_01 = Task(
417-
state_id='StateOne',
417+
state_id="StateOne",
418418
result_selector={
419-
'ParamA': step_result["foo"],
419+
"ParamA": step_result["foo"],
420420
"ParamC": "SampleValueC"
421421
}
422422
)
@@ -444,18 +444,18 @@ def test_schema_validation_for_step_result():
444444

445445
with pytest.raises(ValueError):
446446
test_step_01 = Task(
447-
state_id='StateOne',
447+
state_id="StateOne",
448448
result_selector={
449-
'ParamA': step_result["Payload"]["Key02"],
449+
"ParamA": step_result["Payload"]["Key02"],
450450
"ParamB": "SampleValueB"
451451
}
452452
)
453453

454454
with pytest.raises(ValueError):
455455
test_step_02 = Task(
456-
state_id='StateOne',
456+
state_id="StateOne",
457457
parameters={
458-
'ParamA': step_result["Payload"].get("Key01", float),
458+
"ParamA": step_result["Payload"].get("Key01", float),
459459
"ParamB": "SampleValueB"
460460
}
461461
)
@@ -471,9 +471,9 @@ def test_schema_validation_success_for_step_result():
471471

472472
try:
473473
test_step = Task(
474-
state_id='StateOne',
474+
state_id="StateOne",
475475
result_selector={
476-
'ParamA': step_result["Payload"]["Key01"]
476+
"ParamA": step_result["Payload"]["Key01"]
477477
}
478478
)
479479
except:

0 commit comments

Comments
 (0)