Hello, today I want to teach you about how to Automate your KNIME applications in batch mode.

This is the ability to kick off the scripts, workflows, prep and blend, & effectively automate your KNIME applications!

When following this blog, also check out https://www.knime.com/faq#q12 FAQ on KNIME.

To begin the blog, lets start with the solution that worked for me more than once!

The code to use batch mode on a mac, begin automating your knime apps

The code shared below can be used in your terminal on your macbook and will help you automatically run your workflows.

You will need to change the directory in the beginning based on the correct directories for your computer or “environment.”

I’m using a mac, this is where the KNIME executable is located for me and that’s my workflow directory.

/Applications/KNIME\ 4.1.0.app/Contents/MacOS/Knime -reset -nosplash -application org.knime.product.KNIME_BATCH_APPLICATION -workflowDir=”/Users/itylergarrett/knime-workspace4.1/CoronaVirus2″

Before we dive into the code, lets tour where /Contents/MacOS/Knime is located.

PRO TIP

Add –launcher.supressErrors after -nosplash to remove the pesky popup. More on this in the last paragraph of this blog. It would look like this; /Applications/KNIME\ 4.1.0.app/Contents/MacOS/Knime -reset -nosplash –launcher.suppressErrors -applicationĀ  org.knime.product.KNIME_BATCH_APPLICATION -workflowDir=”/Users/dev3lop/knime-workspace/CoronaVirus7″

Finding the contents folder in your knime application

When using a mac, be sure to note your Knime file is built within your applications. Mac is explained in this tutorial, windows is going to be similar to the MAC and well documented on the KNIME forums.

Here’s a screenshot of your applications on your mac.

Bottom of app folder, open folder.

Or on the bottom right, click open as folder.

Navigate to the KNIME you need to utilize.

right click, show package contents

Here you will find logs, more code, and knime executable.

Expanded in this screenshot below.

This is the directory of the KNIME Executable on a mac.

You can build your directories accordingly, however MAC will likely be identical to my directories in my code. With some variations on your version numbers. Knowing where this file is located is important to accessing and launching this KNIME file.

How the code works?

For sake of simplicity, I will paste the code again.

/Applications/KNIME\ 4.1.0.app/Contents/MacOS/Knime -reset -nosplash -application org.knime.product.KNIME_BATCH_APPLICATION -workflowDir=”/Users/itylergarrett/knime-workspace4.1/CoronaVirus2″

The code above can be broken into 3 major parts.

  1. The location of Knime executable.
  2. The code that makes a knime workflow start.
  3. The directory to your workspace & workflow.

The location of the knime executable.

Finding the location of the knime executable is only challenging on a Mac, so if you’re a windows user, have no fear.

/Applications/KNIME\ 4.1.0.app/Contents/MacOS/Knime

This is the location of the KNIME app for my 4.1.0 installation. Make changes as you see fit.

The code that makes a knime workflow start.

Now, let’s discuss the code that makes a workflow do magic.

Knime -reset -nosplash -application org.knime.product.KNIME_BATCH_APPLICATION

From my testing, -reset in the beginning is important. You want to reset the workflow when it starts.

Reseting the workflow is a common request in KNIME. Please keep these settings the same. If you desire to dig deeper, check out their FAQ page.

The directory to your workspace & workflow.

Your directory to your workspace & workflow is a good thing to understand about your KNIME products.

I’m going to share my code, and how to get the code in your KNIME product with a native feature.

-workflowDir=”/Users/itylergarrett/knime-workspace4.1/CoronaVirus2″

Knowing where these workflows are means you can begin automating them on a schedule!

Open your KNIME product, navigate to your workflows, right click the workflow.

Highlight Copy Location, click local path.

Paste this into your ‘workflow directory’ & rinse and repeat as necessary.

Open your terminal and test.

To begin automating with KNIME, test your CURL to your KNIME application. Make sure it works end to end.

This code is a “request” being sent to your application to start your workflow AKA a curl.

/Applications/KNIME\ 4.1.0.app/Contents/MacOS/Knime -reset -nosplash -application  org.knime.product.KNIME_BATCH_APPLICATION -workflowDir="/Users/itylergarrett/knime-workspace4.1/CoronaVirus2"

Now with terminal open, paste your KNIME automation code into the terminal.

here’s a terminal…

Paste the code into the terminal.

Knime automation code.

Turn off your KNIME analytics platform, or at least the workspace.

Hit enter and sit back.

If it works, you will see your tools flashing on the terminal feedback.

a screenshot of knime analytics platform, used to explain success when automating the workflow, it shows this display of information and nodes used in your knime process.
looks crazy, but it’s working. knime is automating my workflow.

If you get errors, troubleshoot the errors. If you keep getting errors, give yourself an easier task of writing a file to your desktop and see if that file refreshes when running your KNIME automation in batch mode.

Remove the pop up after you automate a task in KNIME batch mode

Removing the popup allows you to “leave it and sleep”… Here’s a post from one of the knime team members Scott, on a forum post on knime.com.

  1. Use the –launcher.suppressErrors option, and remove the -noexit option, on the original workflow in batch mode. Even if the workflow encounters the Fail In Execution node, the popup error dialog will not appear. This has the downside of suppressing any other errors that may occur, though.
  2. Create a separate workflow, and use the Call Local Workflow node (see attached example). This node will execute successfully even if it encounters an error in the workflow that it calls.