Skip to content

Commit

Permalink
fix: Incorrect iteration log display in workflow with multiple parall…
Browse files Browse the repository at this point in the history
…el mode iteartaion nodes (#11158)

Co-authored-by: Novice Lee <novicelee@NovicedeMacBook-Pro.local>
  • Loading branch information
Nov1c444 and Novice Lee authored Nov 27, 2024
1 parent a918cea commit baef18c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 10 deletions.
19 changes: 13 additions & 6 deletions web/app/components/workflow/hooks/use-workflow-run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,13 +271,18 @@ export const useWorkflowRun = () => {
} as any)
}
else {
if (!iterParallelLogMap.has(data.parallel_run_id))
iterParallelLogMap.set(data.parallel_run_id, [{ ...data, status: NodeRunningStatus.Running } as any])
const nodeId = iterations?.node_id as string
if (!iterParallelLogMap.has(nodeId as string))
iterParallelLogMap.set(iterations?.node_id as string, new Map())

const currentIterLogMap = iterParallelLogMap.get(nodeId)!
if (!currentIterLogMap.has(data.parallel_run_id))
currentIterLogMap.set(data.parallel_run_id, [{ ...data, status: NodeRunningStatus.Running } as any])
else
iterParallelLogMap.get(data.parallel_run_id)!.push({ ...data, status: NodeRunningStatus.Running } as any)
currentIterLogMap.get(data.parallel_run_id)!.push({ ...data, status: NodeRunningStatus.Running } as any)
setIterParallelLogMap(iterParallelLogMap)
if (iterations)
iterations.details = Array.from(iterParallelLogMap.values())
iterations.details = Array.from(currentIterLogMap.values())
}
}))
}
Expand Down Expand Up @@ -373,7 +378,7 @@ export const useWorkflowRun = () => {
if (iterations && iterations.details) {
const iterRunID = data.execution_metadata?.parallel_mode_run_id

const currIteration = iterParallelLogMap.get(iterRunID)
const currIteration = iterParallelLogMap.get(iterations.node_id)?.get(iterRunID)
const nodeIndex = currIteration?.findIndex(node =>
node.node_id === data.node_id && (
node?.parallel_run_id === data.execution_metadata?.parallel_mode_run_id),
Expand All @@ -392,7 +397,9 @@ export const useWorkflowRun = () => {
}
}
setIterParallelLogMap(iterParallelLogMap)
iterations.details = Array.from(iterParallelLogMap.values())
const iterLogMap = iterParallelLogMap.get(iterations.node_id)
if (iterLogMap)
iterations.details = Array.from(iterLogMap.values())
}
}))
}
Expand Down
10 changes: 9 additions & 1 deletion web/app/components/workflow/run/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,27 @@ const RunPanel: FC<RunProps> = ({ hideResult, activeTab = 'RESULT', runID, getRe
const formatNodeList = useCallback((list: NodeTracing[]) => {
const allItems = [...list].reverse()
const result: NodeTracing[] = []
const groupMap = new Map<string, NodeTracing[]>()
const nodeGroupMap = new Map<string, Map<string, NodeTracing[]>>()

const processIterationNode = (item: NodeTracing) => {
result.push({
...item,
details: [],
})
}

const updateParallelModeGroup = (runId: string, item: NodeTracing, iterationNode: NodeTracing) => {
if (!nodeGroupMap.has(iterationNode.node_id))
nodeGroupMap.set(iterationNode.node_id, new Map())

const groupMap = nodeGroupMap.get(iterationNode.node_id)!

if (!groupMap.has(runId))
groupMap.set(runId, [item])

else
groupMap.get(runId)!.push(item)

if (item.status === 'failed') {
iterationNode.status = 'failed'
iterationNode.error = item.error
Expand Down
6 changes: 3 additions & 3 deletions web/app/components/workflow/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@ type Shape = {
setShowTips: (showTips: string) => void
iterTimes: number
setIterTimes: (iterTimes: number) => void
iterParallelLogMap: Map<string, NodeTracing[]>
setIterParallelLogMap: (iterParallelLogMap: Map<string, NodeTracing[]>) => void
iterParallelLogMap: Map<string, Map<string, NodeTracing[]>>
setIterParallelLogMap: (iterParallelLogMap: Map<string, Map<string, NodeTracing[]>>) => void
}

export const createWorkflowStore = () => {
Expand Down Expand Up @@ -288,7 +288,7 @@ export const createWorkflowStore = () => {
setShowTips: showTips => set(() => ({ showTips })),
iterTimes: 1,
setIterTimes: iterTimes => set(() => ({ iterTimes })),
iterParallelLogMap: new Map<string, NodeTracing[]>(),
iterParallelLogMap: new Map<string, Map<string, NodeTracing[]>>(),
setIterParallelLogMap: iterParallelLogMap => set(() => ({ iterParallelLogMap })),

}))
Expand Down

0 comments on commit baef18c

Please sign in to comment.