Skip to content

Commit 88bf97f

Browse files
committed
Create SparkContext for R shell launch
1 parent f9268d9 commit 88bf97f

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

pkg/inst/sparkR-submit

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,21 @@ if [[ $NUM_APPLICATION_OPTS -gt 0 && "${APPLICATION_OPTS[0]}" =~ \.R$ ]]; then
5454
exec "$SPARK_HOME"/bin/spark-submit --class edu.berkeley.cs.amplab.sparkr.SparkRRunner --files "$primary" "${SUBMISSION_OPTS[@]}" "$SPARKR_JAR_FILE" "$primary" "${APPLICATION_OPTS[@]:1}"
5555
else
5656

57+
export R_PROFILE_USER="/tmp/sparkR.profile"
58+
5759
# If we don't have an R file to run, run R shell
60+
cat > /tmp/sparkR.profile << EOF
61+
.First <- function() {
62+
projecHome <- Sys.getenv("PROJECT_HOME")
63+
Sys.setenv(NOAWT=1)
64+
.libPaths(c(paste(projecHome,"/..", sep=""), .libPaths()))
65+
require(SparkR)
66+
sc <- sparkR.init()
67+
assign("sc", sc, envir=.GlobalEnv)
68+
cat("\n Welcome to SparkR!")
69+
cat("\n Spark context is available as sc\n")
70+
}
71+
EOF
5872
R
5973

6074
fi

0 commit comments

Comments
 (0)