From d81124442938d929e80437c73ec00e96b4ce741b Mon Sep 17 00:00:00 2001 From: Cheng Huzi Date: Thu, 1 Jul 2021 01:32:24 -0400 Subject: [PATCH] Fix error in calculating the number of fixed trials --- optuna_dashboard/static/action.ts | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/optuna_dashboard/static/action.ts b/optuna_dashboard/static/action.ts index d6efb73c..47bb4490 100644 --- a/optuna_dashboard/static/action.ts +++ b/optuna_dashboard/static/action.ts @@ -33,14 +33,23 @@ export const actionCreator = () => { } const updateStudyDetail = (studyId: number) => { - getStudyDetailAPI( - studyId, - studyId in studyDetails ? studyDetails[studyId].trials.length : 0 - ) + let nLocalFixedTrials = 0 + if (studyId in studyDetails) { + for (const trial of studyDetails[studyId].trials) { + if (!["Running", "Waiting"].includes(trial.state)) { + nLocalFixedTrials += 1 + } else { + break + } + } + } + getStudyDetailAPI(studyId, nLocalFixedTrials) .then((study) => { - const currentTrials = - studyId in studyDetails ? studyDetails[studyId].trials : [] - study.trials = study.trials.concat(currentTrials) + const currentFixedTrials = + studyId in studyDetails + ? studyDetails[studyId].trials.slice(0, nLocalFixedTrials) + : [] + study.trials = study.trials.concat(currentFixedTrials) const newVal = Object.assign({}, studyDetails) newVal[studyId] = study setStudyDetails(newVal)