How to use Flow Variables

Is there any documentation/tutorial on how to using flow variable? Especially a guide in Python/R snippet?

I saw some flow variables used in sample workflows, but I am not quite clear about the basic concepts and general procedures of using it.

Thanks!

Does this wiki page help in the understanding?

Yes, definitely! Thanks aborg!

I read the wiki page about the flow variable, but the introduction to the basic usage of flow variables is still missing.

My questions are related to the basic usage of flow variables. I noticed that flow variables tabs are at at least two locations:

1. When config a node, e.g., File Reader, there is a "Flow Variables" tab. How does this link to the ports of flow variable? Is this for the input variable? Is there any doc for the items listed under this tab, such as "DataURL", "Quotes", etc.? Also for the items in the drop box "knime.workspace" ... what does it mean? How to fill in the text box after that?

2. After executing the node, the context menu shows the result table, such as "File Table" for "File Reader" node. There is a "Flow Variables" tab here as well. Is this the output variable of this node? I see "knime.workspace" as a variable name again here... sounds confusing: the variable name is a "workspace"? Or it means the variable is exported in the knime workspace?

I think if there is some tutorial or more detailed introduction on this topic would be much helpful. For python/R snippets, the use of flow variable could be very critical in many applications.

Thanks again for any help on this!

 

Hello,

For the first question: There is no documentation on the parameter keys (DataURL, Quotes ...), you can guess those from the other part of the configuration, documentation or from the source code. The flow variables in this regard a bit of second class citizens. You can use the drop-down comboboxes to override the values of a parameter from the values of a flow variable. The "knime.workspace" is a flow variable name, it contains the path of the workspace as a String (text). The text field can be used to name the value of a parameter, so that value can be used in other nodes with the parameter key specified in the text field.

Have you seen the Flow Variables... option in the context menu of the project (for example in the KNIME Explorer)? You can define flow variables also for the workflows, not just for loops and other constructs.

For the second question: Yes, you can check the current flow variable values in the output of the nodes. That can change in each iteration. The knime.workspace is a single flow variable name, not a separate for knime and workspace.

It also worth checking the KNIME TV youtube channel content. There is one, that is quite related to your question: Quickforms

Hope this helps. If you find useful, feel free to add to the wiki (and probably give some stars to make it easier to find it). If not, I am sure someone will give a better description.

Cheers, gabor

If you want to use the values of flow variables within an R/Python snippet of the community scripting plugins, you could use the following syntax:

FLOWVAR(name_of_the_flow_variable)

when executing the node, this expression would be replaced with the value of that flow variable.

Example for R snippet node; assuming you have a flow variable fv with value 5.3:

x <- FLOWVAR(fv)

would end up in R like:

x <- 5.3

---

x <- "FLOWVAR(fv)"

wound end up in R like:

x <- "5.3"

The function "FLOWVAR" works well in Python snippet, but not in R. 

in R, it should using the format below:

$${Sknime.workspace}$$

The "S" before the variable name indicates data type.

 

It is also strange that I cannot get the flow variable "knime.workspace" using FLOWVAR in Python snippet.

for example, in the code below:

filename=r"FLOWVAR(Location)"
iter=FLOWVAR(currentIteration)
ws=r"FLOWVAR(knime.workspace)"

Both variables "filename", "iter" are just fine, but it complains the ws with the following error:

ERROR     Python Snippet                     Execute failed: Incorrect use flow variables. Correct example: FLOWVAR(treatment)