decent documentation for command line execution with variables?

Coming from the world of python, I run python scripts with arguments (variables) from the command line. Is there something similar for KNIME? For instance, if I have a workflow that takes a CSV file as an input and outputs another csv file, but I want to set the path to the respective files. In python it would be something like python mypythonscript.py -i path/to/input.csv -o path/to/output.csv. Basically, I can’t find any decent documentation about running KNIME from the command line - specifically with multiple variables. Can anyone point me in the right direction?

2 Likes

Here is what I figured out (True, this information is outlined in the FAQs, there are some finer points that need better explaining)

this blogpost was extremely helpful (Batch Execution of KNIME Workflows, Part 2 –)

=============================================================

  1. First define your workflow variables that you will call/modify from the command line: with your workflow of interest open, right click on your workflow of interest from within the KNIME Explorer panel. Then in the middle of all the options, you will find Workflow Variables.... Click this. Another dialogue window will open up called Workflow Variable Administration. Then click Add. Here you will give your variable a name, a type, and default value. You then have to configure your workflow configuring to utilize this globally defined variable but I won’t go into that here.

  2. Call your workflow from command line using the default variable settings:
    knime --launcher.suppressErrors -nosplash -nosave -reset -application org.knime.product.KNIME_BATCH_APPLICATION -workflowFile="path/to/your/file.knwf"

  3. Call your workflow from command line overriding the default variable settings:
    This is here the magic happens. you need an additional argument -workflow.variable. The syntax for this argument is -workflow.variable=name,value,type. you add as many -workflow.variable arguments as you need/have defined. Here is an example.

    knime --launcher.suppressErrors -nosplash -nosave -reset -application org.knime.product.KNIME_BATCH_APPLICATION -workflowFile="path/to/your/file.knwf" -workflow.variable=myvariable1,999,int -workflow.variable=myvariable2,foo,String

Some additional notes:

  1. you can swap the file -workflowFile for directory -workflowDir="path/to/directory"
  2. all the other arguments after knime and before your paths etc are just settings I click. it doesn’t open the GUI, it doesn’t save, the workflow is rest, and it closes your terminal upon completion of the workflow
  3. a lot of stuff will be printed to your terminal. in my experience when you see ---Registering Weka Editors--- that means you did it correctly!

Good luck! Please reach out with you have questions or issues.

6 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.