Skip to content

Commit bd04826

Browse files
authored
Merge branch 'main' into feature/docu-chapter-fairification-with-CM-CMEM-8258
2 parents 91dd971 + 9ad98ab commit bd04826

3 files changed

Lines changed: 57 additions & 14 deletions

File tree

‎docs/build/.pages‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ nav:
1818
- Connect to Snowflake: snowflake-tutorial
1919
- Active learning: active-learning
2020
- Link Intrusion Detection Systems to Open-Source INTelligence: tutorial-how-to-link-ids-to-osint
21-
- Project and Global Variables: variables
21+
- Variables: variables
2222
- Evaluate Template Operator: evaluate-template
2323
- Build Knowledge Graphs from Kafka Topics: kafka-consumer
2424
- Spark: spark

‎docs/build/variables/index.md‎

Lines changed: 55 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ tags:
44
- KnowledgeGraph
55
- Variables
66
---
7-
# Project and Global Build Variables
7+
# Build Variables
88

99
## Introduction
1010

@@ -147,29 +147,64 @@ They are referenced with the `execution.` prefix, for example `{{execution.myVar
147147

148148
Tasks (including workflows) have an **Execution variables** widget in its configuration view, managed in the same way as project variables:
149149
click on :eccenca-item-add-artefact: to add a variable and provide a name, value and description in the same dialog used for project variables.
150-
When an execution is started, these variables provide the default values of the execution scope.
151-
For a workflow run, the defaults come from the **workflow itself** — the execution variables of the operators and datasets inside the workflow are not used during a workflow run; they apply when such a task is executed directly.
150+
The widget is offered on every task.
151+
Its values take effect when that task is the one being executed, where they provide the defaults of the execution scope.
152+
A task that only runs as part of a workflow receives its values from the enclosing workflow, so its own widget stays unused.
153+
154+
### Where Execution Variables Resolve
155+
156+
Project and global variables are resolved when a task is saved, which is why they can be used in any parameter field that offers the **{#}** toggle.
157+
An execution variable only has a value while a run is in progress.
158+
It therefore takes effect in parameters that are evaluated once per execution, such as the template of the **Evaluate template** workflow operator and of the **Evaluate template** transformer.
159+
A reference such as `{{execution.myVariable}}` resolves there to the value of the current run.
160+
161+
A template in an ordinary parameter field behaves differently.
162+
It is resolved when the task is loaded, and the result is kept until the task is loaded again.
163+
An execution variable referenced in such a field does not change the result from run to run and is not a way to parameterize a plugin per execution.
164+
To give a plugin parameter a value that differs per run, use the [config port](../workflows/index.md#workflow-reconfiguration) of the operator.
165+
166+
### Determining the Variables of a Run
167+
168+
The set of execution variables of a single run is built in three steps:
169+
170+
1. The defaults come from the task that is executed.
171+
For a workflow run these are the execution variables of the workflow itself.
172+
The execution variables of the operators, datasets and sub-workflows inside the workflow are not read; they apply when such a task is executed directly.
173+
2. Values given at the start of the run replace defaults of the same name.
174+
A value given at the start of a run also defines a variable that is not declared on any task.
175+
3. **Set execution variable** operators create or replace entries while the run proceeds.
176+
177+
The resulting set is used by every task of the run, including sub-workflows.
178+
Two consequences follow from this:
179+
180+
- A variable that a task or a sub-workflow inside a workflow references must be defined on the executed workflow itself, or be given at the start of the run.
181+
There is no fallback to the definition on the inner task.
182+
- Variable names form a single flat set.
183+
The same name used by two tasks always receives the same value; different values for the same name in different tasks are not possible.
152184

153185
`{{execution.<name>}}` resolves only from the execution scope — there is no fallback to other scopes.
154186
If `<name>` has not been defined as a default, provided or set for the run, the reference cannot be resolved and the execution fails with an error.
155187
To base a default on a project or global variable, give the execution variable a *template* (e.g. `{{project.baseUrl}}/api`); it is resolved when the variable is saved, and the resulting value is used for each run.
156188

157-
!!! note
158-
159-
Execution variables are resolved in templates that are evaluated **during execution**, for example the template of the template operator.
160-
161189
!!! note
162190

163191
The execution variables of a task are stored together with the task (their default values, not any run-specific overrides).
164192
When the task or its project is exported, they are exported as well.
165193
The values of a running execution are never persisted and are not shared between runs.
166194

167-
Besides the defaults defined in the widget, there are two further ways to supply execution variables for a run:
195+
### Passing Execution Variables When Starting a Workflow
196+
197+
When a workflow execution is triggered via the REST API, execution variables are provided in one of two ways.
198+
199+
The first is a query parameter per variable, with the reserved prefix `variable-`:
168200

169-
### Passing execution variables when starting a workflow
201+
```text
202+
?variable-testVar=World
203+
```
204+
205+
This form works for every endpoint, request content type and request method, including `GET`.
170206

171-
When a workflow execution is triggered via the REST API, execution variables can be provided in the JSON request body under the `executionVariables` key as a simple name/value map.
172-
For example, executing a workflow with a single execution variable `testVar`:
207+
The second is a name/value map under the `executionVariables` key of a JSON request body:
173208

174209
```json
175210
{
@@ -179,10 +214,18 @@ For example, executing a workflow with a single execution variable `testVar`:
179214
}
180215
```
181216

217+
Values are strings in both forms.
218+
The request body form is not available on endpoints that accept a replaceable input dataset, because the body of such a request carries the data for that dataset.
219+
182220
Each entry is set in the `execution` scope — overriding a default of the same name defined on the workflow — and can be referenced anywhere in the workflow as `{{execution.<name>}}`.
183221
For instance, an operator configured with the template `{{value}} {{execution.testVar}}` would resolve `execution.testVar` to `World` for that run.
184222

185-
### Setting execution variables during a workflow run
223+
Querying `GET /api/core/variableTemplate/variables` for a workflow with the `transitive` flag returns every variable that has to be set for a run of that workflow:
224+
the execution variables of the workflow itself together with those of every task and sub-workflow that may take part in the execution.
225+
If the same name is defined on several levels, the definition of the enclosing workflow is returned, which is the one that applies during the run.
226+
These endpoints are described in the [DataIntegration API documentation](../../develop/dataintegration-apis/index.md).
227+
228+
### Setting Execution Variables During a Workflow Run
186229

187230
Execution variables can also be created or updated while a workflow is running.
188231
Two operators in the *Variables* category support this:

‎nav.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ nav:
474474
- build/tutorial-how-to-link-ids-to-osint/link-IDS-event-to-KG/index.md
475475
- link IDS event to KG via cmem:
476476
- build/tutorial-how-to-link-ids-to-osint/link-IDS-event-to-KG-via-cmem/index.md
477-
- Project and Global Variables:
477+
- Variables:
478478
- build/variables/index.md
479479
- Evaluate Template Operator:
480480
- build/evaluate-template/index.md

0 commit comments

Comments
 (0)