Skip to content

Commit 87337a6

Browse files
docs: describe data flow visually
Signed-off-by: Matthias Pichler <[email protected]>
1 parent 67f7669 commit 87337a6

File tree

2 files changed

+63
-7
lines changed

2 files changed

+63
-7
lines changed

dsl-reference.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ The Serverless Workflow DSL defines a list of [tasks](#task) that **must be** su
243243
244244
| Name | Type | Required | Description|
245245
|:--|:---:|:---:|:---|
246-
| if | `string` | `no` | A [`runtime expression`](dsl.md#runtime-expressions), if any, used to determine whether or not the task should be run.<br>The task is considered skipped if not run. The runtime expression evaluates in the context of the filtered task input (i.e. result of the `input.from` expression, if any) |
246+
| if | `string` | `no` | A [`runtime expression`](dsl.md#runtime-expressions), if any, used to determine whether or not the task should be run.<br>The task is considered skipped if not run. |
247247
| input | [`input`](#input) | `no` | An object used to customize the task's input and to document its schema, if any. |
248248
| output | [`output`](#output) | `no` | An object used to customize the task's output and to document its schema, if any. |
249249
| export | [`export`](#export) | `no` | An object used to customize the content of the workflow context. |

dsl.md

Lines changed: 62 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -149,37 +149,93 @@ In Serverless Workflow DSL, data flow management is crucial to ensure that the r
149149
Here's how data flows through a workflow based on various filtering stages:
150150

151151
1. **Filter Workflow Input**
152-
Before the workflow starts, the input data provided to the workflow can be filtered to ensure only relevant data is passed into the workflow context. This step allows the workflow to start with a clean and focused dataset, reducing potential overhead and complexity in subsequent tasks.
152+
Before the workflow starts, the input data provided to the workflow can be filtered to ensure only relevant data is passed into the workflow context. This can be done using the top level `input.from` expression. It evaluates on the raw workflow input and defaults to the identity expression which leaves the input unchanged. This step allows the workflow to start with a clean and focused dataset, reducing potential overhead and complexity in subsequent tasks. The result of this expression will set as the initial value for the `$context` runtime expression argument and be passed to the first task.
153153

154154
*Example: If the workflow receives a JSON object as input, a filter can be applied to remove unnecessary fields and retain only those that are required for the workflow's execution.*
155155

156156
2. **Filter First Task Input**
157-
The input data for the first task can be filtered to match the specific requirements of that task. This ensures that the first task receives only the necessary data it needs to perform its operations.
157+
The input data for the first task can be filtered to match the specific requirements of that task. This ensures that the first task receives only the necessary data it needs to perform its operations. This can be done using the task's `input.from` expression. It evaluates on the filtered workflow input and defaults to the identity expression which leaves the input unchanged. The result of this expression will be set as the `$input` runtime expression argument and be passed to the task. Any runtime expressions used within the task definition will be evaluated using this filtered input.
158158

159159
*Example: If the first task is a function call that only needs a subset of the workflow input, a filter can be applied to provide only those fields needed for the function to execute.*
160160

161161
3. **Filter First Task Output**
162-
After the first task completes, its output can be filtered before passing it to the next task or storing it in the workflow context. This helps in managing the data flow and keeping the context clean by removing any unnecessary data produced by the task.
162+
After the first task completes, its output can be filtered before passing it to the next task or storing it in the workflow context. Filtering is performed using the `output.as` runtime expression. It evaluates on the raw task output and defaults to the identity expression which leaves the output unchanged. Its result will be the input to the next task. To update the context one uses the `export.as` runtime expression. It evaluates on the raw output and defaults to the expression that returns the existing context. The result of this runtime expression replaces the workflows current context and the content of the `$context`runtime expression argument. This helps in managing the data flow and keeping the context clean by removing any unnecessary data produced by the task.
163163

164164
*Example: If the first task returns a large dataset, a filter can be applied to retain only the relevant results needed for subsequent tasks.*
165165

166166
4. **Filter Last Task Input**
167-
Before the last task in the workflow executes, its input data can be filtered to ensure it receives only the necessary information. This step is crucial for ensuring that the final task has all the required data to complete the workflow successfully.
167+
Before the last task in the workflow executes, its input data can be filtered to ensure it receives only the necessary information. This can be done using the task's `input.from` expression. It evaluates on the filtered workflow input and defaults to the identity expression which leaves the input unchanged. The result of this expression will be set as the `$input` runtime expression argument and be passed to the task. Any runtime expressions used within the task definition will be evaluated using this filtered input. This step is crucial for ensuring that the final task has all the required data to complete the workflow successfully.
168168

169169
*Example: If the last task involves generating a report, the input filter can ensure that only the data required for the report generation is passed to the task.*
170170

171171
5. **Filter Last Task Output**
172-
After the last task completes, its output can be filtered before it is considered as the workflow output. This ensures that the workflow produces a clean and relevant output, free from any extraneous data that might have been generated during the task execution.
172+
After the last task completes, its output can be filtered before it is considered as the workflow output. Filtering is performed using the `output.as` runtime expression. It evaluates on the raw task output and defaults to the identity expression which leaves the output unchanged. Its result will be passes to the workflow `output.as` runtime expression. This ensures that the workflow produces a clean and relevant output, free from any extraneous data that might have been generated during the task execution.
173173

174174
*Example: If the last task outputs various statistics, a filter can be applied to retain only the key metrics that are relevant to the stakeholders.*
175175

176176
6. **Filter Workflow Output**
177-
Finally, the overall workflow output can be filtered before it is returned to the caller or stored. This step ensures that the final output of the workflow is concise and relevant, containing only the necessary information that needs to be communicated or recorded.
177+
Finally, the overall workflow output can be filtered before it is returned to the caller or stored. Filtering is performed using the `output.as` runtime expression. It evaluates on the last task's output and defaults to the identity expression which leaves the output unchanged. This step ensures that the final output of the workflow is concise and relevant, containing only the necessary information that needs to be communicated or recorded.
178178

179179
*Example: If the workflow's final output is a summary report, a filter can ensure that the report contains only the most important summaries and conclusions, excluding any intermediate data.*
180180

181181
By applying filters at these strategic points, Serverless Workflow DSL ensures that data flows through the workflow in a controlled and efficient manner, maintaining clarity and relevance at each stage of execution. This approach helps in managing complex workflows and ensures that each task operates with the precise data it requires, leading to more predictable and reliable workflow outcomes.
182182

183+
Visually this can be represented as follows:
184+
185+
```mermaid
186+
flowchart TD
187+
188+
initial_context_arg([<code>$context</code>])
189+
context_arg([<code>$context</code>])
190+
input_arg([<code>$input</code>])
191+
192+
workflow_raw_input{{Raw Workflow Input}}
193+
workflow_input_from[Workflow: <code>input.from</code>]
194+
workflow_filtered_input{{Filtered Workflow Input}}
195+
196+
task_raw_input{{Raw Task Input}}
197+
task_input_from[Task: <code>input.from</code>]
198+
task_filtered_input{{Filtered Task Input}}
199+
task_definition[Task definition]
200+
task_raw_output{{Raw Task output}}
201+
task_output_as[Task: <code>output.as</code>]
202+
task_filtered_output{{Filtered Task output}}
203+
task_export_as[Task: <code>export.as</code>]
204+
205+
workflow_raw_output{{Raw Workflow Output}}
206+
workflow_output_as[Workflow: <code>output.as</code>]
207+
workflow_filtered_output{{Filtered Workflow Output}}
208+
209+
workflow_raw_input --> workflow_input_from
210+
workflow_input_from -- Produces --> workflow_filtered_input
211+
workflow_filtered_input -- Set as --> initial_context_arg
212+
workflow_filtered_input -- Passed to --> task_raw_input
213+
214+
subgraph Task
215+
216+
task_raw_input -- Passed to --> task_input_from
217+
task_input_from -- Produces --> task_filtered_input
218+
task_filtered_input -- Set as --> input_arg
219+
task_filtered_input -- Passed to --> task_definition
220+
221+
task_definition -- Execution produces --> task_raw_output
222+
task_raw_output -- Passed to --> task_output_as
223+
task_output_as -- Produces --> task_filtered_output
224+
task_filtered_output -- Passed to --> task_export_as
225+
end
226+
227+
task_filtered_output -- Passed as raw input to --> next_task
228+
229+
subgraph next_task [Next Task]
230+
end
231+
232+
task_export_as -- Result set as --> context_arg
233+
234+
next_task -- Filtered output becomes --> workflow_raw_output
235+
workflow_raw_output -- Passed to --> workflow_output_as
236+
workflow_output_as -- Produces --> workflow_filtered_output
237+
```
238+
183239
### Runtime Expressions
184240

185241
Runtime expressions serve as dynamic elements that enable flexible and adaptable workflow behaviors. These expressions provide a means to evaluate conditions, transform data, and make decisions during the execution of workflows.

0 commit comments

Comments
 (0)