Skip to content

Commit

Permalink
Apply flake8
Browse files Browse the repository at this point in the history
  • Loading branch information
nabenabe0928 committed Dec 6, 2023
1 parent 0c2606d commit 7bc67e9
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions optuna_dashboard/_storage.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from __future__ import annotations

from datetime import datetime
from datetime import timedelta
import threading
import typing

Expand All @@ -21,13 +19,12 @@
# In-memory trials cache
trials_cache_lock = threading.Lock()
trials_cache: dict[int, list[FrozenTrial]] = {}
trials_last_fetched_at: dict[int, datetime] = {}


def _is_study_updated(storage: BaseStorage, trials: list[FrozenTrial]) -> bool:
max_trial_id = 0 if trials is None else max([t._trial_id for t in trials], default=0)
try:
# Another trial that did not exist is found in the database.
# If another trial that did not exist is found in the database, nothing will be raised.
storage.get_trial(trial_id=max_trial_id + 1)
return True
except KeyError:
Expand All @@ -51,7 +48,6 @@ def get_trials(storage: BaseStorage, study_id: int) -> list[FrozenTrial]:
trials = sorted(trials, key=lambda t: t.number)

with trials_cache_lock:
trials_last_fetched_at[study_id] = datetime.now()
trials_cache[study_id] = trials
return trials

Expand Down

0 comments on commit 7bc67e9

Please sign in to comment.