Browse Source

[Fix-9525] [Worker] Environment did not work as expected (#9527)

* fix #9525

* change to ${PYTHON_HOME}

* remove import

* fix ut error
3.0.0/version-upgrade
xiangzihao 2 years ago committed by GitHub
parent
commit
7f41a96fc1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      dolphinscheduler-task-plugin/dolphinscheduler-task-python/src/main/java/org/apache/dolphinscheduler/plugin/task/python/PythonTask.java
  2. 2
      dolphinscheduler-task-plugin/dolphinscheduler-task-python/src/test/java/org/apache/dolphinscheduler/plugin/task/python/PythonTaskTest.java

6
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;
}

2
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() {

Loading…
Cancel
Save