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

add taskName parameter to parseRuntimeInfoFromExecutions function #2819

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 @@ -166,23 +166,23 @@ describe('pipeline topology parseUtils', () => {
const testTaskId = 'test-task-id';

it('returns undefined when executions are not provided', () => {
const result = parseRuntimeInfoFromExecutions(testTaskId);
const result = parseRuntimeInfoFromExecutions(testTaskId, testTaskId);
expect(result).toBeUndefined();
});

it('returns undefined when executions is null', () => {
const result = parseRuntimeInfoFromExecutions(testTaskId, null);
const result = parseRuntimeInfoFromExecutions(testTaskId, testTaskId, null);
expect(result).toBeUndefined();
});

it('returns undefined when executions are empty', () => {
const result = parseRuntimeInfoFromExecutions(testTaskId, []);
const result = parseRuntimeInfoFromExecutions(testTaskId, testTaskId, []);
expect(result).toBeUndefined();
});

it('returns undefined when there are no match executions', () => {
const mockExecution = new Execution();
const result = parseRuntimeInfoFromExecutions(testTaskId, [mockExecution]);
const result = parseRuntimeInfoFromExecutions(testTaskId, testTaskId, [mockExecution]);
expect(result).toBeUndefined();
});

Expand All @@ -193,7 +193,7 @@ describe('pipeline topology parseUtils', () => {
mockExecution.setCreateTimeSinceEpoch(1713285296322);
mockExecution.setLastUpdateTimeSinceEpoch(1713285296524);
mockExecution.setLastKnownState(Execution.State.COMPLETE);
const result = parseRuntimeInfoFromExecutions(testTaskId, [mockExecution]);
const result = parseRuntimeInfoFromExecutions(testTaskId, testTaskId, [mockExecution]);
expect(result).toStrictEqual({
completeTime: '2024-04-16T16:34:56.524Z',
podName: undefined,
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/concepts/pipelines/topology/parseUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,14 +182,15 @@ export const parseRuntimeInfoFromRunDetails = (

export const parseRuntimeInfoFromExecutions = (
taskId: string,
taskName: string,
executions?: Execution[] | null,
): PipelineTaskRunStatus | undefined => {
if (!executions) {
return undefined;
}

const execution = executions.find(
(e) => e.getCustomPropertiesMap().get('task_name')?.getStringValue() === taskId,
(e) => e.getCustomPropertiesMap().get('task_name')?.getStringValue() === (taskName || taskId),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If both of taskName & taskId props are required and not possibly undefined (since the type is simply string, this will always use the taskName. Maybe taskName is meant to be optional and just used to override the usage of taskId?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not necessarily. I used || which will used the taskId if taskName is "", which is what i noticed in cases where the label is empty for some reason.

in JS:

a = "";
b = "defined"
a || b == "defined"

);

if (!execution) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ const getNodesForTasks = (
const taskName = details.taskInfo.name;

const status =
parseRuntimeInfoFromExecutions(taskId, executions) ||
parseRuntimeInfoFromExecutions(taskId, taskName, executions) ||
parseRuntimeInfoFromRunDetails(taskId, runDetails);
const runStatus = translateStatusForNode(status?.state);

Expand Down
Loading