aws-step-functions-data-science-sdk-python icon indicating copy to clipboard operation
aws-step-functions-data-science-sdk-python copied to clipboard

Add support for Amazon States Language "ResultSelector" in Task, Map …

Open yoodan93 opened this issue 4 years ago • 8 comments

Add ResultSelector support for Task, Map and Parallel states.

Issue #, if available: https://github.com/aws/aws-step-functions-data-science-sdk-python/issues/95


Description of changes

Adding new Amazon States Language payload template "ResultSelector" https://states-language.net/#payload-template This change allows user to define a result_selector which is used to define the effective result of a state.

Testing

  • Added unit test for changes
  • Manual test:
# Create a simple workflow containing a task state with `result_selector`
from stepfunctions.inputs import StepResult

step_result = StepResult()
step_result_placeholder = {
    'Output': step_result['output']
}

state_with_result_selector = Task(
    state_id='StartState',
    parameters={'Key': 'Value'},
    result_selector=step_result_placeholder,
    resource=<resource_arn>
)

workflow = Workflow(
    name="ResultSelector_Example",
    definition=state_with_result_selector,
    role=<workflow_execution_role>
)

# Execute the workflow and confirm it has completed successfully
workflow.execute()

Workflow definition:

{
    "StartAt": "StartState",
    "States": {
        "StartState": {
            "Parameters": {
                "Key": "Value"
            },
            "ResultSelector": {
                "Output.$": "$['output']"
            },
            "Resource": <resource_arn>,
            "Type": "Task",
            "End": true
        }
    }
}

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

yoodan93 avatar Oct 29 '20 21:10 yoodan93

AWS CodeBuild CI Report

  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

StepFunctions-Bot avatar Oct 29 '20 21:10 StepFunctions-Bot

AWS CodeBuild CI Report

  • CodeBuild project: StepFunctionsPythonSDK-integtests
  • Commit ID: 41f2db2fe08f9f7d0e3ac413ce171f1c09310488
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

StepFunctions-Bot avatar Oct 29 '20 23:10 StepFunctions-Bot

Any update with this? Would be fantastic to have! :+1:

milesgranger avatar Aug 31 '21 12:08 milesgranger

Taking over to help merge @yoodan93 's PR Thank you for your review - will be addressing comments shortly

ca-nguyen avatar Sep 08 '21 17:09 ca-nguyen

can you also add some details around testing

Added manual test details

at some point we should probably add some basic integ tests that exercise state machines and their support for ASL features. Presumably, we'll be adding more capabilities in the future. Probably not in scope for this PR, but worth thinking about sooner than later.

Agreed! let's do add integ tests in another PR

ca-nguyen avatar Sep 09 '21 19:09 ca-nguyen

Manual test: Generated a workflow with a Task with StepResult placeholder and executed successfully

This is very unspecific. Can you share the SDK code you used to generate that?

wong-a avatar Oct 23 '21 00:10 wong-a

This is very unspecific. Can you share the SDK code you used to generate that?

Agreed - this is not sufficient information to reproduce the test. I provided more details in the Testing section of the PR description

ca-nguyen avatar Oct 23 '21 00:10 ca-nguyen

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-sEHrOdk7acJc
  • Commit ID: 6594b1c7412095c0a24f2daf502dbe5d85e003d6
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

StepFunctions-Bot avatar Oct 25 '21 17:10 StepFunctions-Bot

Hi! Any plans on merging this PR soon? I'm writing a stepfunction state machine which requires this... Thanks.

alesageProovStation avatar Jun 19 '23 13:06 alesageProovStation