From d2f053e7f6381920a78cb5cf4eda936a3c8ae4b5 Mon Sep 17 00:00:00 2001 From: Sarah Krebs Date: Fri, 5 Jan 2024 09:48:43 +0100 Subject: [PATCH] Fix errors due to changing inputs before runselection --- CHANGELOG.md | 1 + deepcave/plugins/__init__.py | 19 ++++++++++--------- .../plugins/hyperparameter/importances.py | 1 - .../plugins/objective/parallel_coordinates.py | 1 - 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b3ef73be..0329ee1f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ## Bug-Fixes - Don't convert BOHB runs with status 'running' (consistent with SMAC). +- Fix errors due to changing inputs before runselection (#64). # Version 1.1.3 diff --git a/deepcave/plugins/__init__.py b/deepcave/plugins/__init__.py index 85026af8..51020a75 100644 --- a/deepcave/plugins/__init__.py +++ b/deepcave/plugins/__init__.py @@ -365,17 +365,18 @@ def plugin_input_update(pathname: str, *inputs_list: str) -> List[str]: # 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. + if _run_id: + selected_run = run_handler.get_run(_run_id) - selected_run = run_handler.get_run(_run_id) - - # How to update only parameters which have a dependency? - user_dependencies_inputs = self.load_dependency_inputs( - selected_run, _previous_inputs, _inputs - ) + if selected_run is not None: + # How to update only parameters which have a dependency? + user_dependencies_inputs = self.load_dependency_inputs( + selected_run, _previous_inputs, _inputs + ) - # Update dict - # dict.update() remove keys, so we use our own method to do so - update_dict(inputs, user_dependencies_inputs) # inplace operation + # Update dict + # dict.update() remove keys, so we use our own method to do so + update_dict(inputs, user_dependencies_inputs) # inplace operation # Let's cast the inputs inputs = self._cast_inputs(inputs) diff --git a/deepcave/plugins/hyperparameter/importances.py b/deepcave/plugins/hyperparameter/importances.py index 261c9a9e..e37e372e 100644 --- a/deepcave/plugins/hyperparameter/importances.py +++ b/deepcave/plugins/hyperparameter/importances.py @@ -137,7 +137,6 @@ def load_dependency_inputs(self, run, _, inputs): # Pre-set values if objective_value is None: objective_value = objective_ids[0] - n_hps = len(hp_names) if n_hps == 0: n_hps = len(hp_names) diff --git a/deepcave/plugins/objective/parallel_coordinates.py b/deepcave/plugins/objective/parallel_coordinates.py index 7c3eaf96..9706e529 100644 --- a/deepcave/plugins/objective/parallel_coordinates.py +++ b/deepcave/plugins/objective/parallel_coordinates.py @@ -164,7 +164,6 @@ def load_dependency_inputs(self, run, _, inputs): objective_value = objective_ids[0] budget_value = budget_ids[-1] hp_value = hp_names - n_hps = len(hp_names) if n_hps == 0: n_hps = len(hp_names)