Icon

KNIME_​Simple_​Batch_​Windows

Simple KNIME Batch processing on Windows

Simple KNIME Batch processing on Windows

This workflow is being called thru a KNIME batch process

KNIME Batch Processing on Windows and MacOS
https://medium.com/p/caacde067bd0


Workflow Variables are initially set and will be filled by the batch scriptcalling the KNIME workflow @echo offREM This batch file runs a KNIME workflow in batch mode and logs the output.REM Medium Blog - KNIME Batch Processing on Windows and MacOSREM https://medium.com/p/caacde067bd0set CURRENT_DATE=%DATE%set CURRENT_TIME=%TIME%echo Current Date: %CURRENT_DATE%echo Current Time: %CURRENT_TIME%REM Get the current date and time in a format suitable for a filenameREM Example format: YYYYMMDD-HHMMSSREM Depending on your locale, you might need to adjust the order of %%i, %%j, %%kfor /f "tokens=1-3 delims=/" %%a in ('echo %CURRENT_DATE%') do set DATESTR=%%c%%a%%bfor /f "tokens=1-3 delims=:." %%i in ('echo %CURRENT_TIME%') do set TIMESTR=%%i%%j%%kfor /f "tokens=1-3 delims=:." %%i in ('echo %CURRENT_TIME%') do ( set hours=%%i set minutes=%%j set seconds=%%k)REM check how the time variables will appearecho hours=%hours%echo minutes=%minutes%echo seconds=%seconds%echo DATESTR=%DATESTR%echo TIMESTR=%TIMESTR%REM Combine them to form a timestampset TIMESTAMP=%DATESTR%-%TIMESTR%REM Set the path to your KNIME executable (Windows)REM %USERNAME% is an automatic Windows variableset KNIME_PATH=C:\Users\%USERNAME%\software\knime_4.7.0\knime.exeREM Set the path to your workflow directoryset WORKFLOW_DIR=C:\Users\%USERNAME%\knime-workspace\KNIME_Batch\KNIME_Simple_Batch_WindowsREM Set the path where you want to save the log fileset LOG_FILE_PATH=C:\Users\%USERNAME%\knime-workspace\KNIME_Batch\data\knime_log_%TIMESTAMP%.txtREM Set a string variable to pass to the workflowset STRING_VAR_NAME=var_data_pathset STRING_VAR_VALUE=C:\Users\%USERNAME%\knime-workspace\KNIME_Batch\data\REM Proxy settingsset PROXY_HOST=proxy.my-company.orgset PROXY_PORT=8080REM Run KNIME in batch mode with the specified workflow, string variable, proxy settings, and save the log output"%KNIME_PATH%" -reset -nosave -nosplash -application org.knime.product.KNIME_BATCH_APPLICATION -workflowDir="%WORKFLOW_DIR%" ^-workflow.variable=%STRING_VAR_NAME%,%STRING_VAR_VALUE%,String ^-workflow.variable=CURRENT_DATE,%DATESTR%,String ^-workflow.variable=v_hours,%hours%,int ^-workflow.variable=v_minutes,%minutes%,int ^-workflow.variable=v_seconds,"%seconds%",String ^-vmargs -Dhttp.proxyHost=%PROXY_HOST% -Dhttp.proxyPort=%PROXY_PORT% -Dhttps.proxyHost=%PROXY_HOST% -Dhttps.proxyPort=%PROXY_PORT% >"%LOG_FILE_PATH%" 2>&1REM concept of workfow.variables seems to be considered "old technology" - so be awareREM https://forum.knime.com/t/how-to-put-a-global-variable-in-a-workflow/45723/6?u=mlauber71REM Optional: Add a line to indicate completion and log file locationecho Workflow execution complete. Log file saved to "%LOG_FILE_PATH%".REM Pause the script to see the output when running interactively (optional)REM pause This complicated proceeding tries to get the date and time from the CMD/batch script. It has been done with german time so you might have to adapt that. Or you just go with creating the current time inside the KNIME workflow Simple KNIME Batch processing on WindowsThis workflow is being called thru a KNIME batch processKNIME Batch Processing on Windows and MacOShttps://medium.com/p/caacde067bd0 Content of the "knime_simple_batch.cmd" file in the ../script/ folder of thed workflow group () current timetrain.tableRead the table fromthe pathvar_file_pathreturn $${Svar_data_path}$$ + "train.table";configure the file path with the workflow variablevar_file_pathvar_excel_pathfile_pathcollect dummy dataCURRENT_DATECURRENT_TIMECURRENT_DATEv_hoursv_minutesv_secondsv_seconds_Arr[0]timetimetimeHHmmsscurrent_datecurrent_timecurrent_datecurrent_timeHH:mm:sscurrent_date_time*_Arr*v_seconds_Arr[0]Create Date&TimeRange construct filename Extract Date&TimeFields Table Reader Java EditVariable (simple) String to Path(Variable) Excel Writer ConstantValue Column Table Creator ConstantValue Column ConstantValue Column String to Date&Time ConstantValue Column ConstantValue Column ConstantValue Column Cell Splitter Math Formula Number ToString (PMML) String to Date&Time Table Rowto Variable ConstantValue Column ConstantValue Column String to Date&Time String to Date&Time Modify Time String ToNumber (PMML) Workflow Variables are initially set and will be filled by the batch scriptcalling the KNIME workflow @echo offREM This batch file runs a KNIME workflow in batch mode and logs the output.REM Medium Blog - KNIME Batch Processing on Windows and MacOSREM https://medium.com/p/caacde067bd0set CURRENT_DATE=%DATE%set CURRENT_TIME=%TIME%echo Current Date: %CURRENT_DATE%echo Current Time: %CURRENT_TIME%REM Get the current date and time in a format suitable for a filenameREM Example format: YYYYMMDD-HHMMSSREM Depending on your locale, you might need to adjust the order of %%i, %%j, %%kfor /f "tokens=1-3 delims=/" %%a in ('echo %CURRENT_DATE%') do set DATESTR=%%c%%a%%bfor /f "tokens=1-3 delims=:." %%i in ('echo %CURRENT_TIME%') do set TIMESTR=%%i%%j%%kfor /f "tokens=1-3 delims=:." %%i in ('echo %CURRENT_TIME%') do ( set hours=%%i set minutes=%%j set seconds=%%k)REM check how the time variables will appearecho hours=%hours%echo minutes=%minutes%echo seconds=%seconds%echo DATESTR=%DATESTR%echo TIMESTR=%TIMESTR%REM Combine them to form a timestampset TIMESTAMP=%DATESTR%-%TIMESTR%REM Set the path to your KNIME executable (Windows)REM %USERNAME% is an automatic Windows variableset KNIME_PATH=C:\Users\%USERNAME%\software\knime_4.7.0\knime.exeREM Set the path to your workflow directoryset WORKFLOW_DIR=C:\Users\%USERNAME%\knime-workspace\KNIME_Batch\KNIME_Simple_Batch_WindowsREM Set the path where you want to save the log fileset LOG_FILE_PATH=C:\Users\%USERNAME%\knime-workspace\KNIME_Batch\data\knime_log_%TIMESTAMP%.txtREM Set a string variable to pass to the workflowset STRING_VAR_NAME=var_data_pathset STRING_VAR_VALUE=C:\Users\%USERNAME%\knime-workspace\KNIME_Batch\data\REM Proxy settingsset PROXY_HOST=proxy.my-company.orgset PROXY_PORT=8080REM Run KNIME in batch mode with the specified workflow, string variable, proxy settings, and save the log output"%KNIME_PATH%" -reset -nosave -nosplash -application org.knime.product.KNIME_BATCH_APPLICATION -workflowDir="%WORKFLOW_DIR%" ^-workflow.variable=%STRING_VAR_NAME%,%STRING_VAR_VALUE%,String ^-workflow.variable=CURRENT_DATE,%DATESTR%,String ^-workflow.variable=v_hours,%hours%,int ^-workflow.variable=v_minutes,%minutes%,int ^-workflow.variable=v_seconds,"%seconds%",String ^-vmargs -Dhttp.proxyHost=%PROXY_HOST% -Dhttp.proxyPort=%PROXY_PORT% -Dhttps.proxyHost=%PROXY_HOST% -Dhttps.proxyPort=%PROXY_PORT% >"%LOG_FILE_PATH%" 2>&1REM concept of workfow.variables seems to be considered "old technology" - so be awareREM https://forum.knime.com/t/how-to-put-a-global-variable-in-a-workflow/45723/6?u=mlauber71REM Optional: Add a line to indicate completion and log file locationecho Workflow execution complete. Log file saved to "%LOG_FILE_PATH%".REM Pause the script to see the output when running interactively (optional)REM pause This complicated proceeding tries to get the date and time from the CMD/batch script. It has been done with german time so you might have to adapt that. Or you just go with creating the current time inside the KNIME workflow Simple KNIME Batch processing on WindowsThis workflow is being called thru a KNIME batch processKNIME Batch Processing on Windows and MacOShttps://medium.com/p/caacde067bd0 Content of the "knime_simple_batch.cmd" file in the ../script/ folder of thed workflow group () current timetrain.tableRead the table fromthe pathvar_file_pathreturn $${Svar_data_path}$$ + "train.table";configure the file path with the workflow variablevar_file_pathvar_excel_pathfile_pathcollect dummy dataCURRENT_DATECURRENT_TIMECURRENT_DATEv_hoursv_minutesv_secondsv_seconds_Arr[0]timetimetimeHHmmsscurrent_datecurrent_timecurrent_datecurrent_timeHH:mm:sscurrent_date_time*_Arr*v_seconds_Arr[0]Create Date&TimeRange construct filename Extract Date&TimeFields Table Reader Java EditVariable (simple) String to Path(Variable) Excel Writer ConstantValue Column Table Creator ConstantValue Column ConstantValue Column String to Date&Time ConstantValue Column ConstantValue Column ConstantValue Column Cell Splitter Math Formula Number ToString (PMML) String to Date&Time Table Rowto Variable ConstantValue Column ConstantValue Column String to Date&Time String to Date&Time Modify Time String ToNumber (PMML)

Nodes

Extensions

Links