Skip to content

Commit

Permalink
feat(docs): include output preview in the outputs doc (#1026)
Browse files Browse the repository at this point in the history
* feat(docs): include output preview in the outputs doc

* Apply suggestions from code review

---------

Co-authored-by: Anna Geller <anna.m.geller@gmail.com>
  • Loading branch information
shrutimantri and anna-geller authored Mar 11, 2024
1 parent ec58b30 commit 92494ba
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 3 deletions.
37 changes: 34 additions & 3 deletions content/docs/06.workflow-components/07.outputs.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ The expression `{{ outputs['produce-output'].value }}` references the previous t
In the example above, the **Return** task produces an output attribute `value`. Every task produces different output attributes. You can look at each task outputs documentation or use the **Outputs** tab of the **Executions** page to find out about specific task output attributes.
::

The **Outputs** tab will have the output for `produce-output` task. There is no output for `use-output` task as it only logs a message.

![task_outputs_example](/docs/workflow-components/outputs/task_outputs_example.png)

## Internal storage

Each task can store data in Kestra's internal storage. If an output attribute is stored in internal storage, the attribute will contain a URI that points to a file in the internal storage. This output attribute could be used by other tasks to access the stored data.
Expand All @@ -57,7 +61,7 @@ tasks:

- id: write-to-csv
type: io.kestra.plugin.serdes.csv.CsvWriter
from: "{{outputs['output-from-query'].uri}}"
from: "{{ outputs['output-from-query'].uri }}"
```
## Dynamic variables (Each tasks)
Expand All @@ -76,9 +80,13 @@ tasks:
tasks:
- id: inner
type: io.kestra.core.tasks.debugs.Return
format: "{{task.id}} > {{taskrun.value}} > {{taskrun.startDate}}"
format: "{{ task.id }} > {{ taskrun.value }} > {{ taskrun.startDate }}"
```

The **Outputs** tab would contain the output for each of the inner task.

![taskrun_value_example](/docs/workflow-components/outputs/taskrun_value_example.png)

### Loop over a list of JSON objects

On loop, the `value` is always a JSON string, so the `{{ taskrun.value }}` is the current element as JSON string. If you want to access properties, you need to use the [json function](../07.concepts/expression/04.function.md#json) to have a proper object and to access each property easily.
Expand Down Expand Up @@ -242,8 +250,31 @@ Note how the `outputs` are set twice within the `"{{outputs.subflow.outputs.fina
2. once to access the outputs of the subflow itself — specifically, the `final` output.
::

Here is what you will see in the Outputs tab of the **Executions** page in the parent flow:
Here is what you will see in the **Outputs** tab of the **Executions** page in the parent flow:

![subflow_output_parent](/docs/workflow-components/subflow_output_parent.png)

## Using Render Expression ##

You can evaluate the output further using the **Render Expression** functionality in the **Outputs** tab. Consider the following flow:

```yaml
id: json_values
namespace: dev
tasks:
- id: sample_json
type: io.kestra.core.tasks.debugs.Return
format: '{"data": [1, 2, 3]}'
```

When you run this flow, the **Outputs** tab will contain the output for the `sample_json` task, as shown below:

![json_values](/docs/workflow-components/outputs/json_values.png)

You can select the task from the drop-down menu. Here, we will select "sample_json" and click on **Render expression**:

![json_values_render_expression](/docs/workflow-components/outputs/json_values_render_expression.png)

You can now use pebble expressions and evaluate different expressions based on the output data to analyse it further.

![json_values_render_expression_sample](/docs/workflow-components/outputs/json_values_render_expression_sample.png)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 92494ba

Please sign in to comment.