Skip to content

Commit 6ba543e

Browse files
author
pgandhi
committed
[SPARK-22151] : Appending original pythonpath value to ExecutorEnv.PYTHONPATH
Instead of overriding the executorenv PYTHONPATH, appending existing pythonpath string to it and avoiding passing value of appMasterEnv.PYTHONPATH to the executorEnv variable
1 parent 5e733ae commit 6ba543e

File tree

1 file changed

+6
-2
lines changed
  • resource-managers/yarn/src/main/scala/org/apache/spark/deploy/yarn

1 file changed

+6
-2
lines changed

resource-managers/yarn/src/main/scala/org/apache/spark/deploy/yarn/Client.scala

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -811,7 +811,7 @@ private[spark] class Client(
811811

812812
// Finally, update the Spark config to propagate PYTHONPATH to the AM and executors.
813813
if (pythonPath.nonEmpty) {
814-
val pythonPathStr = (sys.env.get("PYTHONPATH") ++=: pythonPath)
814+
val pythonPathStr = (sys.env.get("PYTHONPATH") ++ pythonPath)
815815
.mkString(ApplicationConstants.CLASS_PATH_SEPARATOR)
816816
val newValue =
817817
if (env.contains("PYTHONPATH")) {
@@ -821,7 +821,11 @@ private[spark] class Client(
821821
}
822822
env("PYTHONPATH") = newValue
823823
if (!sparkConf.getExecutorEnv.toMap.contains("PYTHONPATH")) {
824-
sparkConf.setExecutorEnv("PYTHONPATH", newValue)
824+
sparkConf.setExecutorEnv("PYTHONPATH", pythonPathStr)
825+
} else {
826+
val pythonPathExecutorEnv = sparkConf.getExecutorEnv.toMap.get("PYTHONPATH").get +
827+
ApplicationConstants.CLASS_PATH_SEPARATOR + pythonPathStr
828+
sparkConf.setExecutorEnv("PYTHONPATH", pythonPathExecutorEnv)
825829
}
826830
}
827831

0 commit comments

Comments
 (0)