Skip to content

Commit

Permalink
doc: Extra logging on issue w.r.t. trial already existing
Browse files Browse the repository at this point in the history
  • Loading branch information
eddiebergman committed Nov 29, 2024
1 parent 8bf5051 commit 62e130b
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion neps/state/neps_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

from more_itertools import take

from neps.exceptions import TrialAlreadyExistsError
from neps.state.err_dump import ErrDump
from neps.state.optimizer import OptimizationState, OptimizerInfo
from neps.state.trial import Trial
Expand Down Expand Up @@ -151,7 +152,29 @@ def sample_trial(
time_sampled=time.time(),
worker_id=worker_id,
)
self._trials.put_new(trial)
try:
self._trials.put_new(trial)
except TrialAlreadyExistsError as e:
if sampled_config.id in trials:
logger.warning(
"The new sampled trial was given an id of '%s', yet this already"
" exists in the loaded in trials given to the optimizer. This"
" indicates a bug with the optimizers allocation of ids.",
sampled_config.id,
)
else:
logger.warning(
"The new sampled trial was given an id of '%s', which is not one"
" that was loaded in by the optimizer. This indicates that"
" configuration '%s' was put on disk during the time that this"
" worker had the optimizer state lock OR that after obtaining the"
" optimizer state lock, somehow this configuration failed to be"
" loaded in and passed to the optimizer.",
sampled_config.id,
sampled_config.id,
)
raise e

seed_state.recapture()
put_seed_state(seed_state)
put_opt(
Expand Down

0 comments on commit 62e130b

Please sign in to comment.