Skip to content

Commit

Permalink
fix: dynamic-node-tasks (#765)
Browse files Browse the repository at this point in the history
* fix: dynamic-node-tasks

* fix: check for dynamic tasks in execution detaisl context provider

* chore: fix fetching task template

Signed-off-by: Carina Ursu <[email protected]>

* chore: minor fixes

Signed-off-by: Soham <[email protected]>

* chore: pkg

Signed-off-by: Carina Ursu <[email protected]>

* fix: dynamic parent execution not fetched for some tasks

Signed-off-by: Soham <[email protected]>

* fix: dynamic parent execution not fetched for some tasks

Signed-off-by: Soham <[email protected]>

---------

Signed-off-by: Carina Ursu <[email protected]>
Signed-off-by: Soham <[email protected]>
Co-authored-by: Carina Ursu <[email protected]>
  • Loading branch information
4nalog and ursucarina authored May 24, 2023
1 parent b15640a commit 39c252d
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 13 deletions.
2 changes: 1 addition & 1 deletion packages/console/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@flyteorg/console",
"version": "0.0.36",
"version": "0.0.37",
"description": "Flyteconsole main app module",
"main": "./dist/index.js",
"module": "./lib/index.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ export const NodeExecutionDetailsContextProvider = ({
const taskDetails = await getTaskThroughExecution(
queryClient,
nodeExecution,
closure,
);

const tasksMap = tasks;
Expand Down Expand Up @@ -160,7 +161,10 @@ export const NodeExecutionDetailsContextProvider = ({
}

// look for specific task by nodeId in current execution
if (nodeExecution.metadata?.isDynamic) {
if (
nodeExecution.metadata?.isDynamic ||
nodeExecution.dynamicParentNodeId
) {
details = await getDynamicTasks(nodeExecution);
}
return details;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,40 @@ import { getTaskDisplayType } from 'components/Executions/utils';
import { fetchTaskExecutionList } from 'components/Executions/taskExecutionQueries';
import { NodeExecutionDetails } from 'components/Executions/types';
import { fetchTaskTemplate } from 'components/Task/taskQueries';
import { NodeExecution } from 'models/Execution/types';
import { TaskTemplate } from 'models/Task/types';
import { QueryClient } from 'react-query/types/core/queryClient';
import { WorkflowNodeExecution } from 'components/Executions/contexts';
import { CompiledWorkflowClosure } from 'models';
import { isEqual } from 'lodash';

export const getTaskThroughExecution = async (
queryClient: QueryClient,
nodeExecution: NodeExecution,
nodeExecution: WorkflowNodeExecution,
closure: CompiledWorkflowClosure,
): Promise<NodeExecutionDetails> => {
const taskExecutions = await fetchTaskExecutionList(
queryClient,
nodeExecution.id,
);
const taskExecutions = await (nodeExecution?.tasksFetched
? // if the nodeExecution tasks were already fetched, use them
Promise.resolve(nodeExecution.taskExecutions || [])
: // otherwise, fetch them
fetchTaskExecutionList(queryClient, nodeExecution.id));

let taskTemplate: TaskTemplate | undefined = undefined;
if (taskExecutions && taskExecutions.length > 0) {
let taskTemplate: TaskTemplate = closure?.tasks?.find(task =>
isEqual(task.template.id, taskExecutions[0].id.taskId),
)?.template as TaskTemplate;

if (
// skip request if the template was found
!taskTemplate &&
// skip request if the node has a dynamic parent
!nodeExecution.dynamicParentNodeId &&
taskExecutions &&
taskExecutions.length > 0
) {
taskTemplate = await fetchTaskTemplate(
queryClient,
taskExecutions[0].id.taskId,
);

if (!taskTemplate) {
// eslint-disable-next-line no-console
console.error(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,9 @@ const parseNode = ({
/* 1. Add primary workflow as subworkflow on root */
if (getSubWorkflowFromId(dWorkflowId, workflow) === false) {
workflow.subWorkflows?.push(dPrimaryWorkflow);

workflow.tasks = workflow.tasks || [];
workflow.tasks?.push(...dynamicWorkflow.compiledWorkflow.tasks);
}

/* 2. Add subworkflows as subworkflows on root */
Expand All @@ -226,6 +229,7 @@ const parseNode = ({
const subId = subworkflow.template.id;
if (getSubWorkflowFromId(subId, workflow) === false) {
workflow.subWorkflows?.push(subworkflow);
workflow.tasks?.push(...subworkflow.compiledWorkflow.tasks);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
},
"dependencies": {
"@flyteorg/common": "^0.0.4",
"@flyteorg/console": "^0.0.36",
"@flyteorg/console": "^0.0.37",
"long": "^4.0.0",
"protobufjs": "~6.11.3",
"react-ga4": "^1.4.1",
Expand Down
4 changes: 2 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2020,7 +2020,7 @@ __metadata:
resolution: "@flyteconsole/client-app@workspace:website"
dependencies:
"@flyteorg/common": ^0.0.4
"@flyteorg/console": ^0.0.36
"@flyteorg/console": ^0.0.37
"@types/long": ^3.0.32
long: ^4.0.0
protobufjs: ~6.11.3
Expand Down Expand Up @@ -2059,7 +2059,7 @@ __metadata:
languageName: unknown
linkType: soft

"@flyteorg/console@^0.0.36, @flyteorg/console@workspace:packages/console":
"@flyteorg/console@^0.0.37, @flyteorg/console@workspace:packages/console":
version: 0.0.0-use.local
resolution: "@flyteorg/console@workspace:packages/console"
dependencies:
Expand Down

0 comments on commit 39c252d

Please sign in to comment.