From 4502afe40c7d765c7b72c69ddecec8275be8349c Mon Sep 17 00:00:00 2001 From: Kristina Thieme Date: Thu, 8 Feb 2024 16:28:58 +0100 Subject: [PATCH] minor details adjusted --- deepcave/custom_queue.py | 3 +-- deepcave/plugins/__init__.py | 14 ++++++++----- deepcave/plugins/budget/budget_correlation.py | 13 +++++------- deepcave/plugins/dynamic.py | 3 +-- .../plugins/hyperparameter/importances.py | 19 +++++++---------- deepcave/plugins/hyperparameter/pdp.py | 12 +++++------ .../plugins/objective/configuration_cube.py | 6 ++---- deepcave/plugins/objective/cost_over_time.py | 6 ++---- .../plugins/objective/parallel_coordinates.py | 9 +++----- deepcave/plugins/objective/pareto_front.py | 20 +++++++----------- deepcave/plugins/static.py | 3 +-- deepcave/plugins/summary/configurations.py | 10 ++++----- deepcave/plugins/summary/footprint.py | 21 ++++++++----------- deepcave/plugins/summary/overview.py | 3 +-- deepcave/runs/__init__.py | 5 ++--- deepcave/runs/converters/bohb.py | 4 ++-- 16 files changed, 63 insertions(+), 88 deletions(-) diff --git a/deepcave/custom_queue.py b/deepcave/custom_queue.py index 29dd7a35..dcc08b13 100644 --- a/deepcave/custom_queue.py +++ b/deepcave/custom_queue.py @@ -324,8 +324,7 @@ def remove_jobs(registry: BaseRegistry, job_id: Optional[str] = None) -> None: except Exception: registry.remove(self.get_job(job_id)) - # Issue opened - remove_jobs(self._queue, job_id) + remove_jobs(self._queue, job_id) # type: ignore remove_jobs(self._queue.finished_job_registry, job_id) remove_jobs(self._queue.canceled_job_registry, job_id) diff --git a/deepcave/plugins/__init__.py b/deepcave/plugins/__init__.py index 6f23ae32..0f1c29e5 100644 --- a/deepcave/plugins/__init__.py +++ b/deepcave/plugins/__init__.py @@ -558,9 +558,9 @@ def _process_raw_outputs( # passed runs could be a list, but load mpl outputs and load outputs do not # accept lists, but expect single runs if mpl_active: - outputs = self.__class__.load_mpl_outputs(passed_runs, cleaned_inputs, passed_outputs) + outputs = self.__class__.load_mpl_outputs(passed_runs, cleaned_inputs, passed_outputs) # type: ignore # noqa: E501 else: - outputs = self.__class__.load_outputs(passed_runs, cleaned_inputs, passed_outputs) + outputs = self.__class__.load_outputs(passed_runs, cleaned_inputs, passed_outputs) # type: ignore # noqa: E501 logger.debug("Raw outputs processed successfully.") @@ -1342,7 +1342,9 @@ def load_outputs( Note ---- The passed `inputs` are cleaned and therefore differs compared to `load_inputs` or - `load_dependency_inputs`. Please see `_clean_inputs` for more information. + `load_dependency_inputs`. + Inputs are cleaned s.t. only the first value is used. + Also, boolean values are casted to booleans. Parameters ---------- @@ -1374,7 +1376,8 @@ def load_mpl_outputs( Note ---- The passed `inputs` are cleaned and therefore differs compared to `load_inputs` or - `load_dependency_inputs`. Please see `_clean_inputs` for more information. + `load_dependency_inputs`. Inputs are cleaned s.t. only the first value is used. + Also, boolean values are casted to booleans. Parameters ---------- @@ -1406,7 +1409,8 @@ def process(run: AbstractRun, inputs: Dict[str, Any]) -> Dict[str, Any]: Note ---- The passed `inputs` are cleaned and therefore differs compared to `load_inputs` or - `load_dependency_inputs`. Please see `_clean_inputs` for more information. + `load_dependency_inputs`. Inputs are cleaned s.t. only the first value is used. + Also, boolean values are casted to booleans. Parameters ---------- diff --git a/deepcave/plugins/budget/budget_correlation.py b/deepcave/plugins/budget/budget_correlation.py index 7d3359c2..610caab5 100644 --- a/deepcave/plugins/budget/budget_correlation.py +++ b/deepcave/plugins/budget/budget_correlation.py @@ -92,8 +92,7 @@ def get_input_layout(register: Callable) -> List[html.Div]: ), ] - # Types dont match superclass - def load_dependency_inputs(self, run, _, inputs) -> Dict[str, Dict[str, Any]]: + def load_dependency_inputs(self, run, _, inputs) -> Dict[str, Dict[str, Any]]: # type: ignore """ Work like 'load_inputs' but called after inputs have changed. @@ -160,7 +159,6 @@ def process(run: AbstractRun, inputs: Dict[str, int]) -> Dict[str, Any]: budget_ids = run.get_budget_ids(include_combined=False) # Add symmetric correlations; table ready - # Issue already opened with this matrix correlations_symmetric: DefaultDict[str, Dict[str, float]] = defaultdict(dict) correlations: DefaultDict[str, Dict[str, float]] = defaultdict(dict) @@ -185,14 +183,14 @@ def process(run: AbstractRun, inputs: Dict[str, int]) -> Dict[str, Any]: c2 += [costs2[config_id][objective_id]] correlation = round(stats.spearmanr(c1, c2).correlation, 2) - correlations_symmetric["Budget"][budget2_readable] = budget2_readable - correlations_symmetric[budget1_readable][budget2_readable] = correlation + correlations_symmetric["Budget"][budget2_readable] = budget2_readable # type: ignore # noqa: E501 + correlations_symmetric[budget1_readable][budget2_readable] = correlation # type: ignore # noqa: E501 # Exclude if budget2 is higher than budget1 if budget2 > budget1: continue - correlations[budget1_readable][budget2_readable] = correlation + correlations[budget1_readable][budget2_readable] = correlation # type: ignore return { "correlations": correlations, @@ -231,8 +229,7 @@ def get_output_layout(register: Callable) -> List[Any]: ] @staticmethod - # Types dont match superclass - def load_outputs(run, _, outputs) -> List[Any]: + def load_outputs(run, _, outputs) -> List[Any]: # type: ignore """ Read the raw data and prepare it for the layout. diff --git a/deepcave/plugins/dynamic.py b/deepcave/plugins/dynamic.py index ac173280..bd493c8d 100644 --- a/deepcave/plugins/dynamic.py +++ b/deepcave/plugins/dynamic.py @@ -118,8 +118,7 @@ def plugin_output_update(_: Any, *inputs_list: str) -> Any: return self._process_raw_outputs(inputs, raw_outputs) @interactive - # Return type does not match the superclass - def __call__(self) -> List[Component]: + def __call__(self) -> List[Component]: # type: ignore """ Return the components for the plugin. diff --git a/deepcave/plugins/hyperparameter/importances.py b/deepcave/plugins/hyperparameter/importances.py index d2d93990..b80a21d6 100644 --- a/deepcave/plugins/hyperparameter/importances.py +++ b/deepcave/plugins/hyperparameter/importances.py @@ -179,8 +179,7 @@ def load_inputs(self) -> Dict[str, Dict[str, Any]]: "budget_ids": {"options": get_checklist_options(), "value": []}, } - # Types dont match superclass - def load_dependency_inputs(self, run, _: Any, inputs: Dict[str, Any]) -> Dict[str, Any]: + def load_dependency_inputs(self, run, _: Any, inputs: Dict[str, Any]) -> Dict[str, Any]: # type: ignore # noqa: E501 """ Work like 'load_inputs' but called after inputs have changed. @@ -254,7 +253,6 @@ def load_dependency_inputs(self, run, _: Any, inputs: Dict[str, Any]) -> Dict[st } @staticmethod - # Return doesnt match superclass type def process(run: AbstractRun, inputs: Dict[str, Any]) -> Dict[str, Any]: """ Return raw data based on the run and input data. @@ -315,7 +313,7 @@ def process(run: AbstractRun, inputs: Dict[str, Any]) -> Dict[str, Any]: importances = evaluator.get_importances(hp_names) data[budget_id] = importances - return data + return data # type: ignore @staticmethod def get_output_layout(register: Callable) -> dcc.Graph: @@ -336,8 +334,7 @@ def get_output_layout(register: Callable) -> dcc.Graph: return dcc.Graph(register("graph", "figure"), style={"height": config.FIGURE_HEIGHT}) @staticmethod - # Types dont match superclass - def load_outputs(run, inputs, outputs) -> go.Figure: + def load_outputs(run, inputs, outputs) -> go.Figure: # type: ignore """ Read in raw data and prepare for layout. @@ -458,8 +455,7 @@ def get_mpl_output_layout(register: Callable) -> html.Img: ) @staticmethod - # Types dont match superclass - def load_mpl_outputs(run, inputs: Dict[str, Any], outputs): + def load_mpl_outputs(run, inputs: Dict[str, Any], outputs): # type: ignore """ Read the raw data and prepare it for the layout. @@ -536,8 +532,7 @@ def load_mpl_outputs(run, inputs: Dict[str, Any], outputs): x_values, y, yerr=y_err, - # plt is matplotlib object and has no function get_color, Issue opened - color=plt.get_color(budget_id), + color=plt.get_color(budget_id), # type: ignore label=budget, error_kw=dict(lw=1, capsize=2, capthick=1), ) @@ -547,5 +542,5 @@ def load_mpl_outputs(run, inputs: Dict[str, Any], outputs): # Rotate x ticks plt.xticks(x_values, x_labels, rotation=90) plt.ylabel("Importance") - # plt is matplotlib object and has no function render, Issue opened - return plt.render() + + return plt.render() # type: ignore diff --git a/deepcave/plugins/hyperparameter/pdp.py b/deepcave/plugins/hyperparameter/pdp.py index 22bfde8d..2b76e8e3 100644 --- a/deepcave/plugins/hyperparameter/pdp.py +++ b/deepcave/plugins/hyperparameter/pdp.py @@ -198,8 +198,7 @@ def load_inputs(self) -> Dict[str, Dict[str, Any]]: "show_ice": {"options": get_select_options(binary=True), "value": "true"}, } - # Types dont match superclass - def load_dependency_inputs(self, run, previous_inputs, inputs) -> Dict[str, Any]: + def load_dependency_inputs(self, run, previous_inputs, inputs) -> Dict[str, Any]: # type: ignore # noqa: E501 """ Work like 'load_inputs' but called after inputs have changed. @@ -214,6 +213,9 @@ def load_dependency_inputs(self, run, previous_inputs, inputs) -> Dict[str, Any] The selected run. inputs Current content of the inputs. + previous_inputs + Previous content of the inputs. + Not used in this specific function. Returns ------- @@ -253,8 +255,7 @@ def load_dependency_inputs(self, run, previous_inputs, inputs) -> Dict[str, Any] } @staticmethod - # Types dont match superclass - def process(run, inputs) -> Dict[str, Any]: + def process(run, inputs) -> Dict[str, Any]: # type: ignore """ Return raw data based on a run and the input data. @@ -367,8 +368,7 @@ def get_output_layout(register: Callable) -> dcc.Graph: return dcc.Graph(register("graph", "figure"), style={"height": config.FIGURE_HEIGHT}) @staticmethod - # Types dont match superclass - def load_outputs(run, inputs, outputs) -> go.Figure: + def load_outputs(run, inputs, outputs) -> go.Figure: # type: ignore """ Read the raw data and prepare it for the layout. diff --git a/deepcave/plugins/objective/configuration_cube.py b/deepcave/plugins/objective/configuration_cube.py index a2a1240f..d9281c89 100644 --- a/deepcave/plugins/objective/configuration_cube.py +++ b/deepcave/plugins/objective/configuration_cube.py @@ -158,8 +158,7 @@ def load_inputs(self) -> Dict[str, Any]: "hyperparameter_names": {"options": get_checklist_options(), "value": []}, } - # Types dont match superclass - def load_dependency_inputs(self, run, _, inputs) -> Dict[str, Any]: + def load_dependency_inputs(self, run, _, inputs) -> Dict[str, Any]: # type: ignore """ Work like 'load_inputs' but called after inputs have changed. @@ -296,8 +295,7 @@ def get_output_layout(register: Callable) -> Tuple[dcc.Graph,]: return (dcc.Graph(register("graph", "figure"), style={"height": config.FIGURE_HEIGHT}),) @staticmethod - # Types dont match superclass - def load_outputs(run, inputs, outputs) -> go.Figure: + def load_outputs(run, inputs, outputs) -> go.Figure: # type: ignore """ Read in the raw data and prepares them for the layout. diff --git a/deepcave/plugins/objective/cost_over_time.py b/deepcave/plugins/objective/cost_over_time.py index 0ae15fa5..779199f1 100644 --- a/deepcave/plugins/objective/cost_over_time.py +++ b/deepcave/plugins/objective/cost_over_time.py @@ -217,8 +217,7 @@ def load_inputs(self) -> Dict[str, Any]: } @staticmethod - # Types dont match superclass - def process(run, inputs) -> Dict[str, Any]: + def process(run, inputs) -> Dict[str, Any]: # type: ignore """ Return raw data based on a run and input data. @@ -278,8 +277,7 @@ def get_output_layout(register: Callable) -> dcc.Graph: return dcc.Graph(register("graph", "figure"), style={"height": config.FIGURE_HEIGHT}) @staticmethod - # Types dont match superclass - def load_outputs(runs, inputs, outputs) -> go.Figure: + def load_outputs(runs, inputs, outputs) -> go.Figure: # type: ignore """ Read in the raw data and prepare them for the layout. diff --git a/deepcave/plugins/objective/parallel_coordinates.py b/deepcave/plugins/objective/parallel_coordinates.py index 5222946b..ab172327 100644 --- a/deepcave/plugins/objective/parallel_coordinates.py +++ b/deepcave/plugins/objective/parallel_coordinates.py @@ -184,8 +184,7 @@ def load_inputs(self) -> Dict[str, Dict[str, Any]]: "hide_hps": {"hidden": True}, } - # Types dont match superclass - def load_dependency_inputs(self, run, _, inputs) -> Dict[str, Any]: + def load_dependency_inputs(self, run, _, inputs) -> Dict[str, Any]: # type: ignore """ Work like 'load_inputs' but called after inputs have changed. @@ -263,8 +262,7 @@ def load_dependency_inputs(self, run, _, inputs) -> Dict[str, Any]: } @staticmethod - # Types dont match superclass - def process(run, inputs) -> Dict[str, Any]: + def process(run, inputs) -> Dict[str, Any]: # type: ignore """ Return raw data based on a run and input data. @@ -325,8 +323,7 @@ def get_output_layout(register: Callable) -> dcc.Graph: return dcc.Graph(register("graph", "figure"), style={"height": config.FIGURE_HEIGHT}) @staticmethod - # Types dont match superclass - def load_outputs(run, inputs, outputs) -> go.Figure: + def load_outputs(run, inputs, outputs) -> go.Figure: # type: ignore """ Read in the raw data and prepare them for the layout. diff --git a/deepcave/plugins/objective/pareto_front.py b/deepcave/plugins/objective/pareto_front.py index 7f9fe5e0..db3b836f 100644 --- a/deepcave/plugins/objective/pareto_front.py +++ b/deepcave/plugins/objective/pareto_front.py @@ -232,8 +232,7 @@ def load_inputs(self) -> Dict[str, Dict[str, Any]]: } @staticmethod - # Types dont match superclass - def process(run, inputs) -> Dict[str, Any]: + def process(run, inputs) -> Dict[str, Any]: # type: ignore """ Return raw data based on a run and input data. @@ -332,8 +331,7 @@ def get_output_layout(register: Callable) -> dcc.Graph: return dcc.Graph(register("graph", "figure"), style={"height": config.FIGURE_HEIGHT}) @staticmethod - # Types dont match superclass - def load_outputs(runs, inputs, outputs) -> go.Figure: + def load_outputs(runs, inputs, outputs) -> go.Figure: # type: ignore """ Read in the raw data and prepare them for the layout. @@ -470,8 +468,7 @@ def get_mpl_output_layout(register: Callable) -> html.Img: ) @staticmethod - # Types dont match superclass - def load_mpl_outputs(runs, inputs, outputs): + def load_mpl_outputs(runs, inputs, outputs): # type: ignore """ Read in the raw data and prepare them for the layout. @@ -521,10 +518,9 @@ def load_mpl_outputs(runs, inputs, outputs): x += [points[point_idx][0]] y += [points[point_idx][1]] - # Issue opened - color = plt.get_color(idx) # , alpha=0.1) - # Issue opened - color_pareto = plt.get_color(idx) + # , alpha=0.1) + color = plt.get_color(idx) # type: ignore + color_pareto = plt.get_color(idx) # type: ignore if show_all: plt.scatter(x, y, color=color, marker="o", alpha=0.1, s=3) @@ -558,5 +554,5 @@ def load_mpl_outputs(runs, inputs, outputs): plt.ylabel(objective_2.name) plt.legend() - # Issue already opened - return plt.render() + + return plt.render() # type: ignore diff --git a/deepcave/plugins/static.py b/deepcave/plugins/static.py index ffa40ba4..85a9fb00 100644 --- a/deepcave/plugins/static.py +++ b/deepcave/plugins/static.py @@ -378,8 +378,7 @@ def _get_job_id(self, run_name: str, inputs_key: str) -> str: return f"{run_name}-{inputs_key}" @interactive - # Return type does not match the superclass - def __call__(self) -> List[Component]: + def __call__(self) -> List[Component]: # type: ignore """ Return the components for the plugin. diff --git a/deepcave/plugins/summary/configurations.py b/deepcave/plugins/summary/configurations.py index 82ea377e..f1d44d69 100644 --- a/deepcave/plugins/summary/configurations.py +++ b/deepcave/plugins/summary/configurations.py @@ -113,8 +113,7 @@ def load_inputs(self) -> Dict[str, Any]: "config_id": {"min": 0, "max": 0, "marks": get_slider_marks(), "value": 0}, } - # Types dont match superclass - def load_dependency_inputs( + def load_dependency_inputs( # type: ignore self, run, previous_inputs: Dict[str, Any], inputs: Dict[str, Any] ) -> Dict[str, Any]: """ @@ -131,6 +130,7 @@ def load_dependency_inputs( The selected run. previous_inputs : Previous content of the inputs. + Not used in this specific function inputs : Dict[str, Any] The current content of the inputs. @@ -155,8 +155,7 @@ def load_dependency_inputs( } @staticmethod - # Types dont match superclass - def process(run, inputs) -> Dict[str, Any]: + def process(run, inputs) -> Dict[str, Any]: # type: ignore """ Return raw data based on a run and input data. @@ -454,8 +453,7 @@ def _get_configspace_figure( return fig @staticmethod - # Types dont match superclass - def load_outputs(run, inputs, outputs) -> List[Any]: + def load_outputs(run, inputs, outputs) -> List[Any]: # type: ignore """ Read in the raw data and prepare them for the layout. diff --git a/deepcave/plugins/summary/footprint.py b/deepcave/plugins/summary/footprint.py index 4a0b0cee..612065eb 100644 --- a/deepcave/plugins/summary/footprint.py +++ b/deepcave/plugins/summary/footprint.py @@ -170,8 +170,7 @@ def load_inputs(self) -> Dict[str, Dict[str, Any]]: "show_supports": {"options": get_select_options(binary=True), "value": "true"}, } - # Types dont match superclass - def load_dependency_inputs(self, run, previous_inputs, inputs) -> Dict[str, Any]: + def load_dependency_inputs(self, run, previous_inputs, inputs) -> Dict[str, Any]: # type: ignore # noqa: E501 """ Work like 'load_inputs' but called after inputs have changed. @@ -186,6 +185,7 @@ def load_dependency_inputs(self, run, previous_inputs, inputs) -> Dict[str, Any] The selected run. previous_inputs : Previous content of the inputs. + Not used in this specific function. inputs : Current content of the inputs. @@ -225,8 +225,7 @@ def load_dependency_inputs(self, run, previous_inputs, inputs) -> Dict[str, Any] } @staticmethod - # Types dont match superclass - def process(run, inputs) -> Dict[str, Any]: + def process(run, inputs) -> Dict[str, Any]: # type: ignore """ Return raw data based on a run and input data. @@ -310,8 +309,7 @@ def get_output_layout(register: Callable) -> dbc.Tabs: ) @staticmethod - # Types dont match superclass - def load_outputs(run, inputs, outputs) -> List[Any]: + def load_outputs(run, inputs, outputs) -> List[Any]: # type: ignore """ Read in the raw data and prepare them for the layout. @@ -454,8 +452,7 @@ def get_mpl_output_layout(register: Callable) -> List[dbc.Tabs]: ] @staticmethod - # Types dont match superclass - def load_mpl_outputs(run, inputs, outputs): + def load_mpl_outputs(run, inputs, outputs): # type: ignore """ Read in the raw data and prepare them for the layout. @@ -521,13 +518,13 @@ def load_mpl_outputs(run, inputs, outputs): if points == "incumbent_points": size = 10 marker_symbol = "^" - # Issue opened - color = plt.get_color(color_id) + + color = plt.get_color(color_id) # type: ignore plt.scatter(x, y, marker=marker_symbol, s=size, label=name, c=color) plt.axis("off") plt.legend(loc="lower right") - # Issue opened - images += [plt.render()] + + images += [plt.render()] # type: ignore return images diff --git a/deepcave/plugins/summary/overview.py b/deepcave/plugins/summary/overview.py index bd03fceb..a3edae86 100644 --- a/deepcave/plugins/summary/overview.py +++ b/deepcave/plugins/summary/overview.py @@ -103,8 +103,7 @@ def get_output_layout(register: Callable) -> List[Any]: ] @staticmethod - # Types dont match superclass - def load_outputs(run, *_: Any) -> List[Any]: + def load_outputs(run, *_: Any) -> List[Any]: # type: ignore """ Read in the raw data and prepare them for the layout. diff --git a/deepcave/runs/__init__.py b/deepcave/runs/__init__.py index 2f00c411..0ee084e9 100644 --- a/deepcave/runs/__init__.py +++ b/deepcave/runs/__init__.py @@ -504,7 +504,7 @@ def get_budget(self, id: Union[int, str], human: bool = False) -> Union[int, flo If the budget with this id is invalid. """ budgets = self.get_budgets(human=human) - return budgets[int(id)] + return budgets[int(id)] # type: ignore def get_budget_ids(self, include_combined: bool = True) -> List[int]: """ @@ -900,8 +900,7 @@ def get_model(self, config_id: int) -> Optional["torch.nn.Module"]: # type: ign """ import torch - # Issue is opened - filename = self.models_dir / f"{str(config_id)}.pth" + filename = self.models_dir / f"{str(config_id)}.pth" # type: ignore if not filename.exists(): return None diff --git a/deepcave/runs/converters/bohb.py b/deepcave/runs/converters/bohb.py index c3a552ad..b6aa0a78 100644 --- a/deepcave/runs/converters/bohb.py +++ b/deepcave/runs/converters/bohb.py @@ -134,8 +134,8 @@ def from_path(cls, path: Union[Path, str]) -> "BOHBRun": status = Status.SUCCESS elif ( "RUNNING" in status_string or "QUEUED" in status_string or "REVIEW" in status_string - ): # RUNNING is no attribute in Status, Issue already opened - status = Status.RUNNING + ): + status = Status.RUNNING # type: ignore else: status = Status.CRASHED