Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
DolphinScheduler
提交
0715be34
DolphinScheduler
项目概览
apache
/
DolphinScheduler
上一次同步 1 年多
通知
704
Star
9572
Fork
3514
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
DolphinScheduler
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
0715be34
编写于
9月 11, 2021
作者:
mgsky1
提交者:
GitHub
9月 11, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[Fix-6166][task-plugin]Fix Python Task Execution Error (#6167)
* fix python task execution error * delete AbstractTask#setCommand
上级
ea2a9dbc
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
28 addition
and
13 deletion
+28
-13
dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/AbstractTask.java
...va/org/apache/dolphinscheduler/spi/task/AbstractTask.java
+0
-3
dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/AbstractCommandExecutor.java
...hinscheduler/plugin/task/api/AbstractCommandExecutor.java
+1
-1
dolphinscheduler-task-plugin/dolphinscheduler-task-python/src/main/java/org/apache/dolphinscheduler/plugin/task/python/PythonTask.java
...pache/dolphinscheduler/plugin/task/python/PythonTask.java
+27
-9
未找到文件。
dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/AbstractTask.java
浏览文件 @
0715be34
...
...
@@ -79,9 +79,6 @@ public abstract class AbstractTask {
return
null
;
}
public
void
setCommand
(
String
command
)
throws
Exception
{
}
/**
* task handle
...
...
dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/AbstractCommandExecutor.java
浏览文件 @
0715be34
...
...
@@ -127,7 +127,7 @@ public abstract class AbstractCommandExecutor {
command
.
add
(
"sudo"
);
command
.
add
(
"-u"
);
command
.
add
(
taskRequest
.
getTenantCode
());
command
.
add
(
SH
);
command
.
add
(
commandInterpreter
()
);
command
.
addAll
(
Collections
.
emptyList
());
command
.
add
(
commandFile
);
...
...
dolphinscheduler-task-plugin/dolphinscheduler-task-python/src/main/java/org/apache/dolphinscheduler/plugin/task/python/PythonTask.java
浏览文件 @
0715be34
...
...
@@ -21,9 +21,13 @@ import org.apache.dolphinscheduler.plugin.task.api.AbstractTaskExecutor;
import
org.apache.dolphinscheduler.plugin.task.api.TaskException
;
import
org.apache.dolphinscheduler.plugin.task.api.TaskResponse
;
import
org.apache.dolphinscheduler.spi.task.AbstractParameters
;
import
org.apache.dolphinscheduler.spi.task.Property
;
import
org.apache.dolphinscheduler.spi.task.TaskConstants
;
import
org.apache.dolphinscheduler.spi.task.paramparser.ParamUtils
;
import
org.apache.dolphinscheduler.spi.task.paramparser.ParameterUtils
;
import
org.apache.dolphinscheduler.spi.task.request.TaskRequest
;
import
org.apache.dolphinscheduler.spi.utils.JSONUtils
;
import
java.util.Map
;
/**
* python task
...
...
@@ -48,8 +52,6 @@ public class PythonTask extends AbstractTaskExecutor {
private
TaskRequest
taskRequest
;
private
String
command
;
/**
* constructor
*
...
...
@@ -86,17 +88,12 @@ public class PythonTask extends AbstractTaskExecutor {
return
rawPythonScript
;
}
@Override
public
void
setCommand
(
String
command
)
{
this
.
command
=
command
;
}
@Override
public
void
handle
()
throws
Exception
{
try
{
// construct process
// construct process
String
command
=
buildCommand
();
TaskResponse
taskResponse
=
pythonCommandExecutor
.
run
(
command
);
setExitStatusCode
(
taskResponse
.
getExitStatusCode
());
setAppIds
(
taskResponse
.
getAppIds
());
setProcessId
(
taskResponse
.
getProcessId
());
...
...
@@ -151,4 +148,25 @@ public class PythonTask extends AbstractTaskExecutor {
return
rawScript
;
}
/**
* build command
* @return raw python script
* @throws Exception exception
*/
private
String
buildCommand
()
throws
Exception
{
String
rawPythonScript
=
pythonParameters
.
getRawScript
().
replaceAll
(
"\\r\\n"
,
"\n"
);
// replace placeholder
Map
<
String
,
Property
>
paramsMap
=
ParamUtils
.
convert
(
taskRequest
,
pythonParameters
);
if
(
paramsMap
!=
null
){
rawPythonScript
=
ParameterUtils
.
convertParameterPlaceholders
(
rawPythonScript
,
ParamUtils
.
convert
(
paramsMap
));
}
logger
.
info
(
"raw python script : {}"
,
pythonParameters
.
getRawScript
());
logger
.
info
(
"task dir : {}"
,
taskDir
);
return
rawPythonScript
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录