Skip to content

Commit

Permalink
fix: Tasks status out of sync (#802)
Browse files Browse the repository at this point in the history
* fix: tasks status out of sync

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

* chore: pkg

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

---------

Signed-off-by: Carina Ursu <[email protected]>
  • Loading branch information
ursucarina authored Jul 26, 2023
1 parent fd145ec commit 8872536
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 50 deletions.
2 changes: 1 addition & 1 deletion packages/components/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@flyteorg/components",
"version": "0.0.3",
"version": "0.0.4",
"description": "Flyteconsole Components module, which is published as npm package and can be consumed by 3rd parties",
"main": "./dist/index.js",
"module": "./lib/index.js",
Expand Down
4 changes: 2 additions & 2 deletions packages/console/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@flyteorg/console",
"version": "0.0.45",
"version": "0.0.46",
"description": "Flyteconsole main app module",
"main": "./dist/index.js",
"module": "./lib/index.js",
Expand Down Expand Up @@ -57,7 +57,7 @@
"@date-io/moment": "1.3.9",
"@emotion/core": "10.1.1",
"@flyteorg/common": "^0.0.4",
"@flyteorg/components": "^0.0.3",
"@flyteorg/components": "^0.0.4",
"@flyteorg/flyte-api": "^0.0.2",
"@flyteorg/flyteidl-types": "^0.0.4",
"@flyteorg/locale": "^0.0.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,11 @@ export const NodeExecutionDetailsPanelContent: React.FC<
useNodeExecutionsById();

const nodeExecution = useMemo(() => {
return values(nodeExecutionsById).find(node =>
const finalExecution = values(nodeExecutionsById).find(node =>
isEqual(node.id, nodeExecutionId),
);

return finalExecution;
}, [nodeExecutionId, nodeExecutionsById]);

const [isReasonsVisible, setReasonsVisible] = useState<boolean>(false);
Expand Down Expand Up @@ -299,7 +301,7 @@ export const NodeExecutionDetailsPanelContent: React.FC<
return () => {
isCurrent = false;
};
});
}, [nodeExecution]);

useEffect(() => {
let isCurrent = true;
Expand Down Expand Up @@ -408,7 +410,7 @@ export const NodeExecutionDetailsPanelContent: React.FC<
isGateNode,
);
return computedPhase;
}, [nodeExecution?.closure.phase, isGateNode]);
}, [nodeExecution, isGateNode]);

const isRunningPhase = useMemo(
() =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export const parseSpanData = (
export const getOperationsFromWorkflowExecutionMetrics = (
data: Admin.WorkflowExecutionGetMetricsResponse,
): string[] => {
const operationIds = uniq(
const operationIds = uniq<string>(
traverse(data)
.paths()
.filter(path => path[path.length - 1] === 'operationId')
Expand Down Expand Up @@ -173,7 +173,7 @@ export const getDuration = (
export const getExecutionMetricsOperationIds = (
data: Admin.WorkflowExecutionGetMetricsResponse,
): string[] => {
const operationIds = uniq(
const operationIds = uniq<string>(
traverse(data)
.paths()
.filter(path => path[path.length - 1] === 'operationId')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React, {
PropsWithChildren,
useCallback,
useContext,
useEffect,
useState,
Expand All @@ -11,7 +10,7 @@ import {
NodeExecutionsById,
WorkflowNodeExecutionsContext,
} from 'components/Executions/contexts';
import { isEqual, keyBy, merge, mergeWith } from 'lodash';
import { isEqual, keyBy, merge, mergeWith, cloneDeep } from 'lodash';
import { dNode } from 'models/Graph/types';
import {
NodeExecutionDynamicWorkflowQueryResult,
Expand Down Expand Up @@ -187,33 +186,31 @@ export const WorkflowNodeExecutionsProvider = ({
}
}, [shouldUpdate]);

const setCurrentNodeExecutionsById = useCallback(
(
newNodeExecutionsById: NodeExecutionsById,
checkForDynamicParents?: boolean,
): void => {
setNodeExecutionsById(prev => {
const newNodes = mergeWith(
{ ...prev },
{ ...newNodeExecutionsById },
mergeNodeExecutions,
);
if (
JSON.stringify(prev, mapStringifyReplacer) ===
JSON.stringify(newNodes, mapStringifyReplacer)
) {
return prev;
}
const setCurrentNodeExecutionsById = (
newNodeExecutionsById: NodeExecutionsById,
checkForDynamicParents?: boolean,
): void => {
const mergedNodes = mergeWith(
cloneDeep(nodeExecutionsById),
cloneDeep(newNodeExecutionsById),
mergeNodeExecutions,
);

if (checkForDynamicParents) {
setShouldUpdate(true);
}
setNodeExecutionsById(prev => {
if (
JSON.stringify(prev, mapStringifyReplacer) ===
JSON.stringify(mergedNodes, mapStringifyReplacer)
) {
return prev;
}

return newNodes;
});
},
[],
);
if (checkForDynamicParents) {
setShouldUpdate(true);
}

return mergedNodes;
});
};

return (
<WorkflowNodeExecutionsContext.Provider
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,15 @@ export const stringifyIsEqual = (a: any, b: any) => {
);
};

export const mergeNodeExecutions = (val, srcVal, _key) => {
export const mergeNodeExecutions = (val, srcVal, _topkey) => {
const retVal = mergeWith(val, srcVal, (target, src, _key) => {
if (!target) {
return src;
}
const clonedTarget = cloneDeep(target);
const clonedSrc = cloneDeep(src);
if (clonedSrc instanceof Map) {
return clonedSrc;
if (src instanceof Map) {
return src;
}
const finaVal =
typeof clonedSrc === 'object'
? merge(clonedTarget, clonedSrc)
: clonedSrc;
const finaVal = typeof src === 'object' ? merge(target, src) : src;
return finaVal;
});
return retVal;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
import { isParentNode } from 'components/Executions/utils';
import { isStartOrEndNode } from 'models/Node/utils';
import { NodeExecutionsById } from 'components/Executions/contexts';
import { cloneDeep, values } from 'lodash';
import {
getDisplayName,
getSubWorkflowFromId,
Expand Down Expand Up @@ -509,11 +510,14 @@ export interface TransformerWorkflowToDag {
export const transformerWorkflowToDag = (
workflow: CompiledWorkflowClosure,
dynamicToMerge: any | null = null,
nodeExecutionsById = {},
inputNodeExecutionsById: NodeExecutionsById = {},
): TransformerWorkflowToDag => {
const { primary } = workflow;
const staticExecutionIdsMap = {};

// clone nodeExecutionsById to prevent mutation
const nodeExecutionsById = cloneDeep(inputNodeExecutionsById);

const primaryWorkflowRoot = createDNode({
compiledNode: {
id: startNodeId,
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.45",
"@flyteorg/console": "^0.0.46",
"long": "^4.0.0",
"protobufjs": "~6.11.3",
"react-ga4": "^1.4.1",
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2032,7 +2032,7 @@ __metadata:
resolution: "@flyteconsole/client-app@workspace:website"
dependencies:
"@flyteorg/common": ^0.0.4
"@flyteorg/console": ^0.0.45
"@flyteorg/console": ^0.0.46
"@types/long": ^3.0.32
long: ^4.0.0
protobufjs: ~6.11.3
Expand All @@ -2054,7 +2054,7 @@ __metadata:
languageName: unknown
linkType: soft

"@flyteorg/components@^0.0.3, @flyteorg/components@workspace:packages/components":
"@flyteorg/components@^0.0.4, @flyteorg/components@workspace:packages/components":
version: 0.0.0-use.local
resolution: "@flyteorg/components@workspace:packages/components"
dependencies:
Expand All @@ -2071,14 +2071,14 @@ __metadata:
languageName: unknown
linkType: soft

"@flyteorg/console@^0.0.45, @flyteorg/console@workspace:packages/console":
"@flyteorg/console@^0.0.46, @flyteorg/console@workspace:packages/console":
version: 0.0.0-use.local
resolution: "@flyteorg/console@workspace:packages/console"
dependencies:
"@date-io/moment": 1.3.9
"@emotion/core": 10.1.1
"@flyteorg/common": ^0.0.4
"@flyteorg/components": ^0.0.3
"@flyteorg/components": ^0.0.4
"@flyteorg/flyte-api": ^0.0.2
"@flyteorg/flyteidl-types": ^0.0.4
"@flyteorg/locale": ^0.0.2
Expand Down

0 comments on commit 8872536

Please sign in to comment.