How to know when the workflow is running in batch mode or interactive mode

I have a workflow that I run both in batch mode and interactively. The workflow should perform some additional tasks when in batch mode, so I placed a FLOW VARIABLE IF SWITCH at this point of the workflow. To determine if I am in batch mode or not, I use a Java Snippet to check whether a variable passed in the batch command exists (using flowVariableExists). If so, then I'm in batch mode.

So I run interactively and worked fine. Then I run in batch mode and also worked as expected. The third time, I opened the application to run it interactively, but all the variables resulting from the previous run (batch mode) had been stored. Hence, my IF did not work because the flowVariablesExists test resulted positive.

My question is: is there a simpler way to figure out whether this is a batch execution or not? 

Thanks

Hi robvdo, 

You can change the previous value of a flow variable providing a new value within the command. 

Please refer to the following line at https://www.knime.com/faq#q12: 

It's also possible to change the configuration of the workflow through workflow variables. If a variable is defined for a workflow, you can use it in batch mode by referring to it using a comma separated triplet to specify the name, value and type like this:

    -workflow.variable=my_integer,5,int

 

Best,

Anna

Hi Anna,

Thanks for the input. However, if I got your suggestion right, it did not work for me. What I'm doing is passing a variable using the format you mentioned, like this:

-workflow.variable=batch_mode,1,int

What happens is, after running the workflow once in batch mode, when I start it again in interactive mode the variable "batch_mode" is already set to "1".  And it does not help to reset it to "0" at some point of the workflow because this only affect the value of the variable from that node onwards, i.e. it will still be "1" at the IF node.

Best