Skip to content

Commit

Permalink
Ship pyspark archives and add it to PYTHONPATH
Browse files Browse the repository at this point in the history
  • Loading branch information
Sephiroth-Lin committed Apr 16, 2015
1 parent 413fa25 commit 51ebb26
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ private[spark] object PythonUtils {
pythonPath += Seq(sparkHome, "python", "lib", "py4j-0.8.2.1-src.zip").mkString(File.separator)
}
pythonPath ++= SparkContext.jarOfObject(this)
sys.env.get("PYSPARK_ARCHIVES_PATH") match {
case Some(path) => pythonPath += path
case None => // do nothing
}
pythonPath.mkString(File.pathSeparator)
}

Expand Down
5 changes: 0 additions & 5 deletions yarn/src/main/scala/org/apache/spark/deploy/yarn/Client.scala
Original file line number Diff line number Diff line change
Expand Up @@ -371,11 +371,6 @@ private[spark] class Client(
env(ENV_DIST_CLASSPATH) = dcp
}

sys.env.get("PYTHONPATH") match {
case Some(pythonPath) => env("PYTHONPATH") = pythonPath
case None => // do nothing
}

env
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,12 @@ class ExecutorRunnable(

val localResources = prepareLocalResources
ctx.setLocalResources(localResources)

// From SPARK-1920 and SPARK-1520 we know PySpark on Yarn can not work when the assembly jar are
// package by JDK 1.7+, so we ship PySpark archives to executors by Yarn with --py-files, and
// add this path to PYTHONPATH.
for ((k, v) <- localResources if k.contains("spark-pyspark")) {
env("PYSPARK_ARCHIVES_PATH") = k
}
ctx.setEnvironment(env)

val credentials = UserGroupInformation.getCurrentUser().getCredentials()
Expand Down Expand Up @@ -299,12 +304,6 @@ class ExecutorRunnable(
}

System.getenv().filterKeys(_.startsWith("SPARK")).foreach { case (k, v) => env(k) = v }

sys.env.get("PYTHONPATH") match {
case Some(pythonPath) => env("PYTHONPATH") = pythonPath
case None => // do nothing
}

env
}
}

0 comments on commit 51ebb26

Please sign in to comment.