Skip to content

Commit

Permalink
Add guard against unnecessary workflow updates (#5949)
Browse files Browse the repository at this point in the history
Co-authored-by: Tom Szendrey <[email protected]>
  • Loading branch information
mwdchang and Tom-Szendrey authored Jan 3, 2025
1 parent 077d96a commit 530a490
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,11 @@ const pollResult = async (runId: string) => {
const checkpoint = _.last(data.updates);
if (checkpoint) {
const state = _.cloneDeep(props.node.state);
state.currentProgress = +((100 * checkpoint.data.progress) / state.numIterations).toFixed(2);
emit('update-state', state);
const newProgress = +((100 * checkpoint.data.progress) / state.numIterations).toFixed(2);
if (newProgress !== state.currentProgress) {
state.currentProgress = newProgress;
emit('update-state', state);
}
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,11 @@ const pollResult = async (runId: string) => {
const checkpoint = _.last(data.updates);
if (checkpoint) {
const state = _.cloneDeep(props.node.state);
state.currentProgress = +((100 * checkpoint.data.progress) / state.extra.numIterations).toFixed(2);
emit('update-state', state);
const newProgress = +((100 * checkpoint.data.progress) / state.extra.numIterations).toFixed(2);
if (newProgress !== state.currentProgress) {
state.currentProgress = newProgress;
emit('update-state', state);
}
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,15 @@ const pollResult = async (runId: string) => {
.setPollAction(async () => pollAction(runId))
.setProgressAction((data: Simulation) => {
if (runId === props.node.state.inProgressOptimizeId && data.updates.length > 0) {
const checkpointData = _.first(data.updates)?.data as CiemssOptimizeStatusUpdate;
data.updates.sort((a, b) => a.data.progress - b.data.progress);
const checkpointData = _.last(data.updates)?.data as CiemssOptimizeStatusUpdate;
if (checkpointData) {
const state = _.cloneDeep(props.node.state);
state.currentProgress = +((100 * checkpointData.progress) / checkpointData.totalPossibleIterations).toFixed(
2
);
emit('update-state', state);
const newProgress = +((100 * checkpointData.progress) / checkpointData.totalPossibleIterations).toFixed(2);
if (newProgress !== state.currentProgress) {
state.currentProgress = newProgress;
emit('update-state', state);
}
}
}
});
Expand Down

0 comments on commit 530a490

Please sign in to comment.