Skip to content

Commit

Permalink
Merge pull request #107 from automl/bugfix/reset-dependencies-inputs-…
Browse files Browse the repository at this point in the history
…when-changing-runs

bugfix/Reset inputs when changing runs
  • Loading branch information
sarah-segel authored Jan 16, 2024
2 parents 411f0ed + 6a71ac9 commit a10ef27
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

## Bug-Fixes
- Don't convert BOHB runs with status 'running' (consistent with SMAC).
- Reset inputs to fix error when subsequently selecting runs with different configspaces, objectives or budgets (#106)

# Version 1.1.3

Expand Down
14 changes: 9 additions & 5 deletions deepcave/plugins/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,11 +360,15 @@ def plugin_input_update(pathname: str, *inputs_list: str) -> List[str]:
# because `run` would be removed.
# Also: We want to keep the current run name.
update_dict(_inputs, self.load_inputs())

# TODO: Reset only inputs which are not available in another run.
# E.g. if options from budget in run_2 and run_3 are the same
# take the budget from run_2 if changed to run_3. Otherwise,
# reset budgets.
# Reset inputs
if "objective_id" in _inputs.keys():
update_dict(_inputs, {"objective_id": {"value": None}})
if "budget_id" in _inputs.keys():
update_dict(_inputs, {"budget_id": {"value": None}})
if "hyperparameter_name_1" in _inputs.keys():
update_dict(_inputs, {"hyperparameter_name_1": {"value": None}})
if "hyperparameter_name_2" in _inputs.keys():
update_dict(_inputs, {"hyperparameter_name_2": {"value": None}})

selected_run = run_handler.get_run(_run_id)

Expand Down
4 changes: 4 additions & 0 deletions deepcave/plugins/hyperparameter/pdp.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,13 @@ def load_dependency_inputs(self, run, previous_inputs, inputs):
objective_value = inputs["objective_id"]["value"]
budget_value = inputs["budget_id"]["value"]
hp1_value = inputs["hyperparameter_name_1"]["value"]
hp2_value = inputs["hyperparameter_name_2"]["value"]

if objective_value is None:
objective_value = objective_ids[0]
if budget_value is None:
budget_value = budget_ids[-1]
if hp1_value is None:
hp1_value = hp_names[0]

return {
Expand All @@ -160,6 +163,7 @@ def load_dependency_inputs(self, run, previous_inputs, inputs):
},
"hyperparameter_name_2": {
"options": get_checklist_options([None] + hp_names),
"value": hp2_value,
},
}

Expand Down
1 change: 1 addition & 0 deletions deepcave/plugins/objective/configuration_cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ def load_dependency_inputs(self, run, _, inputs):
# Pre-set values
if objective_value is None:
objective_value = objective_ids[0]
if budget_value is None:
budget_value = budget_ids[-1]
else:
budget_value = inputs["budget_id"]["value"]
Expand Down

0 comments on commit a10ef27

Please sign in to comment.