I have a Knime workflow that works perfectly fine through the GUI.
But when i do a command line execution, I keep getting the exit code 4 error:
This is my command line execution code:
knime -nosave -reset -application org.knime.product.KNIME_BATCH_APPLICATION -workflowDir=“C:\DATA\knime-workspace\FG_file_consumption_check”
I understand that Exit code 4 means there was an error during execution.
This is my original KNIME workflow:
By process of elimination, I rand the command line script after removing each node 1 by 1 from the end. I found that if I remove the R nodes then it executes successfully.
Is there any way to make the command line execution work with the R nodes? I’m trying to automate the execution, and I don’t want to keep opening KNIME manually and executing the workflow.
Any insight would be appreciated!
So I found out that its due to me calliing these libraries in my R code:
df <- knime.in
df$PHX_lot_id <- as.character(df$PHX_lot_id)
df$fg_lot_id <- as.character(df$fg_lot_id)
df$check <- ifelse(df$PHX_lot_id==df$fg_lot_id, "yes","no")
df1<-df %>% filter(check=="no")
If I try just executing without the libraries by taking converting the table to an R dataframe and back to a table again, its fine. So its not the R node per say, but Knime trying to call R libraries from the command line execution.
has anyone done this before?
@thentangler these things come to my mind.
You should check if you can do these transformations in knime so you would not need to use R.
Then you could try and use R thru
Miniconda and Conda Environment Propagation.
Then you might want to check a complete log file to see what is going on.
Also there are hints that this might be a thing about the lubridate package specifically.
I thought about a few things. Have you tried to execute the lines before this one just from within the R Snippet. Does this also not recognise the lubridate package?
What is the purpose of days(1) - is there a function to substitute that?
Then your batch seems to start from a path with blanks and brackets in the path name. Have you tried to move it to a simpler path like c:\knime_wf\my_wf without any special characters.
The R code I showed was just the first few lines that i truncated for testing. The actual R code is a bit longer. If I were to convert it to KNIME it would blow up the flow and make it very complicated.
Could you advise where I can find the complete log file that is generated when I execute in batch mode?
@thentangler I do not have a consitant guide how to obtain the batch log. You should check out some threads in the forum about that.
Currently I would assume the problem might be with the R lubridate library. What
version of R are you using?
You could try and use the
community R nodes, but that would mean you have to have R with Rserve running when knime is being started. Never tried that with a batch system.
To use the community R source node you will have to start the RServe from R itself. Like this (you will have to have Rserve and RSclient installed):
Rserve(port = 6311, debug = FALSE, args = “–vanilla”)
# start the RServe(er)
rsc <- RSconnect(port = 6311)
# shutdown the server after you used it
And you will have to set the preferences