Skip to content

Commit

Permalink
Remove unnecessary distribution compatibility check
Browse files Browse the repository at this point in the history
  • Loading branch information
porink0424 committed Oct 16, 2024
1 parent 12c2744 commit 2227ed0
Showing 1 changed file with 6 additions and 19 deletions.
25 changes: 6 additions & 19 deletions optuna/storages/_rdb/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -588,27 +588,14 @@ def _set_trial_param_without_commit(
trial = models.TrialModel.find_or_raise_by_id(trial_id, session)
self.check_trial_is_updatable(trial_id, trial.state)

trial_param = models.TrialParamModel.find_by_trial_and_param_name(
trial, param_name, session
trial_param = models.TrialParamModel(
trial_id=trial_id,
param_name=param_name,
param_value=param_value_internal,
distribution_json=distributions.distribution_to_json(distribution),
)

if trial_param is not None:
# Raise error in case distribution is incompatible.
distributions.check_distribution_compatibility(
distributions.json_to_distribution(trial_param.distribution_json), distribution
)

trial_param.param_value = param_value_internal
trial_param.distribution_json = distributions.distribution_to_json(distribution)
else:
trial_param = models.TrialParamModel(
trial_id=trial_id,
param_name=param_name,
param_value=param_value_internal,
distribution_json=distributions.distribution_to_json(distribution),
)

trial_param.check_and_add(session)
trial_param.check_and_add(session)

def _check_and_set_param_distribution(
self,
Expand Down

0 comments on commit 2227ed0

Please sign in to comment.