Skip to content

Commit

Permalink
minor details adjusted
Browse files Browse the repository at this point in the history
  • Loading branch information
KrissiHub committed Feb 8, 2024
1 parent b40b6da commit 4502afe
Show file tree
Hide file tree
Showing 16 changed files with 63 additions and 88 deletions.
3 changes: 1 addition & 2 deletions deepcave/custom_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
14 changes: 9 additions & 5 deletions deepcave/plugins/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.")

Expand Down Expand Up @@ -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
----------
Expand Down Expand Up @@ -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
----------
Expand Down Expand Up @@ -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
----------
Expand Down
13 changes: 5 additions & 8 deletions deepcave/plugins/budget/budget_correlation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)
Expand All @@ -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,
Expand Down Expand Up @@ -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.
Expand Down
3 changes: 1 addition & 2 deletions deepcave/plugins/dynamic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
19 changes: 7 additions & 12 deletions deepcave/plugins/hyperparameter/importances.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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:
Expand All @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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),
)
Expand All @@ -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
12 changes: 6 additions & 6 deletions deepcave/plugins/hyperparameter/pdp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
-------
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
6 changes: 2 additions & 4 deletions deepcave/plugins/objective/configuration_cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
6 changes: 2 additions & 4 deletions deepcave/plugins/objective/cost_over_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
9 changes: 3 additions & 6 deletions deepcave/plugins/objective/parallel_coordinates.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
20 changes: 8 additions & 12 deletions deepcave/plugins/objective/pareto_front.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
3 changes: 1 addition & 2 deletions deepcave/plugins/static.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
10 changes: 4 additions & 6 deletions deepcave/plugins/summary/configurations.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]:
"""
Expand All @@ -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.
Expand All @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
Loading

0 comments on commit 4502afe

Please sign in to comment.