Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show correct artifact run node details on artifact side drawer panel #2885

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@
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,
Expand All @@ -51,9 +51,7 @@
*/
const getInputArtifacts = (
groupId: string | undefined,
status: PipelineTaskRunStatus | undefined,
inputArtifacts: InputOutputDefinitionArtifacts | undefined,
artifactData: Artifact | undefined,
) => {
if (!inputArtifacts) {
return [];
Expand All @@ -63,9 +61,8 @@
createArtifactNode(
idForTaskArtifact(groupId, '', artifactKey),
artifactKey,
getArtifactPipelineTask(artifactKey, artifactType, artifactData),
getArtifactPipelineTask(artifactKey, artifactType),
undefined,
translateStatusForNode(status?.state),
artifactType.schemaTitle,
),
);
Expand All @@ -74,27 +71,41 @@
const getTaskArtifacts = (
groupId: string | undefined,
taskId: string,
status: PipelineTaskRunStatus | undefined,
componentRef: string,
componentArtifactMap: ComponentArtifactMap,
artifactData: Artifact | undefined,
artifacts?: Artifact[],
events?: Event[] | null,
executions?: Execution[] | null,
): PipelineNodeModelExpanded[] => {
const artifactsInComponent = componentArtifactMap[componentRef];

if (!artifactsInComponent) {
return [];
}

return Object.entries(artifactsInComponent).map(([artifactKey, data]) =>
createArtifactNode(
const execution = executions?.find(
(e) => e.getCustomPropertiesMap().get('task_name')?.getStringValue() === taskId,

Check warning on line 87 in frontend/src/concepts/pipelines/topology/usePipelineTaskTopology.tsx

View check run for this annotation

Codecov / codecov/patch

frontend/src/concepts/pipelines/topology/usePipelineTaskTopology.tsx#L87

Added line #L87 was not covered by tests
);

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(),

Check warning on line 95 in frontend/src/concepts/pipelines/topology/usePipelineTaskTopology.tsx

View check run for this annotation

Codecov / codecov/patch

frontend/src/concepts/pipelines/topology/usePipelineTaskTopology.tsx#L94-L95

Added lines #L94 - L95 were not covered by tests
);

return artifactEvent && artifact.getType() === data.schemaTitle;

Check warning on line 98 in frontend/src/concepts/pipelines/topology/usePipelineTaskTopology.tsx

View check run for this annotation

Codecov / codecov/patch

frontend/src/concepts/pipelines/topology/usePipelineTaskTopology.tsx#L98

Added line #L98 was not covered by tests
});

return createArtifactNode(
idForTaskArtifact(groupId, taskId, artifactKey),
artifactKey,
getArtifactPipelineTask(artifactKey, data, artifactData),
[taskId],
translateStatusForNode(status?.state),
data.schemaTitle,
),
);
);
});
};

const getNodesForTasks = (
Expand All @@ -109,8 +120,8 @@
runDetails?: RunDetailsKF,
executions?: Execution[] | null,
inputArtifacts?: InputOutputDefinitionArtifacts,
events?: Event[],
artifacts?: Artifact[] | undefined,
events?: Event[] | null,
artifacts?: Artifact[],
): [nestedNodes: PipelineNodeModelExpanded[], children: string[]] => {
const nodes: PipelineNodeModelExpanded[] = [];
const children: string[] = [];
Expand Down Expand Up @@ -166,33 +177,23 @@
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);
children.push(...artifactNodes.map((n) => n.id));
}

// 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));
Expand All @@ -218,6 +219,8 @@
runDetails,
executions,
component?.inputDefinitions?.artifacts,
events,
artifacts,
);

const itemNode = createGroupNode(
Expand All @@ -243,7 +246,7 @@
runDetails?: RunDetailsKF,
executions?: Execution[] | null,
events?: Event[] | null,
artifacts?: Artifact[] | undefined,
artifacts?: Artifact[],
): PipelineNodeModelExpanded[] =>
React.useMemo(() => {
if (!spec) {
Expand Down
3 changes: 1 addition & 2 deletions frontend/src/concepts/topology/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ export const createArtifactNode = (
label: string,
pipelineTask: PipelineTask,
runAfterTasks?: string[],
runStatus?: RunStatus,
artifactType?: string,
): PipelineNodeModelExpanded => ({
id,
Expand All @@ -47,7 +46,7 @@ export const createArtifactNode = (
data: {
pipelineTask,
artifactType,
runStatus,
runStatus: pipelineTask.metadata ? RunStatus.Succeeded : undefined,
},
});

Expand Down
Loading