This repository has been archived by the owner on Jan 9, 2020. It is now read-only.
forked from apache/spark
-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* initial R support without integration tests * finished sparkR integration * case sensitive file names in unix * revert back to previous lower case in dockerfile * addition into the build-push-docker-images
- Loading branch information
1 parent
49932d6
commit f94499b
Showing
15 changed files
with
374 additions
and
27 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
36 changes: 36 additions & 0 deletions
36
...kubernetes/core/src/main/scala/org/apache/spark/deploy/k8s/submit/submitsteps/RStep.scala
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.apache.spark.deploy.k8s.submit.submitsteps | ||
|
||
import io.fabric8.kubernetes.api.model.ContainerBuilder | ||
|
||
import org.apache.spark.deploy.k8s.constants._ | ||
import org.apache.spark.deploy.k8s.submit.KubernetesFileUtils | ||
|
||
private[spark] class RStep( | ||
mainRFile: String, | ||
filesDownloadPath: String) extends DriverConfigurationStep { | ||
|
||
override def configureDriver(driverSpec: KubernetesDriverSpec): KubernetesDriverSpec = { | ||
val withRFileContainer = new ContainerBuilder(driverSpec.driverContainer) | ||
.addNewEnv() | ||
.withName(ENV_R_FILE) | ||
.withValue(KubernetesFileUtils.resolveFilePath(mainRFile, filesDownloadPath)) | ||
.endEnv() | ||
driverSpec.copy(driverContainer = withRFileContainer.build()) | ||
} | ||
} |
This file contains 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
64 changes: 64 additions & 0 deletions
64
...netes/core/src/test/scala/org/apache/spark/deploy/k8s/submit/submitsteps/RStepSuite.scala
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.apache.spark.deploy.k8s.submit.submitsteps | ||
|
||
import io.fabric8.kubernetes.api.model._ | ||
import org.scalatest.BeforeAndAfter | ||
import scala.collection.JavaConverters._ | ||
|
||
import org.apache.spark.{SparkConf, SparkFunSuite} | ||
|
||
class RStepSuite extends SparkFunSuite with BeforeAndAfter { | ||
private val FILE_DOWNLOAD_PATH = "/var/data/spark-files" | ||
private val R_PRIMARY_FILE_OP1 = "local:///app/files/file1.R" | ||
private val RESOLVED_R_PRIMARY_FILE_OP1 = "/app/files/file1.R" | ||
private val R_PRIMARY_FILE_OP2 = "file:///app/files/file2.R" | ||
private val RESOLVED_R_PRIMARY_FILE_OP2 = FILE_DOWNLOAD_PATH + "/file2.R" | ||
|
||
test("testing RSpark with local file") { | ||
val rStep = new RStep( | ||
R_PRIMARY_FILE_OP1, | ||
FILE_DOWNLOAD_PATH) | ||
val returnedDriverContainer = rStep.configureDriver( | ||
KubernetesDriverSpec( | ||
new Pod(), | ||
new Container(), | ||
Seq.empty[HasMetadata], | ||
new SparkConf)) | ||
assert(returnedDriverContainer.driverContainer.getEnv | ||
.asScala.map(env => (env.getName, env.getValue)).toMap === | ||
Map( | ||
"R_FILE" -> RESOLVED_R_PRIMARY_FILE_OP1)) | ||
} | ||
|
||
test("testing RSpark with remote file") { | ||
val rStep = new RStep( | ||
R_PRIMARY_FILE_OP2, | ||
FILE_DOWNLOAD_PATH) | ||
val returnedDriverContainer = rStep.configureDriver( | ||
KubernetesDriverSpec( | ||
new Pod(), | ||
new Container(), | ||
Seq.empty[HasMetadata], | ||
new SparkConf)) | ||
assert(returnedDriverContainer.driverContainer.getEnv | ||
.asScala.map(env => (env.getName, env.getValue)).toMap === | ||
Map( | ||
"R_FILE" -> RESOLVED_R_PRIMARY_FILE_OP2)) | ||
} | ||
|
||
} |
39 changes: 39 additions & 0 deletions
39
resource-managers/kubernetes/docker-minimal-bundle/src/main/docker/driver-r/Dockerfile
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# | ||
# Licensed to the Apache Software Foundation (ASF) under one or more | ||
# contributor license agreements. See the NOTICE file distributed with | ||
# this work for additional information regarding copyright ownership. | ||
# The ASF licenses this file to You under the Apache License, Version 2.0 | ||
# (the "License"); you may not use this file except in compliance with | ||
# the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
FROM spark-base | ||
|
||
# If this docker file is being used in the context of building your images from a Spark distribution, the docker build | ||
# command should be invoked from the top level directory of the Spark distribution. E.g.: | ||
# docker build -t spark-driver-r:latest -f dockerfiles/driver-r/Dockerfile . | ||
|
||
ADD examples /opt/spark/examples | ||
ADD R /opt/spark/R | ||
|
||
RUN apk add --no-cache R R-dev | ||
|
||
ENV R_HOME /usr/lib/R | ||
|
||
CMD SPARK_CLASSPATH="${SPARK_HOME}/jars/*" && \ | ||
env | grep SPARK_JAVA_OPT_ | sed 's/[^=]*=\(.*\)/\1/g' > /tmp/java_opts.txt && \ | ||
readarray -t SPARK_DRIVER_JAVA_OPTS < /tmp/java_opts.txt && \ | ||
if ! [ -z ${SPARK_MOUNTED_CLASSPATH+x} ]; then SPARK_CLASSPATH="$SPARK_MOUNTED_CLASSPATH:$SPARK_CLASSPATH"; fi && \ | ||
if ! [ -z ${SPARK_SUBMIT_EXTRA_CLASSPATH+x} ]; then SPARK_CLASSPATH="$SPARK_SUBMIT_EXTRA_CLASSPATH:$SPARK_CLASSPATH"; fi && \ | ||
if ! [ -z ${SPARK_EXTRA_CLASSPATH+x} ]; then SPARK_CLASSPATH="$SPARK_EXTRA_CLASSPATH:$SPARK_CLASSPATH"; fi && \ | ||
if ! [ -z ${SPARK_MOUNTED_FILES_DIR+x} ]; then cp -R "$SPARK_MOUNTED_FILES_DIR/." .; fi && \ | ||
if ! [ -z ${SPARK_MOUNTED_FILES_FROM_SECRET_DIR+x} ]; then cp -R "$SPARK_MOUNTED_FILES_FROM_SECRET_DIR/." .; fi && \ | ||
${JAVA_HOME}/bin/java "${SPARK_DRIVER_JAVA_OPTS[@]}" -cp $SPARK_CLASSPATH -Xms$SPARK_DRIVER_MEMORY -Xmx$SPARK_DRIVER_MEMORY $SPARK_DRIVER_CLASS $R_FILE $SPARK_DRIVER_ARGS |
38 changes: 38 additions & 0 deletions
38
resource-managers/kubernetes/docker-minimal-bundle/src/main/docker/executor-r/Dockerfile
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# | ||
# Licensed to the Apache Software Foundation (ASF) under one or more | ||
# contributor license agreements. See the NOTICE file distributed with | ||
# this work for additional information regarding copyright ownership. | ||
# The ASF licenses this file to You under the Apache License, Version 2.0 | ||
# (the "License"); you may not use this file except in compliance with | ||
# the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
FROM spark-base | ||
|
||
# If this docker file is being used in the context of building your images from a Spark distribution, the docker build | ||
# command should be invoked from the top level directory of the Spark distribution. E.g.: | ||
# docker build -t spark-executor-r:latest -f dockerfiles/executor-r/Dockerfile . | ||
|
||
ADD examples /opt/spark/examples | ||
ADD R /opt/spark/R | ||
|
||
RUN apk add --no-cache R R-dev | ||
|
||
ENV R_HOME /usr/lib/R | ||
|
||
CMD SPARK_CLASSPATH="${SPARK_HOME}/jars/*" && \ | ||
env | grep SPARK_JAVA_OPT_ | sed 's/[^=]*=\(.*\)/\1/g' > /tmp/java_opts.txt && \ | ||
readarray -t SPARK_EXECUTOR_JAVA_OPTS < /tmp/java_opts.txt && \ | ||
if ! [ -z ${SPARK_MOUNTED_CLASSPATH}+x} ]; then SPARK_CLASSPATH="$SPARK_MOUNTED_CLASSPATH:$SPARK_CLASSPATH"; fi && \ | ||
if ! [ -z ${SPARK_EXECUTOR_EXTRA_CLASSPATH+x} ]; then SPARK_CLASSPATH="$SPARK_EXECUTOR_EXTRA_CLASSPATH:$SPARK_CLASSPATH"; fi && \ | ||
if ! [ -z ${SPARK_MOUNTED_FILES_DIR+x} ]; then cp -R "$SPARK_MOUNTED_FILES_DIR/." .; fi && \ | ||
if ! [ -z ${SPARK_MOUNTED_FILES_FROM_SECRET_DIR+x} ]; then cp -R "$SPARK_MOUNTED_FILES_FROM_SECRET_DIR/." .; fi && \ | ||
${JAVA_HOME}/bin/java "${SPARK_EXECUTOR_JAVA_OPTS[@]}" -Dspark.executor.port=$SPARK_EXECUTOR_PORT -Xms$SPARK_EXECUTOR_MEMORY -Xmx$SPARK_EXECUTOR_MEMORY -cp $SPARK_CLASSPATH org.apache.spark.executor.CoarseGrainedExecutorBackend --driver-url $SPARK_DRIVER_URL --executor-id $SPARK_EXECUTOR_ID --cores $SPARK_EXECUTOR_CORES --app-id $SPARK_APPLICATION_ID --hostname $SPARK_EXECUTOR_POD_IP |
This file contains 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
Oops, something went wrong.