You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@linkis.apache.org by GitBox <gi...@apache.org> on 2022/08/17 12:39:17 UTC

[GitHub] [incubator-linkis] peacewong commented on a diff in pull request #2817: test case for python engine

peacewong commented on code in PR #2817:
URL: https://github.com/apache/incubator-linkis/pull/2817#discussion_r947875582


##########
linkis-engineconn-plugins/python/src/main/scala/org/apache/linkis/manager/engineplugin/python/conf/PythonEngineConfiguration.scala:
##########
@@ -23,11 +23,18 @@ import org.apache.linkis.common.conf.{CommonVars, TimeType}
 object PythonEngineConfiguration {
 
   val PYTHON_CONSOLE_OUTPUT_LINE_LIMIT = CommonVars("wds.linkis.python.line.limit", 10)
-  val PY4J_HOME = CommonVars("wds.linkis.python.py4j.home", this.getClass.getResource("/conf").getPath)
+  val PY4J_HOME = CommonVars("wds.linkis.python.py4j.home", getPy4jHome)
   val PYTHON_VERSION = CommonVars("pythonVersion", "python3")
 
   val PYTHON_PATH:CommonVars[String] = CommonVars[String]("python.path", "", "Specify Python's extra path, which only accepts shared storage paths(指定Python额外的path,该路径只接受共享存储的路径).")
 
   val PYTHON_LANGUAGE_REPL_INIT_TIME = CommonVars[TimeType]("wds.linkis.engine.python.language-repl.init.time", new TimeType("30s"))
 
+  private def getPy4jHome(): String = {
+    val confDir = "/conf"
+    if (null !=  this.getClass.getResource(confDir)) {
+      this.getClass.getResource(confDir).getPath
+    }
+    this.getClass.getResource("/").getPath

Review Comment:
   is else ?



##########
linkis-engineconn-plugins/python/src/main/scala/org/apache/linkis/manager/engineplugin/python/executor/PythonEngineConnExecutor.scala:
##########
@@ -45,8 +46,14 @@ class PythonEngineConnExecutor(id: Int, pythonSession: PythonSession, outputPrin
     super.init
   }
 
-  private val pythonDefaultVersion: String = EngineConnServer.getEngineCreationContext.getOptions.getOrDefault("python.version", "python")
+  private val pythonDefaultVersion: String = getPyVersion
 
+  private def getPyVersion(): String = {
+    if (null != EngineConnServer.getEngineCreationContext.getOptions) {
+      EngineConnServer.getEngineCreationContext.getOptions.getOrDefault("python.version", "python")
+    }
+    PythonEngineConfiguration.PYTHON_VERSION.getValue

Review Comment:
   is else?



##########
linkis-engineconn-plugins/python/src/main/scala/org/apache/linkis/manager/engineplugin/python/executor/PythonSession.scala:
##########
@@ -58,9 +58,16 @@ class PythonSession extends Logging {
   private var code: String = _
   private var pid: Option[String] = None
 
-  private val pythonDefaultVersion: String = EngineConnServer.getEngineCreationContext.getOptions.getOrDefault("python.version", "python")
+  private val pythonDefaultVersion: String = getPyVersion
 
 
+  private def getPyVersion(): String = {
+    if (null != EngineConnServer.getEngineCreationContext.getOptions) {
+      EngineConnServer.getEngineCreationContext.getOptions.getOrDefault("python.version", "python")
+    }

Review Comment:
   is else



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@linkis.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@linkis.apache.org
For additional commands, e-mail: notifications-help@linkis.apache.org