Skip to content

Commit

Permalink
Create SparkContext for R shell launch
Browse files Browse the repository at this point in the history
  • Loading branch information
shivaram committed Feb 20, 2015
1 parent f9268d9 commit 88bf97f
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions pkg/inst/sparkR-submit
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,21 @@ if [[ $NUM_APPLICATION_OPTS -gt 0 && "${APPLICATION_OPTS[0]}" =~ \.R$ ]]; then
exec "$SPARK_HOME"/bin/spark-submit --class edu.berkeley.cs.amplab.sparkr.SparkRRunner --files "$primary" "${SUBMISSION_OPTS[@]}" "$SPARKR_JAR_FILE" "$primary" "${APPLICATION_OPTS[@]:1}"
else

export R_PROFILE_USER="/tmp/sparkR.profile"

# If we don't have an R file to run, run R shell
cat > /tmp/sparkR.profile << EOF
.First <- function() {
projecHome <- Sys.getenv("PROJECT_HOME")
Sys.setenv(NOAWT=1)
.libPaths(c(paste(projecHome,"/..", sep=""), .libPaths()))
require(SparkR)
sc <- sparkR.init()
assign("sc", sc, envir=.GlobalEnv)
cat("\n Welcome to SparkR!")
cat("\n Spark context is available as sc\n")
}
EOF
R

fi

0 comments on commit 88bf97f

Please sign in to comment.