Skip to content

Commit 7b909d1

Browse files
committed
revert change
1 parent 7e8bd78 commit 7b909d1

1 file changed

Lines changed: 38 additions & 50 deletions

File tree

src/orion/client/experiment.py

Lines changed: 38 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@
2626
from orion.core.worker.trial import Trial, TrialCM
2727
from orion.core.worker.trial_pacemaker import TrialPacemaker
2828
from orion.executor.base import Executor
29+
from orion.ext.extensions import OrionExtensionManager
2930
from orion.plotting.base import PlotAccessor
3031
from orion.storage.base import FailedUpdate
31-
from orion.ext.extensions import OrionExtensionManager
32+
3233

3334
log = logging.getLogger(__name__)
3435

@@ -772,37 +773,6 @@ def workon(
772773

773774
return sum(trials)
774775

775-
def _optimize_trial(self, fct, trial, trial_arg, kwargs, worker_broken_trials, max_broken, on_error):
776-
kwargs.update(flatten(trial.params))
777-
778-
if trial_arg:
779-
kwargs[trial_arg] = trial
780-
781-
try:
782-
with self.extensions.trial(trial):
783-
results = self.executor.wait(
784-
[self.executor.submit(fct, **unflatten(kwargs))]
785-
)[0]
786-
self.observe(trial, results=results)
787-
except (KeyboardInterrupt, InvalidResult):
788-
raise
789-
except BaseException as e:
790-
if on_error is None or on_error(self, trial, e, worker_broken_trials):
791-
log.error(traceback.format_exc())
792-
worker_broken_trials += 1
793-
else:
794-
log.error(str(e))
795-
log.debug(traceback.format_exc())
796-
797-
if worker_broken_trials >= max_broken:
798-
raise BrokenExperiment(
799-
"Worker has reached broken trials threshold"
800-
)
801-
else:
802-
self.release(trial, status="broken")
803-
804-
return worker_broken_trials
805-
806776
def _optimize(
807777
self, fct, pool_size, max_trials, max_broken, trial_arg, on_error, **kwargs
808778
):
@@ -812,24 +782,42 @@ def _optimize(
812782
max_trials = min(max_trials, self.max_trials)
813783

814784
while not self.is_done and trials - worker_broken_trials < max_trials:
815-
try:
816-
with self.suggest(pool_size=pool_size) as trial:
817-
818-
worker_broken_trials = self._optimize_trial(
819-
fct,
820-
trial,
821-
trial_arg,
822-
kwargs,
823-
worker_broken_trials,
824-
max_broken,
825-
on_error
826-
)
827-
828-
except CompletedExperiment as e:
829-
log.warning(e)
830-
break
831-
832-
trials += 1
785+
try:
786+
with self.suggest(pool_size=pool_size) as trial:
787+
788+
kwargs.update(flatten(trial.params))
789+
790+
if trial_arg:
791+
kwargs[trial_arg] = trial
792+
793+
try:
794+
with self.extensions.trial(trial):
795+
results = self.executor.wait(
796+
[self.executor.submit(fct, **unflatten(kwargs))]
797+
)[0]
798+
self.observe(trial, results=results)
799+
except (KeyboardInterrupt, InvalidResult):
800+
raise
801+
except BaseException as e:
802+
if on_error is None or on_error(self, trial, e, worker_broken_trials):
803+
log.error(traceback.format_exc())
804+
worker_broken_trials += 1
805+
else:
806+
log.error(str(e))
807+
log.debug(traceback.format_exc())
808+
809+
if worker_broken_trials >= max_broken:
810+
raise BrokenExperiment(
811+
"Worker has reached broken trials threshold"
812+
)
813+
else:
814+
self.release(trial, status="broken")
815+
816+
except CompletedExperiment as e:
817+
log.warning(e)
818+
break
819+
820+
trials += 1
833821

834822
return trials
835823

0 commit comments

Comments
 (0)