mirror of
https://github.com/wassname/optuna-dashboard.git
synced 2026-09-17 12:30:35 +08:00
Merge pull request #434 from c-bata/modify-reload-interval
Reduce the reload interval time for human-in-the-loop optimization
This commit is contained in:
@@ -158,9 +158,18 @@ def create_new_study(
|
||||
return study_id
|
||||
|
||||
|
||||
def get_trials(storage: BaseStorage, study_id: int, ttl_seconds: int = 10) -> list[FrozenTrial]:
|
||||
def get_trials(storage: BaseStorage, study_id: int) -> list[FrozenTrial]:
|
||||
with trials_cache_lock:
|
||||
trials = trials_cache.get(study_id, None)
|
||||
|
||||
# Not a big fan of the heuristic, but I can't think of anything better.
|
||||
if trials is None or len(trials) < 100:
|
||||
ttl_seconds = 2
|
||||
elif len(trials) < 500:
|
||||
ttl_seconds = 5
|
||||
else:
|
||||
ttl_seconds = 10
|
||||
|
||||
last_fetched_at = trials_last_fetched_at.get(study_id, None)
|
||||
if (
|
||||
trials is not None
|
||||
|
||||
@@ -60,12 +60,23 @@ export const StudyDetailBeta: FC<{
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
if (reloadInterval < 0 || page === "trialTable") {
|
||||
if (reloadInterval < 0) {
|
||||
return
|
||||
}
|
||||
const nTrials = studyDetail ? studyDetail.trials.length : 0
|
||||
let interval = reloadInterval * 1000
|
||||
|
||||
// For Human-in-the-loop Optimization, the interval is set to 2 seconds
|
||||
// when the number of trials is small and the page is "trialList".
|
||||
if (page === "trialList" && nTrials < 100) {
|
||||
interval = 2000
|
||||
} else if (page === "trialList" && nTrials < 500) {
|
||||
interval = 5000
|
||||
}
|
||||
|
||||
const intervalId = setInterval(function () {
|
||||
action.updateStudyDetail(studyId)
|
||||
}, reloadInterval * 1000)
|
||||
}, interval)
|
||||
return () => clearInterval(intervalId)
|
||||
}, [reloadInterval, studyDetail, page])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user