Skip to content

Commit de41643

Browse files
refactor: use transform instead of filter
Signed-off-by: Matthias Pichler <[email protected]>
1 parent 2a36aae commit de41643

File tree

2 files changed

+44
-44
lines changed

2 files changed

+44
-44
lines changed

dsl-reference.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1491,7 +1491,7 @@ from: .order.pet
14911491

14921492
### Output
14931493

1494-
Documents the structure - and optionally configures the filtering of - workflow/task output data.
1494+
Documents the structure - and optionally configures the transformations of - workflow/task output data.
14951495

14961496
It's crucial for authors to document the schema of output data whenever feasible. This documentation empowers consuming applications to provide contextual auto-suggestions when handling runtime expressions.
14971497

dsl.md

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -146,39 +146,39 @@ Once the task has been executed, different things can happen:
146146

147147
In Serverless Workflow DSL, data flow management is crucial to ensure that the right data is passed between tasks and to the workflow itself.
148148

149-
Here's how data flows through a workflow based on various filtering stages:
149+
Here's how data flows through a workflow based on various transformation stages:
150150

151-
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 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.
151+
1. **Transform Workflow Input**
152+
Before the workflow starts, the input data provided to the workflow can be transformed to ensure only relevant data in the expected format 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

154-
*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.*
154+
*Example: If the workflow receives a JSON object as input, a transformation can be applied to remove unnecessary fields and retain only those that are required for the workflow's execution.*
155155

156-
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. 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.
156+
2. **Transform First Task Input**
157+
The input data for the first task can be transformed 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 transformed 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 transformed input.
158158

159-
*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.*
159+
*Example: If the first task is a function call that only needs a subset of the workflow input, a transformation can be applied to provide only those fields needed for the function to execute.*
160160

161-
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. 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.
161+
3. **Transform First Task Output**
162+
After the first task completes, its output can be transformed before passing it to the next task or storing it in the workflow context. Transformations are applied 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

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

166-
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 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.
166+
4. **Transform Last Task Input**
167+
Before the last task in the workflow executes, its input data can be transformed to ensure it receives only the necessary information. This can be done using the task's `input.from` expression. It evaluates on the transformed 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 transformed input. This step is crucial for ensuring that the final task has all the required data to complete the workflow successfully.
168168

169-
*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.*
169+
*Example: If the last task involves generating a report, the input transformation can ensure that only the data required for the report generation is passed to the task.*
170170

171-
5. **Filter Last Task Output**
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.
171+
5. **Transform Last Task Output**
172+
After the last task completes, its output can be transformed before it is considered as the workflow output. Transformations are applied 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

174-
*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.*
174+
*Example: If the last task outputs various statistics, a transformation can be applied to retain only the key metrics that are relevant to the stakeholders.*
175175

176-
6. **Filter Workflow Output**
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.
176+
6. **Transform Workflow Output**
177+
Finally, the overall workflow output can be transformed before it is returned to the caller or stored. Transformations are applied 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

179-
*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.*
179+
*Example: If the workflow's final output is a summary report, a transformation can ensure that the report contains only the most important summaries and conclusions, excluding any intermediate data.*
180180

181-
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.
181+
By applying transformations 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

183183
Visually this can be represented as follows:
184184

@@ -191,49 +191,49 @@ flowchart TD
191191
192192
workflow_raw_input{{Raw Workflow Input}}
193193
workflow_input_from[Workflow: <code>input.from</code>]
194-
workflow_filtered_input{{Filtered Workflow Input}}
194+
workflow_transformed_input{{Transformed Workflow Input}}
195195
196196
task_raw_input{{Raw Task Input}}
197197
task_input_from[Task: <code>input.from</code>]
198-
task_filtered_input{{Filtered Task Input}}
198+
task_transformed_input{{Transformed Task Input}}
199199
task_definition[Task definition]
200200
task_raw_output{{Raw Task output}}
201201
task_output_as[Task: <code>output.as</code>]
202-
task_filtered_output{{Filtered Task output}}
202+
task_transformed_output{{Transformed Task output}}
203203
task_export_as[Task: <code>export.as</code>]
204204
205205
workflow_raw_output{{Raw Workflow Output}}
206206
workflow_output_as[Workflow: <code>output.as</code>]
207-
workflow_filtered_output{{Filtered Workflow Output}}
207+
workflow_transformed_output{{Transformed Workflow Output}}
208208
209209
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
210+
workflow_input_from -- Produces --> workflow_transformed_input
211+
workflow_transformed_input -- Set as --> initial_context_arg
212+
workflow_transformed_input -- Passed to --> task_raw_input
213213
214214
subgraph Task
215215
216216
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
217+
task_input_from -- Produces --> task_transformed_input
218+
task_transformed_input -- Set as --> input_arg
219+
task_transformed_input -- Passed to --> task_definition
220220
221221
task_definition -- Execution produces --> task_raw_output
222222
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
223+
task_output_as -- Produces --> task_transformed_output
224+
task_transformed_output -- Passed to --> task_export_as
225225
end
226226
227-
task_filtered_output -- Passed as raw input to --> next_task
227+
task_transformed_output -- Passed as raw input to --> next_task
228228
229229
subgraph next_task [Next Task]
230230
end
231231
232232
task_export_as -- Result set as --> context_arg
233233
234-
next_task -- Filtered output becomes --> workflow_raw_output
234+
next_task -- Transformed output becomes --> workflow_raw_output
235235
workflow_raw_output -- Passed to --> workflow_output_as
236-
workflow_output_as -- Produces --> workflow_filtered_output
236+
workflow_output_as -- Produces --> workflow_transformed_output
237237
```
238238

239239
### Runtime Expressions
@@ -259,7 +259,7 @@ When the evaluation of an expression fails, runtimes **must** raise an error wit
259259
| Name | Type | Description |
260260
|:-----|:----:|:------------|
261261
| context | `map` | The task's context data. |
262-
| input | `any` | The task's filtered input. |
262+
| input | `any` | The task's transformed input. |
263263
| secrets | `map` | A key/value map of the workflow secrets.<br>To avoid unintentional bleeding, secrets can only be used in the `input.from` runtime expression. |
264264
| task | [`taskDescriptor`](#task-descriptor) | Describes the current task. |
265265
| workflow | [`workflowDescritor`](#workflow-descriptor) | Describes the current workflow. |
@@ -268,13 +268,13 @@ The following table shows which arguments are available for each runtime express
268268

269269
| Runtime Expression | Evaluated on | Produces | `$context` | `$input` | `$secrets` | `$task` | `$workflow` |
270270
|:-------------------|:---------:|:---------:|:---------:|:-------:|:---------:|:-------:|:----------:|
271-
| Workflow `input.from` | Raw workflow input | Filtered workflow input | | || ||
272-
| Task `input.from` | Raw task input (i.e. filtered workflow input for first task, filtered output from previous task otherwise) | Filtered task input || ||||
273-
| Task `if` | Filtered task input | ||||||
274-
| Task definition | Filtered task input | ||||||
275-
| Task `output.as` | Raw task output | Filtered task output ||||||
276-
| Task `export.as` | Filtered task output | `$context` ||||||
277-
| Workflow `output.as` | Last task's filtered output | Filtered workflow output || || ||
271+
| Workflow `input.from` | Raw workflow input | Transformed workflow input | | || ||
272+
| Task `input.from` | Raw task input (i.e. transformed workflow input for first task, transformed output from previous task otherwise) | Transformed task input || ||||
273+
| Task `if` | Transformed task input | ||||||
274+
| Task definition | Transformed task input | ||||||
275+
| Task `output.as` | Raw task output | Transformed task output ||||||
276+
| Task `export.as` | Transformed task output | `$context` ||||||
277+
| Workflow `output.as` | Last task's transformed output | Transformed workflow output || || ||
278278

279279
### Fault Tolerance
280280

0 commit comments

Comments
 (0)