You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by zi...@apache.org on 2022/04/16 10:57:43 UTC
[dolphinscheduler] branch dev updated: [Fix-9525] [Worker] Environment did not work as expected (#9527)
This is an automated email from the ASF dual-hosted git repository.
zihaoxiang pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/dolphinscheduler.git
The following commit(s) were added to refs/heads/dev by this push:
new 7f41a96fc1 [Fix-9525] [Worker] Environment did not work as expected (#9527)
7f41a96fc1 is described below
commit 7f41a96fc102110366738b59c437884e19ae6b8e
Author: xiangzihao <46...@qq.com>
AuthorDate: Sat Apr 16 18:57:33 2022 +0800
[Fix-9525] [Worker] Environment did not work as expected (#9527)
* fix #9525
* change to ${PYTHON_HOME}
* remove import
* fix ut error
---
.../org/apache/dolphinscheduler/plugin/task/python/PythonTask.java | 6 ++----
.../apache/dolphinscheduler/plugin/task/python/PythonTaskTest.java | 2 +-
2 files changed, 3 insertions(+), 5 deletions(-)
diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-python/src/main/java/org/apache/dolphinscheduler/plugin/task/python/PythonTask.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-python/src/main/java/org/apache/dolphinscheduler/plugin/task/python/PythonTask.java
index 1df388f756..c153847b18 100644
--- a/dolphinscheduler-task-plugin/dolphinscheduler-task-python/src/main/java/org/apache/dolphinscheduler/plugin/task/python/PythonTask.java
+++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-python/src/main/java/org/apache/dolphinscheduler/plugin/task/python/PythonTask.java
@@ -238,10 +238,8 @@ public class PythonTask extends AbstractTaskExecutor {
private String buildPythonExecuteCommand(String pythonFile) {
Preconditions.checkNotNull(pythonFile, "Python file cannot be null");
- String pythonHome = System.getenv(PYTHON_HOME);
- if (StringUtils.isEmpty(pythonHome)) {
- return DEFAULT_PYTHON_VERSION + " " + pythonFile;
- }
+ String pythonHome = String.format("${%s}", PYTHON_HOME);
+
return pythonHome + " " + pythonFile;
}
diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-python/src/test/java/org/apache/dolphinscheduler/plugin/task/python/PythonTaskTest.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-python/src/test/java/org/apache/dolphinscheduler/plugin/task/python/PythonTaskTest.java
index 08c5e0d8cf..7df5342179 100644
--- a/dolphinscheduler-task-plugin/dolphinscheduler-task-python/src/test/java/org/apache/dolphinscheduler/plugin/task/python/PythonTaskTest.java
+++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-python/src/test/java/org/apache/dolphinscheduler/plugin/task/python/PythonTaskTest.java
@@ -29,7 +29,7 @@ public class PythonTaskTest {
String methodName = "buildPythonExecuteCommand";
String pythonFile = "test.py";
String result1 = Whitebox.invokeMethod(pythonTask, methodName, pythonFile);
- Assert.assertEquals("python test.py", result1);
+ Assert.assertEquals("${PYTHON_HOME} test.py", result1);
}
private PythonTask createPythonTask() {