Batch mode with JAR file

chris_mlchris_ml Member Posts: 17 Maven
edited November 2018 in Help
Hi,

I'd like to use RapidMiner in batch mode without the GUI.
With the bash script "scripts/rapidminer CONTROL.xml" this works
fine. However, I would prefer to use the shipped JAR file
from the "lib" directory "rapidminer.jar". Starting it with
"java -jar lib/rapidminer.jar CONTROL.xml" ends up in the
invocation of the GUI without executing the provided xml
file.

Is there a way to start RapidMiner in batch mode with
the JAR file? Or can the JAR file be adjusted to do so?

Greetings,
Chris

Answers

  • steffensteffen Member Posts: 347 Maven
    Hello

    Assuming that you are a linux guy...
    I am no bash expert, but did you take a look at the file "rapidminer"

    The interesting part is this one:

    BUILD="${RAPIDMINER_HOME}/build"
    RAPIDMINER_JAR="${RAPIDMINER_HOME}/lib/rapidminer.jar"
    RAPIDMINER_CLASSPATH=""

    if [ -d "${BUILD}" ] ; then
        RAPIDMINER_CLASSPATH=${BUILD}
    elif [ -f "${RAPIDMINER_JAR}" ] ; then
        RAPIDMINER_CLASSPATH=${RAPIDMINER_JAR}
    else
        echo "Neither ${BUILD} nor ${RAPIDMINER_JAR} was found."
        echo "Try 'ant build' or 'ant dist' first or check the value of RAPIDMINER_HOME!"
        exit 1
    fi
    To avoid using the build - directory (I do not know why you want to do this...) replace the if-condition with this assignment:

    RAPIDMINER_CLASSPATH=${RAPIDMINER_JAR}
    [glow=lightgreen,2,300]The final java command is at the bottom of the script[/glow] (as an inspiration for further changes).

    On windows (rapidminer.bat), these are the interesting lines:

    if exist "%RAPIDMINER_JAR%" set RAPIDMINER_CLASSPATH=%RAPIDMINER_JAR%
    if exist "%BUILD%" set RAPIDMINER_CLASSPATH=%BUILD%
    if "%RAPIDMINER_CLASSPATH%"=="" goto error1



    Please note that the command you have posted does not include the libraries in the /bin - directory. This can cause some serious trouble...

    Maybe I got you wrong...in this case please specify what do you want to achieve

    greetings,

    Steffen


  • chris_mlchris_ml Member Posts: 17 Maven
    Hi Steffen,
    Assuming that you are a linux guy...
    Yep.  ;)
    To avoid using the build - directory (I do not know why you want to do this...) replace the if-condition with this assignment:
    My idea was to just copy the single archive "lib/rapidminer.jar" to an arbitrary
    Linux machine and execute it there with "java -jar" to apply some models
    learned previously. Is this not feasible? Do I always have to provide all the
    libraries from the "lib" directory when invoking java with "-cp ${CLASSPATH}"
    and in addition the class "com.rapidminer.RapidMinerCommandLine" ?

    Regards,
    Chris
  • steffensteffen Member Posts: 347 Maven
    Hello again

    [quote author=chris_ml]
    Do I always have to provide all the libraries from the "lib" directory when invoking java with "-cp ${CLASSPATH}"
    [/quote]
    I guess it depends on the process you want to perform since I do not have a dependency graph available  ;D. You will know that something is missing when a RuntimeException occurs ... beside: It is such a big deal to copy the libraries, too ?

    [quote author=chris_ml]
    and in addition the class "com.rapidminer.RapidMinerCommandLine" ?
    [/quote]
    This class is part of rapidminer.jar. It is part of the command to specify which main method shall be executed to start rapidminer...

    I did some similar a few months ago, when my "terminal" was slow and a linux computer was available as test machine. I copied all the libraries, modified the starting script and it worked...there is nothing more annoying than to see how  a weekend-long-process is crushing in the last steps because you forgot to add some libraries to the classpath  >:( ... so why risk it ?

    greetings,

    Steffen
  • chris_mlchris_ml Member Posts: 17 Maven
    Hi,
    It is such a big deal to copy the libraries, too ?
    The lib directory has something more than 22 MB, I think that's OK. :-)
    I did some similar a few months ago, when my "terminal" was slow and a linux computer was available as test machine. I copied all the libraries, modified the starting script and it worked...there is nothing more annoying than to see how  a weekend-long-process is crushing in the last steps because you forgot to add some libraries to the classpath  >:( ... so why risk it ?
    OK, you convinced me. :-)

    Just another question going into the same direction. When I run the GUI, I see in the bottom
    bar the status of the currently running progress. This is very useful since it also indicates
    that RapidMiner is still working. However, when I run RapidMiner in the batch mode, I
    just see how RapidMiner was invoked but there is no real information about the current process.
    Is there a possibility to indicate the state of progress in batch mode as well?

    Regards,
    Chris
Sign In or Register to comment.