-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Step Functions, Support for Output Blocks in Choice Rules, Improvments to JSONata Choice Defaults #12075
Conversation
LocalStack Community integration with Pro 2 files ± 0 2 suites ±0 32m 18s ⏱️ - 1h 20m 37s Results for commit 340ee29. ± Comparison against base commit 81d9fb0. This pull request removes 2600 and adds 5 tests. Note that renamed tests count towards both.
This pull request skips 1 test.
♻️ This comment has been updated with latest results. |
# Exec the state's logic. | ||
self._eval_state(env) | ||
|
||
# Handle legacy output sequences if in JsonPath mode. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: Did you need to override base _eval_body
method because of this legacy handling? If yes, is there any existing test that covers this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I refactored the reusable parts of states' evaluation into: loading the state input, evaluating the state logic, and evaluation the state output. whilst the logical glue of these three steps is being reused in the _eval_body of CommonStateField. This works well with the two known exception for evalutatint the state output: catch blocks in execution states and choice states.
We do have many snpahost tests for legacy (or JSONPath) choice states in aws.services.stepfunctions.v2.scenarios
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great refactoring! 🎉
Now all special cases are handled within their respective states and common method is clean and readable! 👏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
I'd appreciate a bit more information about the differences from base _eval_body
method. It is not obvious why it needs to be overridden. Override that mostly repeats base method with slight differences adds additional maintenance effort.
As a suggestion to follow up later, maybe we could analyze if super()._eval_body(env=env)
can be called from override instead of copying most parts of it?
env.stack.append(env.states.get_input()) | ||
|
||
# Exec the state's logic. | ||
self._eval_state(env) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: in the base method this block is wrapped in a try-catch block that handles NoSuchJsonPathError
. Why is it not needed here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, there is another generic check in base method that is not present here:
if not isinstance(env.program_state(), ProgramRunning):
return
Is there anything specific about Choice state that doesn't require the check?
Motivation
The SFN v2 interpreter currently lacks support for
Output
block declarations within choice rules, as noted in #12048. Additionally, the current implementation of the choice state does not handleOutput
andAssign
blocks as intended, since it always evaluates the defaultAssign
andOutput
blocks before returning.A further issue lies in the use of a member variable to track the next state name, which has been identified as an antipattern and addressed in recent changes #12068.
Changes
Output
blocks in choice rules.Assign
andOutput
blocks.Output
blocks in choice rulesOuput
andAssign
evaluation logic