Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
csst
Scalebox Apps
Commits
225b9a01
Commit
225b9a01
authored
Dec 20, 2024
by
Zhang Xiaoli
Browse files
增加 --header repeatable=yes 可修改正在运行的task状态,使其重新执行
parent
d3c47ad6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
1 deletion
+16
-1
L1/pipelines/csst-msc-l1-mbi/message-router/messageRoute.py
L1/pipelines/csst-msc-l1-mbi/message-router/messageRoute.py
+16
-1
No files found.
L1/pipelines/csst-msc-l1-mbi/message-router/messageRoute.py
View file @
225b9a01
...
@@ -99,19 +99,34 @@ class messageRoute():
...
@@ -99,19 +99,34 @@ class messageRoute():
def
sendmsg
(
self
,
dag_run_id
,
job
,
message
):
def
sendmsg
(
self
,
dag_run_id
,
job
,
message
):
#执行解包操作
#执行解包操作
print
(
"sendmsg dag_run_id is "
+
dag_run_id
)
print
(
"sendmsg dag_run_id is "
+
dag_run_id
)
messageRoute
.
append_dagrunid
(
dag_run_id
)
message
=
"'"
+
message
+
"'"
message
=
"'"
+
message
+
"'"
command
=
f
"scalebox task add --header dag_run_id=
{
dag_run_id
}
--upsert --sink-job=
{
job
}
{
message
}
"
command
=
f
"scalebox task add --header dag_run_id=
{
dag_run_id
}
--header repeatable=yes
--upsert --sink-job=
{
job
}
{
message
}
"
print
(
"command : "
+
command
)
print
(
"command : "
+
command
)
result
=
subprocess
.
run
(
command
,
shell
=
True
)
result
=
subprocess
.
run
(
command
,
shell
=
True
)
if
result
.
returncode
==
0
:
if
result
.
returncode
==
0
:
print
(
f
"send message
{
message
}
to
{
job
}
"
)
print
(
f
"send message
{
message
}
to
{
job
}
"
)
# dag_run_id记入/work/extra-attributes.txt
print
(
"命令执行成功"
)
print
(
"命令执行成功"
)
return
result
.
returncode
return
result
.
returncode
else
:
else
:
print
(
f
"命令执行失败,返回码为:
{
result
.
returncode
}
"
)
print
(
f
"命令执行失败,返回码为:
{
result
.
returncode
}
"
)
return
result
.
returncode
return
result
.
returncode
@
classmethod
def
append_dagrunid
(
self
,
dag_run_id
):
file_path
=
'/work/extra-attributes.txt'
content_to_append
=
f
"dag_run_id:
{
dag_run_id
}
\n
"
# 以追加模式打开文件
try
:
with
open
(
file_path
,
'a'
,
encoding
=
'utf-8'
)
as
file
:
# 追加内容
file
.
write
(
content_to_append
)
print
(
f
"追加完成,dag_run_id :
{
dag_run_id
}
"
)
except
IOError
as
e
:
print
(
f
"写入文件/work/extra-attributes.txt时发生错误:
{
e
}
"
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
parameter
=
sys
.
argv
parameter
=
sys
.
argv
message
=
parameter
[
1
]
message
=
parameter
[
1
]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment