Created
March 26, 2015 13:04
-
-
Save zachradtka/889dc4b83c83c8f613a7 to your computer and use it in GitHub Desktop.
A script to run mortar's recommendation engine
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Exit on Error | |
set -e | |
# Get the path of the script | |
pushd `dirname $0` > /dev/null | |
SCRIPT_PATH=`pwd` | |
popd > /dev/null | |
# Set the path for mortar home and jython | |
MORTAR_HOME=<PATH_TO_MORTAR_HOME> | |
JYTHON_HOME=${MORTAR_HOME}/jython | |
export PIG_HOME=${MORTAR_HOME}/pig-0.12 | |
export PIG_CLASSPATH=\ | |
${PIG_HOME}/lib-local/*:\ | |
${MORTAR_HOME}/lib-common/lib-local/*:\ | |
${PIG_HOME}/lib-pig/*:\ | |
${PIG_HOME}/lib-cluster/*:\ | |
${MORTAR_HOME}/lib-common/lib-pig/*:\ | |
${MORTAR_HOME}/lib-common/lib-cluster/*:\ | |
${JYTHON_HOME}/jython.jar:\ | |
${SCRIPT_PATH}/lib/* | |
export CLASSPATH=\ | |
${MORTAR_HOME}/lib-common/lib-local/*:\ | |
${MORTAR_HOME}/lib-common/lib-pig/*:\ | |
${MORTAR_HOME}/lib-common/lib-cluster/*:\ | |
${JYTHON_HOME}/jython.jar:\ | |
${MORTAR_HOME}/lib-common/conf/jets3t.properties:\ | |
${SCRIPT_PATH}/lib/* | |
export PIG_MAIN_CLASS=org.apache.pig.Main | |
export PIG_OPTS=\ | |
"-Dpig.events.logformat=humanreadable \ | |
-Dfs.s3.awsAccessKeyId=XXXXXXXXXXXX \ | |
-Dfs.s3.awsSecretAccessKey=XXXXXXXXXXXX \ | |
-Dfs.s3n.awsAccessKeyId=XXXXXXXXXXXX \ | |
-Dfs.s3n.awsSecretAccessKey=XXXXXXXXXXXX \ | |
-Dpig.logfile=${SCRIPT_PATH}/logs/local-pig.log \ | |
-Djava.security.krb5.realm= \ | |
-Dpython.cachedir=${JYTHON_HOME}/cachedir \ | |
-Dpython.home=${JYTHON_HOME} \ | |
-Djython.output=true \ | |
-Djava.security.krb5.kdc= \ | |
-Dpython.verbose=error \ | |
-Dpig.udf.scripting.log.dir=${SCRIPT_PATH}/logs/udf " | |
#Uncomment to debug pig code | |
#export PIG_OPTS="$PIG_OPTS -Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=8000" | |
# UDF paths are relative to this direectory | |
if [ -d "${SCRIPT_PATH}/pigscripts" ]; then | |
export LOG4J_CONF_FILE=${MORTAR_HOME}/lib-common/conf/log4j-cli-local-dev.properties | |
cd ${SCRIPT_PATH}/pigscripts | |
else | |
export LOG4J_CONF_FILE=${MORTAR_HOME}/lib-common/conf/log4j-cli-local-no-project.properties | |
fi | |
# Setup python environment | |
echo "Activating python" | |
source ${MORTAR_HOME}/pythonenv/bin/activate | |
# Run Pig | |
${PIG_HOME}/bin/pig -exectype local \ | |
-log4jconf "${LOG4J_CONF_FILE}" \ | |
-propertyFile ${MORTAR_HOME}/lib-common/conf/pig-hawk-global.properties \ | |
-propertyFile ${MORTAR_HOME}/lib-common/conf/pig-cli-local-dev.properties \ | |
-param_file ${SCRIPT_PATH}/params/retail.params \ | |
-f ${SCRIPT_PATH}/pigscripts/retail-recsys.pig |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment