Control flow in Step Functions

Having seen how data flow works naturally in Cohesion, let's take a look at how control flow works.

If statements

Let's start with the good old if statement. You write an ordinary Python if statement in your workflow function. Cohesion compiles this into a Choice state in your step function.

Generated Lambda Functions

In this example, we see one more Cohesion feature: generated Python Lambdas. You can see the source for these in the Python Functions tab. They're named as workflow_func_N.

Click on a workflow step in the graph on the right to see the code it's generated from.

These generated Python functions are used whenever there's Python code in your workflow function that cannot be implemented using Step Function primitives. So we generate Lambda functions and calls to them from the Step Function.

In this example, we generated a Lambda to implement the if statement test, since it calls the Python string.upper() function.

⬉ Click the build button to get a workflow graph