Github user mridulm commented on a diff in the pull request:
https://github.com/apache/spark/pull/13599#discussion_r85859906
--- Diff:
core/src/main/scala/org/apache/spark/api/python/PythonWorkerFactory.scala ---
@@ -69,6 +84,66 @@ private[spark] class PythonWorkerFactory(pythonExec:
String, envVars: Map[String
}
/**
+ * Create virtualenv using native virtualenv or conda
+ *
+ * Native Virtualenv:
+ * - Execute command: virtualenv -p pythonExec --no-site-packages
virtualenvName
+ * - Execute command: python -m pip --cache-dir cache-dir install -r
requirement_file
+ *
+ * Conda
+ * - Execute command: conda create --prefix prefix --file
requirement_file -y
+ *
+ */
+ def setupVirtualEnv(): Unit = {
+ logDebug("Start to setup virtualenv...")
+ logDebug("user.dir=" + System.getProperty("user.dir"))
+ logDebug("user.home=" + System.getProperty("user.home"))
+
+ require(virtualEnvType == "native" || virtualEnvType == "conda",
+ s"VirtualEnvType: ${virtualEnvType} is not supported" )
+ virtualEnvName = "virtualenv_" + conf.getAppId + "_" +
VIRTUALENV_ID.getAndIncrement()
+ // use the absolute path when it is local mode otherwise just use
filename as it would be
+ // fetched from FileServer
+ val pyspark_requirements =
+ if (Utils.isLocalMaster(conf)) {
+ conf.get("spark.pyspark.virtualenv.requirements")
+ } else {
+ conf.get("spark.pyspark.virtualenv.requirements").split("/").last
+ }
+
+ val createEnvCommand =
+ if (virtualEnvType == "native") {
+ Arrays.asList(virtualEnvPath,
+ "-p", pythonExec,
+ "--no-site-packages", virtualEnvName)
+ } else {
+ Arrays.asList(virtualEnvPath,
+ "create", "--prefix", System.getProperty("user.dir") + "/" +
virtualEnvName,
+ "--file", pyspark_requirements, "-y")
+ }
+ execCommand(createEnvCommand)
+ // virtualenv will be created in the working directory of Executor.
+ virtualPythonExec = virtualEnvName + "/bin/python"
--- End diff --
curious how this works under windows ... not supported ?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]