mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-14 04:05:53 +08:00
fix: Incorrect iteration log display in workflow with multiple parallel mode iteartaion nodes (#11158)
Co-authored-by: Novice Lee <novicelee@NovicedeMacBook-Pro.local>
This commit is contained in:
parent
a918cea2fe
commit
baef18cedd
@ -271,13 +271,18 @@ export const useWorkflowRun = () => {
|
|||||||
} as any)
|
} as any)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (!iterParallelLogMap.has(data.parallel_run_id))
|
const nodeId = iterations?.node_id as string
|
||||||
iterParallelLogMap.set(data.parallel_run_id, [{ ...data, status: NodeRunningStatus.Running } as any])
|
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
|
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)
|
setIterParallelLogMap(iterParallelLogMap)
|
||||||
if (iterations)
|
if (iterations)
|
||||||
iterations.details = Array.from(iterParallelLogMap.values())
|
iterations.details = Array.from(currentIterLogMap.values())
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
@ -373,7 +378,7 @@ export const useWorkflowRun = () => {
|
|||||||
if (iterations && iterations.details) {
|
if (iterations && iterations.details) {
|
||||||
const iterRunID = data.execution_metadata?.parallel_mode_run_id
|
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 =>
|
const nodeIndex = currIteration?.findIndex(node =>
|
||||||
node.node_id === data.node_id && (
|
node.node_id === data.node_id && (
|
||||||
node?.parallel_run_id === data.execution_metadata?.parallel_mode_run_id),
|
node?.parallel_run_id === data.execution_metadata?.parallel_mode_run_id),
|
||||||
@ -392,7 +397,9 @@ export const useWorkflowRun = () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
setIterParallelLogMap(iterParallelLogMap)
|
setIterParallelLogMap(iterParallelLogMap)
|
||||||
iterations.details = Array.from(iterParallelLogMap.values())
|
const iterLogMap = iterParallelLogMap.get(iterations.node_id)
|
||||||
|
if (iterLogMap)
|
||||||
|
iterations.details = Array.from(iterLogMap.values())
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@ const RunPanel: FC<RunProps> = ({ hideResult, activeTab = 'RESULT', runID, getRe
|
|||||||
const formatNodeList = useCallback((list: NodeTracing[]) => {
|
const formatNodeList = useCallback((list: NodeTracing[]) => {
|
||||||
const allItems = [...list].reverse()
|
const allItems = [...list].reverse()
|
||||||
const result: NodeTracing[] = []
|
const result: NodeTracing[] = []
|
||||||
const groupMap = new Map<string, NodeTracing[]>()
|
const nodeGroupMap = new Map<string, Map<string, NodeTracing[]>>()
|
||||||
|
|
||||||
const processIterationNode = (item: NodeTracing) => {
|
const processIterationNode = (item: NodeTracing) => {
|
||||||
result.push({
|
result.push({
|
||||||
@ -70,11 +70,19 @@ const RunPanel: FC<RunProps> = ({ hideResult, activeTab = 'RESULT', runID, getRe
|
|||||||
details: [],
|
details: [],
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const updateParallelModeGroup = (runId: string, item: NodeTracing, iterationNode: NodeTracing) => {
|
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))
|
if (!groupMap.has(runId))
|
||||||
groupMap.set(runId, [item])
|
groupMap.set(runId, [item])
|
||||||
|
|
||||||
else
|
else
|
||||||
groupMap.get(runId)!.push(item)
|
groupMap.get(runId)!.push(item)
|
||||||
|
|
||||||
if (item.status === 'failed') {
|
if (item.status === 'failed') {
|
||||||
iterationNode.status = 'failed'
|
iterationNode.status = 'failed'
|
||||||
iterationNode.error = item.error
|
iterationNode.error = item.error
|
||||||
|
@ -169,8 +169,8 @@ type Shape = {
|
|||||||
setShowTips: (showTips: string) => void
|
setShowTips: (showTips: string) => void
|
||||||
iterTimes: number
|
iterTimes: number
|
||||||
setIterTimes: (iterTimes: number) => void
|
setIterTimes: (iterTimes: number) => void
|
||||||
iterParallelLogMap: Map<string, NodeTracing[]>
|
iterParallelLogMap: Map<string, Map<string, NodeTracing[]>>
|
||||||
setIterParallelLogMap: (iterParallelLogMap: Map<string, NodeTracing[]>) => void
|
setIterParallelLogMap: (iterParallelLogMap: Map<string, Map<string, NodeTracing[]>>) => void
|
||||||
}
|
}
|
||||||
|
|
||||||
export const createWorkflowStore = () => {
|
export const createWorkflowStore = () => {
|
||||||
@ -288,7 +288,7 @@ export const createWorkflowStore = () => {
|
|||||||
setShowTips: showTips => set(() => ({ showTips })),
|
setShowTips: showTips => set(() => ({ showTips })),
|
||||||
iterTimes: 1,
|
iterTimes: 1,
|
||||||
setIterTimes: iterTimes => set(() => ({ iterTimes })),
|
setIterTimes: iterTimes => set(() => ({ iterTimes })),
|
||||||
iterParallelLogMap: new Map<string, NodeTracing[]>(),
|
iterParallelLogMap: new Map<string, Map<string, NodeTracing[]>>(),
|
||||||
setIterParallelLogMap: iterParallelLogMap => set(() => ({ iterParallelLogMap })),
|
setIterParallelLogMap: iterParallelLogMap => set(() => ({ iterParallelLogMap })),
|
||||||
|
|
||||||
}))
|
}))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user