feat: Parallel Execution of Nodes in Workflows (#8192)
Co-authored-by: StyleZhang <jasonapring2015@outlook.com> Co-authored-by: Yi <yxiaoisme@gmail.com> Co-authored-by: -LAN- <laipz8200@outlook.com>
This commit is contained in:
@@ -196,8 +196,6 @@ const Result: FC<IResultProps> = ({
|
||||
})()
|
||||
|
||||
if (isWorkflow) {
|
||||
let isInIteration = false
|
||||
|
||||
sendWorkflowMessage(
|
||||
data,
|
||||
{
|
||||
@@ -219,23 +217,28 @@ const Result: FC<IResultProps> = ({
|
||||
expand: true,
|
||||
} as any)
|
||||
}))
|
||||
isInIteration = true
|
||||
},
|
||||
onIterationNext: () => {
|
||||
setWorkflowProccessData(produce(getWorkflowProccessData()!, (draft) => {
|
||||
draft.expand = true
|
||||
const iterations = draft.tracing.find(item => item.node_id === data.node_id
|
||||
&& (item.execution_metadata?.parallel_id === data.execution_metadata?.parallel_id || item.parallel_id === data.execution_metadata?.parallel_id))!
|
||||
iterations?.details!.push([])
|
||||
}))
|
||||
},
|
||||
onIterationFinish: ({ data }) => {
|
||||
setWorkflowProcessData(produce(getWorkflowProcessData()!, (draft) => {
|
||||
draft.expand = true
|
||||
// const iteration = draft.tracing![draft.tracing!.length - 1]
|
||||
draft.tracing![draft.tracing!.length - 1] = {
|
||||
const iterationsIndex = draft.tracing.findIndex(item => item.node_id === data.node_id
|
||||
&& (item.execution_metadata?.parallel_id === data.execution_metadata?.parallel_id || item.parallel_id === data.execution_metadata?.parallel_id))!
|
||||
draft.tracing[iterationsIndex] = {
|
||||
...data,
|
||||
expand: !!data.error,
|
||||
} as any
|
||||
}))
|
||||
isInIteration = false
|
||||
},
|
||||
onNodeStarted: ({ data }) => {
|
||||
if (isInIteration)
|
||||
if (data.iteration_id)
|
||||
return
|
||||
|
||||
setWorkflowProcessData(produce(getWorkflowProcessData()!, (draft) => {
|
||||
@@ -248,11 +251,12 @@ const Result: FC<IResultProps> = ({
|
||||
}))
|
||||
},
|
||||
onNodeFinished: ({ data }) => {
|
||||
if (isInIteration)
|
||||
if (data.iteration_id)
|
||||
return
|
||||
|
||||
setWorkflowProcessData(produce(getWorkflowProcessData()!, (draft) => {
|
||||
const currentIndex = draft.tracing!.findIndex(trace => trace.node_id === data.node_id)
|
||||
const currentIndex = draft.tracing!.findIndex(trace => trace.node_id === data.node_id
|
||||
&& (trace.execution_metadata?.parallel_id === data.execution_metadata?.parallel_id || trace.parallel_id === data.execution_metadata?.parallel_id))
|
||||
if (currentIndex > -1 && draft.tracing) {
|
||||
draft.tracing[currentIndex] = {
|
||||
...(draft.tracing[currentIndex].extras
|
||||
|
Reference in New Issue
Block a user