Montag, 17. Februar 2014

Testing R/Rserve in the Cloud

I have to admit, this took me quite a while to figure out. But here we go.

Continuous Integration ?


My present idea of good software is, that good software MUST prove that it works. In order to show that, a continuous integration server is a developers best friend. Such a Continuous Integration server is JENKINS. But when I run such a server on my local laptop, I cannot show anyone out there in the world wide web, that my code seriously runs. So, searching the web for a CI service with low cost I happened to stumble upon the red hat openshift service. They offer free "gears" (modules), remote https login and configuration. Some security restriktions involve that I am not admin of the server, but nevertheless I can unpack ("install") R in my gear.

Running R/Rserve on openshift


After creating a standard Jenkins CI gear I need a bit of remote work to install Rserve and the required environment:
ssh ...7@ci-joris.rhcloud.com
#DOWNLOAD AND INSTALL R
cd $OPENSHIFT_DATA_DIR/tools
rm -rf .. (old version if installed)
wget ftp://ftp.stat.math.ethz.ch/pub/Software/R/R-devel.tar.gz
tar -xzf R-devel.tar.gz
cd R-devel
./configure --prefix=$OPENSHIFT_DATA_DIR/tools/R/ --exec-prefix=$OPENSHIFT_DATA_DIR/tools/R-tools --enable-R-shlib >r_configure.log 2>r_configure_error.log
make >r_make.log 2>r_make_error.log
#INSTALL Rserve
export PATH=$PATH:$OPENSHIFT_DATA_DIR/tools/R-devel/bin
wget http://www.rforge.net/Rserve/snapshot/Rserve_1.7-0.tar.gz
R CMD INSTALL Rserve_1.7-0.tar.gz >rserve_install.log 2>rserve_install_error.log
#Rserve requires a native domain socket:
wget http://junixsocket.googlecode.com/files/junixsocket-1.3-bin.tar.bz2
tar -xvjf junixsocket-1.3-bin.tar.bz2
mv junixsocket-1.3/lib-native/* .
rm *.bz2
rm -rf junixsocket-1.3/

Done so far. This installed R, Rserve and a Java Unixsocket library (junixsocket). The unix socket is required to allow connection to Rserve. "localhost" is not available as a server IP running on openshift. Nevertheless I can connect to Rserve through a socket.

Be aware that this continuos integration server will test R and Rserve with one installed version. I like to keep that combination fixed for now. A possible next extension is to install R and Rserve on the fly.

Nevertheless, you may take peek of what extensions are in development and see the health of j.o.r.i.s in the web: https://ci-joris.rhcloud.com

You may download the current source from SVN https://ralfseger.svn.cloudforge.com/repository/root and test yourselves.
To use unix-socket connection add some environment variables:

export DERBY_HOST="$OPENSHIFT_INTERNAL_IP"
export DERBY_PORT="3529"
export NATIVE_LIB_PATH="$OPENSHIFT_DATA_DIR"tools/native-libs
export RSERVE_SOCKET="$OPENSHIFT_DATA_DIR"socket/rserve
export JORIS_host="$OPENSHIFT_INTERNAL_IP"
export JORIS_port="9999"

the $OPENSHIFT_INTERNAL_IP is the internal IP when you run on openshift.
For your own computer you are free to use whatever fits your needs.

Big thanks to red hat for providing openshift and to cloudforge for their complimentary, great service.


Keine Kommentare:

Kommentar veröffentlichen