Skip to content

Commit 63d800e

Browse files
committed
Added documentation on concurrent and conditional
execution
1 parent c4ac164 commit 63d800e

9 files changed

Lines changed: 58 additions & 7 deletions

.DS_Store

0 Bytes
Binary file not shown.

docs/conditional.md

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,27 @@
1-
# Conditional invocation
1+
# Conditional Invocation
22

3-
Conditional invocation
3+
FaaSr supports the conditional invocation of actions in the workflow. This is useful in workflows where actions may or may not execute depending on the _return value_ (true or false) of a predecessor.
4+
5+
## Expressing conditional invocation in the workflow
6+
7+
Consider the example below, where the action `DownloadData` always invokes `TestData` unconditionally (black edges denote unconditional execution). Now suppose `TestData` invokes a user function (in R or Python) `my_test()` that returns either `True` or `False`.
8+
9+
Then, _depending on the return value of_ `my_test()`, either `ComputeT` is invoked (return value `True`, green edge), or `ComputeF` is invoked (return value `False`, red edge) - but not both.
10+
11+
![alt text](conditional_example.png)
12+
13+
Finally, the last action in the graph `ComputeNext` is invoked unconditionally. In effect, this implements the behavior of an if-then-else conditional execution in the workflow.
14+
15+
## Constraints
16+
17+
There are constraints that need to be observed when expressing conditional execution:
18+
19+
- Cycles are not allowed (the workflow graph must still be a [DAG])
20+
- A node in a graph *cannot* have incident edges of different types (conditional and unconditional).
21+
22+
The example below shows an _invalid_ use of conditionals where `ComputeNext` has incident edges of different types:
23+
24+
![alt text](conditional_disallowed.png)
25+
26+
27+
[DAG]: prog_model.md

docs/conditional_disallowed.png

108 KB
Loading

docs/conditional_example.png

105 KB
Loading

docs/credentials.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ In summary:
2727
- You need an access key, secret key, and ARN to use Lambda in FaaSr.
2828
- You can access your access and secret keys, and your ARN from your [Amazon AWS console](https://console.aws.amazon.com/console/home).
2929
- Paste the access key and the secret key under the names `AWS_AccessKey` and `AWS_SecretKey`, respectively, as _Repository secrets_ in your _FaaSr-workflow_ as per the instructions in the [workflow repo] documentation
30-
- Past your ARN as `AWS_ARN` as _Repository secrets_ in your _FaaSr-workflow_
30+
- Paste your ARN as `AWS_ARN` as _Repository secrets_ in your _FaaSr-workflow_
3131

3232

33-
## OpenWHisk
33+
## OpenWhisk
3434

3535
- You need an API key from your provider to configure for use in FaaSr
3636
- How you obtain this will depend on your cloud provider.

docs/distinct_concurrent.png

103 KB
Loading

docs/rank.md

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,30 @@
1-
# Concurrent invocation
1+
# Concurrent Actions
2+
3+
FaaSr supports the invocation of multiple concurrent actions in the workflow. This is useful in workflows where the workflow developer is able to determine that multiple functions can safely execute in parallel - for example, when different functions operate on independent files/datasets There are two approaches possible to invoke actions to execute concurrently:
4+
5+
- Multiple distinct actions explicitly invoked with edges from the same predecessor in the workflow DAG, or
6+
- A single action that is invoked _N times_, where _N_ is a configurable integer number, greater than 1; each invocation of the action is assigned a unique _rank_ (an integer from _1_ to _N_) that is available to the user function via the `faasr_rank` API
7+
8+
## Multiple distinct actions
9+
10+
Consider the example below, where the action `DownloadData` invokes three concurrent actions that are distinct and explicitly added to the workflow graph: `ComputeA`, `ComputeB`, and `ComputeC`:
11+
12+
![alt text](distinct_concurrent.png)
13+
14+
Each one of these actions can invoke a different user function concurrently. At the end, the action `Merge` executes the last user function, only after the three distinct actions `ComputeA`, `ComputeB`, and `ComputeC` have completed.
15+
16+
## Ranked actions
17+
18+
Ranked actions allows you to express concurrency with _multiple, parameterized invocations of the same user function_. Consider the workflow below, where the action `DownloadData` now invokes the _same_ action `ComputeRanked` three times, concurrently:
19+
20+
![alt text](ranked_concurrent.png)
21+
22+
Each concurrent `ComputeRanked` action invokes the _same user function_. Similarly to the previous example, at the end, the action `Merge` executes the last user function, only after all three `ComputeRanked` actions have completed.
23+
24+
Inside the user function invoked by each `ComputeRanked` action, the `faasr_rank` API can be invoked to return a unique number (1, 2, or 3 in this example) that can be used to differentiate between invocations. As described in the [Python API] and [R API] documentation, `faasr_rank` allows the user function to determine the `maximum` rank (3 in this example) in addition to the `per-action` rank (1, 2, or 3).
25+
26+
This information can be used, for example, to select different file names, folders, or data subsets that each action operates on. It is the responsibility of the programmer to properly use the rank information to partition datasets for safe concurrent execution, depending on their workflow and application logic.
27+
28+
[Python API]: py_api.md
29+
[R API]: r_api.md
230

3-
Concurrent invocation

docs/ranked_concurrent.png

106 KB
Loading

mkdocs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ nav:
1818
- 'Registering workflows': 'register_workflow.md'
1919
- 'Invoking workflows': 'invoke_workflow.md'
2020
- 'Retrieving logs': 'logs.md'
21-
- 'Concurrent invocation': 'rank.md'
21+
- 'Concurrent actions and ranks': 'rank.md'
2222
- 'Conditional invocation': 'conditional.md'
2323
- 'Invocation IDs': 'invocationid.md'
2424
- 'Package dependences': 'dependences.md'

0 commit comments

Comments
 (0)