diff --git a/frontend/src/concepts/pipelines/topology/usePipelineTaskTopology.tsx b/frontend/src/concepts/pipelines/topology/usePipelineTaskTopology.tsx index bcbe911a2f..b012f308fe 100644 --- a/frontend/src/concepts/pipelines/topology/usePipelineTaskTopology.tsx +++ b/frontend/src/concepts/pipelines/topology/usePipelineTaskTopology.tsx @@ -26,12 +26,12 @@ import { TaskArtifactMap, translateStatusForNode, } from './parseUtils'; -import { PipelineTask, PipelineTaskRunStatus } from './pipelineTaskTypes'; +import { PipelineTask } from './pipelineTaskTypes'; const getArtifactPipelineTask = ( name: string, artifactType: InputOutputArtifactType, - artifactData: Artifact | undefined, + artifactData?: Artifact, ): PipelineTask => ({ type: 'artifact', name, @@ -46,9 +46,7 @@ const getArtifactPipelineTask = ( */ const getInputArtifacts = ( groupId: string | undefined, - status: PipelineTaskRunStatus | undefined, inputArtifacts: InputOutputDefinitionArtifacts | undefined, - artifactData: Artifact | undefined, ) => { if (!inputArtifacts) { return []; @@ -58,9 +56,8 @@ const getInputArtifacts = ( createArtifactNode( idForTaskArtifact(groupId, '', artifactKey), artifactKey, - getArtifactPipelineTask(artifactKey, artifactType, artifactData), + getArtifactPipelineTask(artifactKey, artifactType), undefined, - translateStatusForNode(status?.state), artifactType.schemaTitle, ), ); @@ -69,10 +66,11 @@ const getInputArtifacts = ( const getTaskArtifacts = ( groupId: string | undefined, taskId: string, - status: PipelineTaskRunStatus | undefined, componentRef: string, componentArtifactMap: ComponentArtifactMap, - artifactData: Artifact | undefined, + artifacts: Artifact[] | undefined, + events: Event[] | undefined, + executions: Execution[] | undefined, ): PipelineNodeModelExpanded[] => { const artifactsInComponent = componentArtifactMap[componentRef]; @@ -80,16 +78,29 @@ const getTaskArtifacts = ( return []; } - return Object.entries(artifactsInComponent).map(([artifactKey, data]) => - createArtifactNode( + const execution = executions?.find( + (e) => e.getCustomPropertiesMap().get('task_name')?.getStringValue() === taskId, + ); + + const executionEvents = events?.filter((event) => event.getExecutionId() === execution?.getId()); + + return Object.entries(artifactsInComponent).map(([artifactKey, data]) => { + const artifactData = artifacts?.find((artifact) => { + const artifactEvent = executionEvents?.find( + (event) => event.getArtifactId() === artifact.getId(), + ); + + return artifactEvent && artifact.getType() === data.schemaTitle; + }); + + return createArtifactNode( idForTaskArtifact(groupId, taskId, artifactKey), artifactKey, getArtifactPipelineTask(artifactKey, data, artifactData), [taskId], - translateStatusForNode(status?.state), data.schemaTitle, - ), - ); + ); + }); }; const getNodesForTasks = ( @@ -101,10 +112,10 @@ const getNodesForTasks = ( componentArtifactMap: ComponentArtifactMap, taskArtifactMap: TaskArtifactMap, runDetails?: RunDetailsKF, - executions?: Execution[] | null, + executions?: Execution[], inputArtifacts?: InputOutputDefinitionArtifacts, events?: Event[], - artifacts?: Artifact[] | undefined, + artifacts?: Artifact[], ): [nestedNodes: PipelineNodeModelExpanded[], children: string[]] => { const nodes: PipelineNodeModelExpanded[] = []; const children: string[] = []; @@ -139,25 +150,15 @@ const getNodesForTasks = ( volumeMounts: parseVolumeMounts(spec.platform_spec, executorLabel), }; - const artifactData = artifacts?.find((artifact) => { - const artifactEvent = events?.find((event) => event.getArtifactId() === artifact.getId()); - const artifactExecution = executions?.find( - (execution) => execution.getId() === artifactEvent?.getExecutionId(), - ); - - return ( - artifactExecution?.getCustomPropertiesMap().get('task_name')?.getStringValue() === taskId - ); - }); - // Build artifact nodes with inputs from task nodes const artifactNodes = getTaskArtifacts( groupId, taskId, - status, componentRef, componentArtifactMap, - artifactData, + artifacts, + events, + executions, ); if (artifactNodes.length) { nodes.push(...artifactNodes); @@ -165,7 +166,7 @@ const getNodesForTasks = ( } // Build artifact nodes without inputs - const inputArtifactNodes = getInputArtifacts(groupId, status, inputArtifacts, artifactData); + const inputArtifactNodes = getInputArtifacts(groupId, inputArtifacts); if (inputArtifactNodes.length) { nodes.push(...inputArtifactNodes); children.push(...inputArtifactNodes.map((n) => n.id)); @@ -190,6 +191,8 @@ const getNodesForTasks = ( runDetails, executions, component?.inputDefinitions?.artifacts, + events, + artifacts, ); const itemNode = createGroupNode( @@ -213,9 +216,9 @@ const getNodesForTasks = ( export const usePipelineTaskTopology = ( spec?: PipelineSpecVariable, runDetails?: RunDetailsKF, - executions?: Execution[] | null, + executions?: Execution[], events?: Event[], - artifacts?: Artifact[] | undefined, + artifacts?: Artifact[], ): PipelineNodeModelExpanded[] => React.useMemo(() => { if (!spec) { diff --git a/frontend/src/concepts/topology/utils.ts b/frontend/src/concepts/topology/utils.ts index 006408098e..1f58900e0e 100644 --- a/frontend/src/concepts/topology/utils.ts +++ b/frontend/src/concepts/topology/utils.ts @@ -38,7 +38,6 @@ export const createArtifactNode = ( label: string, pipelineTask: PipelineTask, runAfterTasks?: string[], - runStatus?: RunStatus, artifactType?: string, ): PipelineNodeModelExpanded => ({ id, @@ -50,7 +49,6 @@ export const createArtifactNode = ( data: { pipelineTask, artifactType, - runStatus, }, });