You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@linkis.apache.org by pe...@apache.org on 2022/08/19 15:22:22 UTC
[incubator-linkis] branch dev-1.3.0 updated: fix the way of getting pythonversion (#2898)
This is an automated email from the ASF dual-hosted git repository.
peacewong pushed a commit to branch dev-1.3.0
in repository https://gitbox.apache.org/repos/asf/incubator-linkis.git
The following commit(s) were added to refs/heads/dev-1.3.0 by this push:
new e3794d3ed fix the way of getting pythonversion (#2898)
e3794d3ed is described below
commit e3794d3ed618865aae3e7dae1d2b0b831e38222b
Author: QuintinTao <72...@users.noreply.github.com>
AuthorDate: Fri Aug 19 23:22:15 2022 +0800
fix the way of getting pythonversion (#2898)
---
.../python/conf/PythonEngineConfiguration.scala | 11 ++++++++++-
.../python/executor/PythonEngineConnExecutor.scala | 13 +++++++++++--
.../engineplugin/python/executor/PythonSession.scala | 12 ++++++++++--
3 files changed, 31 insertions(+), 5 deletions(-)
diff --git a/linkis-engineconn-plugins/python/src/main/scala/org/apache/linkis/manager/engineplugin/python/conf/PythonEngineConfiguration.scala b/linkis-engineconn-plugins/python/src/main/scala/org/apache/linkis/manager/engineplugin/python/conf/PythonEngineConfiguration.scala
old mode 100644
new mode 100755
index 47ecc0811..6eff880e0
--- a/linkis-engineconn-plugins/python/src/main/scala/org/apache/linkis/manager/engineplugin/python/conf/PythonEngineConfiguration.scala
+++ b/linkis-engineconn-plugins/python/src/main/scala/org/apache/linkis/manager/engineplugin/python/conf/PythonEngineConfiguration.scala
@@ -24,7 +24,7 @@ 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)
+ CommonVars("wds.linkis.python.py4j.home", getPy4jHome)
val PYTHON_VERSION = CommonVars("pythonVersion", "python3")
@@ -37,4 +37,13 @@ object PythonEngineConfiguration {
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
+ } else {
+ this.getClass.getResource("/").getPath
+ }
+ }
+
}
diff --git a/linkis-engineconn-plugins/python/src/main/scala/org/apache/linkis/manager/engineplugin/python/executor/PythonEngineConnExecutor.scala b/linkis-engineconn-plugins/python/src/main/scala/org/apache/linkis/manager/engineplugin/python/executor/PythonEngineConnExecutor.scala
index 68cc8ad88..2d41ca09a 100644
--- a/linkis-engineconn-plugins/python/src/main/scala/org/apache/linkis/manager/engineplugin/python/executor/PythonEngineConnExecutor.scala
+++ b/linkis-engineconn-plugins/python/src/main/scala/org/apache/linkis/manager/engineplugin/python/executor/PythonEngineConnExecutor.scala
@@ -31,6 +31,7 @@ import org.apache.linkis.manager.common.entity.resource.{
NodeResource
}
import org.apache.linkis.manager.engineplugin.common.conf.EngineConnPluginConf
+import org.apache.linkis.manager.engineplugin.python.conf.PythonEngineConfiguration
import org.apache.linkis.manager.label.entity.Label
import org.apache.linkis.protocol.engine.JobProgressInfo
import org.apache.linkis.rpc.Sender
@@ -54,8 +55,16 @@ 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")
+ } else {
+ PythonEngineConfiguration.PYTHON_VERSION.getValue
+ }
+ }
override def executeLine(
engineExecutionContext: EngineExecutionContext,
diff --git a/linkis-engineconn-plugins/python/src/main/scala/org/apache/linkis/manager/engineplugin/python/executor/PythonSession.scala b/linkis-engineconn-plugins/python/src/main/scala/org/apache/linkis/manager/engineplugin/python/executor/PythonSession.scala
index 2d7866b99..b7f693c8a 100644
--- a/linkis-engineconn-plugins/python/src/main/scala/org/apache/linkis/manager/engineplugin/python/executor/PythonSession.scala
+++ b/linkis-engineconn-plugins/python/src/main/scala/org/apache/linkis/manager/engineplugin/python/executor/PythonSession.scala
@@ -62,8 +62,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")
+ } else {
+ PythonEngineConfiguration.PYTHON_VERSION.getValue
+ }
+ }
def init(): Unit = {}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@linkis.apache.org
For additional commands, e-mail: commits-help@linkis.apache.org