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 0dd3915c0 refactor(ecp-python): testPython With default python version (#3119) 0dd3915c0 is described below commit 0dd3915c0b515f8e31610c29688f58c99638e031 Author: Jack Xu <xuling...@126.com> AuthorDate: Mon Aug 29 11:21:25 2022 +0800 refactor(ecp-python): testPython With default python version (#3119) --- .../engineplugin/python/hook/PythonVersionEngineHook.scala | 8 ++++++-- .../python/executor/TestPythonEngineConnExecutor.scala | 7 ------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/linkis-engineconn-plugins/python/src/main/scala/org/apache/linkis/manager/engineplugin/python/hook/PythonVersionEngineHook.scala b/linkis-engineconn-plugins/python/src/main/scala/org/apache/linkis/manager/engineplugin/python/hook/PythonVersionEngineHook.scala index fbf41ec73..277942997 100644 --- a/linkis-engineconn-plugins/python/src/main/scala/org/apache/linkis/manager/engineplugin/python/hook/PythonVersionEngineHook.scala +++ b/linkis-engineconn-plugins/python/src/main/scala/org/apache/linkis/manager/engineplugin/python/hook/PythonVersionEngineHook.scala @@ -24,6 +24,8 @@ import org.apache.linkis.engineconn.common.hook.EngineConnHook import org.apache.linkis.manager.engineplugin.python.conf.PythonEngineConfiguration import org.apache.linkis.manager.engineplugin.python.executor.PythonSession +import java.util + class PythonVersionEngineHook extends EngineConnHook with Logging { var _sparkpythonVersion: String = _ var _sparkpythonExtraPackage: String = _ @@ -31,8 +33,10 @@ class PythonVersionEngineHook extends EngineConnHook with Logging { var _pythonExtraPackage: String = _ override def beforeCreateEngineConn(engineCreationContext: EngineCreationContext): Unit = { - val params = engineCreationContext.getOptions - _pythonVersion = params.getOrDefault("python.version", "python3").toString + val params = + if (engineCreationContext.getOptions == null) new util.HashMap[String, String]() + else engineCreationContext.getOptions + _pythonVersion = params.getOrDefault("python.version", "python3") _pythonExtraPackage = params .getOrDefault("python.application.pyFiles", "file:///mnt/bdap/test/test/test.zip") .toString diff --git a/linkis-engineconn-plugins/python/src/test/scala/org/apache/linkis/manager/engineplugin/python/executor/TestPythonEngineConnExecutor.scala b/linkis-engineconn-plugins/python/src/test/scala/org/apache/linkis/manager/engineplugin/python/executor/TestPythonEngineConnExecutor.scala index 295b30078..eb1bc5418 100644 --- a/linkis-engineconn-plugins/python/src/test/scala/org/apache/linkis/manager/engineplugin/python/executor/TestPythonEngineConnExecutor.scala +++ b/linkis-engineconn-plugins/python/src/test/scala/org/apache/linkis/manager/engineplugin/python/executor/TestPythonEngineConnExecutor.scala @@ -25,7 +25,6 @@ import org.apache.linkis.engineconn.common.creation.{ EngineCreationContext } import org.apache.linkis.engineconn.computation.executor.execute.EngineExecutionContext -import org.apache.linkis.engineconn.launch.EngineConnServer import org.apache.linkis.manager.engineplugin.python.factory.PythonEngineConnFactory import org.apache.linkis.manager.engineplugin.python.hook.PythonVersionEngineHook @@ -57,17 +56,12 @@ class TestPythonEngineConnExecutor { val engineConnFactory: PythonEngineConnFactory = new PythonEngineConnFactory val engineCreationContext: EngineCreationContext = new DefaultEngineCreationContext val path = this.getClass.getResource("/").getPath - System.setProperty("pythonVersion", "python") System.setProperty("HADOOP_CONF_DIR", "./") System.setProperty( "wds.linkis.python.py4j.home", path.substring(0, path.indexOf("/target")) + "/src/main/py4j" ) - val jMap = new java.util.HashMap[String, String]() - jMap.put("python.version", "python") - engineCreationContext.setOptions(jMap) val engineConn = engineConnFactory.createEngineConn(engineCreationContext) - EngineConnServer.getEngineCreationContext.setOptions(jMap) hookPre.beforeCreateEngineConn(engineCreationContext) val executor = engineConnFactory .newExecutor(1, engineCreationContext, engineConn) @@ -78,7 +72,6 @@ class TestPythonEngineConnExecutor { // engineConn.getEngineConnSession.asInstanceOf[PythonSession].onPythonScriptInitialized(1) // hookPre.beforeExecutionExecute(engineCreationContext, engineConn) val engineExecutionContext = new EngineExecutionContext(executor, Utils.getJvmUser) - engineExecutionContext.addProperty("python.version", "python") val code = "for i in range(10):\n print(i)" val response = executor.executeLine(engineExecutionContext, code) Assertions.assertNotNull(response) --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@linkis.apache.org For additional commands, e-mail: commits-h...@linkis.apache.org