Skip to content

Commit

Permalink
Add backward.ensure_trial_working_dir
Browse files Browse the repository at this point in the history
Why:

Database filled with previous version of Oríon will have trials with no
exp_working_dir. We must make sure that these trials when suggested will
have their exp_working_dir set properly before being passed to the
function to optimize.
  • Loading branch information
bouthilx committed Dec 15, 2021
1 parent 4dd8e79 commit 70f5c55
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/orion/client/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import orion.core
import orion.core.utils.format_trials as format_trials
from orion.core.io.database import DuplicateKeyError
from orion.core.utils import backward
from orion.core.utils.exceptions import (
BrokenExperiment,
CompletedExperiment,
Expand Down Expand Up @@ -842,6 +843,7 @@ def _optimize(
with self.suggest(
pool_size=pool_size, timeout=reservation_timeout
) as trial:
backward.ensure_trial_working_dir(self, trial)

kwargs.update(flatten(trial.params))

Expand Down
6 changes: 6 additions & 0 deletions src/orion/core/utils/backward.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,3 +184,9 @@ def algo_observe(algo, trials, results):
trial.results.append(Trial.Result(name=name, type=name, value=trial_result))

algo.observe(trials)


def ensure_trial_working_dir(experiment, trial):
"""If the trial's exp working dir is not set, set it to current experiment's working dir."""
if not trial.exp_working_dir:
trial.exp_working_dir = experiment.working_dir

0 comments on commit 70f5c55

Please sign in to comment.