From 51cd107ee1590eccb865edcae3c6540127f0fb06 Mon Sep 17 00:00:00 2001 From: Bogdan Budescu Date: Thu, 3 Aug 2023 15:11:14 +0300 Subject: [PATCH] - implement regular control flow without relying on exception semantics - should enable using the -O flag for the python interpreter --- flaml/tune/searcher/blendsearch.py | 32 +++++++++++++++++++----------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/flaml/tune/searcher/blendsearch.py b/flaml/tune/searcher/blendsearch.py index 0d264fcbde..f5527ad021 100644 --- a/flaml/tune/searcher/blendsearch.py +++ b/flaml/tune/searcher/blendsearch.py @@ -231,18 +231,26 @@ def __init__( sampler = ot.samplers.TPESampler(seed=gs_seed, multivariate=True, group=True) else: sampler = None - try: - assert evaluated_rewards - self._gs = GlobalSearch( - space=gs_space, - metric=metric, - mode=mode, - seed=gs_seed, - sampler=sampler, - points_to_evaluate=self._evaluated_points, - evaluated_rewards=evaluated_rewards, - ) - except (AssertionError, ValueError): + + if evaluated_rewards: + try: + self._gs = GlobalSearch( + space=gs_space, + metric=metric, + mode=mode, + seed=gs_seed, + sampler=sampler, + points_to_evaluate=self._evaluated_points, + evaluated_rewards=evaluated_rewards, + ) + except ValueError: + try_without_warmup = True + else: + try_without_warmup = False + else: + try_without_warmup = True + + if try_without_warmup: self._gs = GlobalSearch( space=gs_space, metric=metric,