[tune] update Optuna integration to 2.4.0 API (#13631)

Co-authored-by: Amog Kamsetty <amogkamsetty@yahoo.com>
This commit is contained in:
Kai Fricke
2021-01-23 00:32:37 -08:00
committed by GitHub
co-authored by Amog Kamsetty
parent 8ef835ff03
commit 17760e1510
5 changed files with 59 additions and 55 deletions
+8 -2
View File
@@ -218,8 +218,14 @@ class OptunaSearch(Searcher):
error: bool = False):
ot_trial = self._ot_trials[trial_id]
ot_trial_id = ot_trial._trial_id
self._storage.set_trial_value(ot_trial_id, result.get(
self.metric, None))
val = result.get(self.metric, None)
if hasattr(self._storage, "set_trial_value"):
# Backwards compatibility with optuna < 2.4.0
self._storage.set_trial_value(ot_trial_id, val)
else:
self._storage.set_trial_values(ot_trial_id, [val])
self._storage.set_trial_state(ot_trial_id,
ot.trial.TrialState.COMPLETE)