Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug/pre commit hooks #94

Merged
merged 55 commits into from
Feb 23, 2024
Merged
Changes from 1 commit
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
6f1f4e8
Fix flake config
Apr 12, 2023
3c50ce4
Refactor docstrings, ignore D102 (missing docstring) for overwritten …
helegraf Apr 12, 2023
12b2c6a
Ignore missing inputs
Apr 12, 2023
240a7c2
Refactor docstrings.
helegraf Apr 12, 2023
f6877b8
Fix mypy errors in utils files
Apr 12, 2023
f815346
Solve merge conflict
Apr 12, 2023
021cbe9
Refactor docstrings
helegraf Jun 28, 2023
4d796df
Add type ignores/ types
helegraf Jun 28, 2023
c973068
Eliminated all D401 in pre-commit
KrissiHub Aug 15, 2023
1dc0505
added a few docstrings
KrissiHub Aug 25, 2023
af13db4
added docstrings
KrissiHub Aug 26, 2023
24d3ee4
added more docstrings
KrissiHub Aug 27, 2023
c0a6a60
added even more docstrings
KrissiHub Aug 28, 2023
a36a4bc
more docstrings added
KrissiHub Aug 28, 2023
388bf37
pydocstyle passes
KrissiHub Aug 29, 2023
d7732ef
added all docstrings
KrissiHub Sep 12, 2023
a87b743
added type annotations and changed the make file
KrissiHub Oct 5, 2023
bce1de4
added some more type annotations
KrissiHub Oct 5, 2023
8baf7fc
changed pre commit, so all errors get caught
KrissiHub Oct 10, 2023
e053e92
fixed a few type annotation problems
KrissiHub Oct 11, 2023
0f00bb7
fixed a few type annotations
KrissiHub Oct 30, 2023
1327166
fixed a few type annotations
KrissiHub Nov 1, 2023
c2d4b90
ajust docs to type annotations
KrissiHub Nov 6, 2023
fea9889
changed a few docstrings
KrissiHub Nov 6, 2023
e20d749
ready for a draft
KrissiHub Nov 6, 2023
e620250
changed a few details
KrissiHub Nov 13, 2023
0391d60
docstrings and noqa/type ignores revised
KrissiHub Nov 14, 2023
2fc0361
changed a few small details
KrissiHub Nov 17, 2023
0d49311
tests should run trough now
KrissiHub Nov 22, 2023
ba394c9
added an install command for examples
KrissiHub Nov 22, 2023
dec68b6
Merge branch 'main' into bug/pre-commit-hooks
KrissiHub Nov 22, 2023
22cf5c9
resolved a conflict
KrissiHub Nov 22, 2023
a78ea11
Merge branch 'main' into bug/pre-commit-hooks
KrissiHub Nov 23, 2023
6e9e9bf
resolved conflicts
KrissiHub Nov 23, 2023
8ab95e7
merge should have worked now
KrissiHub Nov 23, 2023
0909690
docs test error resolved - hopefully
KrissiHub Nov 23, 2023
ff69418
Changed the changelog file accordingly
KrissiHub Nov 23, 2023
4c0dbf6
Fixed Issue #80
KrissiHub Dec 1, 2023
1396581
Fixed a minor merge issue
KrissiHub Dec 1, 2023
3e45b16
revised the evaluators documentation
KrissiHub Jan 19, 2024
a16d3ae
revised layout documentation
KrissiHub Jan 19, 2024
f487b5c
revised a few plugin docstrings
KrissiHub Jan 19, 2024
06276c6
revised a few plugin docstrings
KrissiHub Jan 20, 2024
affdb1a
revised more plugin docstrings
KrissiHub Jan 21, 2024
49e3249
plugin docstrings revised
KrissiHub Jan 22, 2024
d91f3dd
revised the converter docstrings
KrissiHub Jan 25, 2024
1c4c55a
revised more runs docstrings
KrissiHub Jan 25, 2024
bb61cd4
revised runs docstrings
KrissiHub Feb 8, 2024
dadc8cb
revised utils docstrings
KrissiHub Feb 8, 2024
021a111
revised remaining docstrings
KrissiHub Feb 8, 2024
b40b6da
reformatted docstrings for pydocstyle again
KrissiHub Feb 8, 2024
4502afe
minor details adjusted
KrissiHub Feb 8, 2024
967692d
fixed non existing variable model_opt
KrissiHub Feb 9, 2024
f753273
Solve merge conflict
Feb 22, 2024
4eacae3
Minor fixes from PR
Feb 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
revised a few plugin docstrings
  • Loading branch information
KrissiHub committed Jan 19, 2024
commit f487b5c44be469e2fae665338ea098a50c97aa01
51 changes: 36 additions & 15 deletions deepcave/plugins/budget/budget_correlation.py
Original file line number Diff line number Diff line change
@@ -31,7 +31,7 @@

class BudgetCorrelation(DynamicPlugin):
"""
Can be used for visualizing the correlation of budgets.
Used for visualizing the correlation of budgets.

Provided utilities include getting input/output layout, data processing
and loading outputs.
@@ -67,18 +67,18 @@ def check_run_compatibility(run: AbstractRun) -> bool:
@staticmethod
def get_input_layout(register: Callable) -> List[html.Div]:
"""
Get the html container for the layout of the input.
Get the layout for the input block.

Parameters
----------
register : Callable
Used for the id of the objective.
Method to register (user) variables.
The register_input function is located in the Plugin superclass.

Returns
-------
List[html.Div]
An html container for the layout of the input.
Layouts for the input block.
"""
return [
html.Div(
@@ -95,7 +95,11 @@ 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]]:
"""
Load the objectives attributes.
Same as 'load_inputs' but called after inputs have changed.

Note
----
Only the changes are returned, they will be later merged with the inputs.

Parameters
----------
@@ -107,7 +111,7 @@ def load_dependency_inputs(self, run, _, inputs) -> Dict[str, Dict[str, Any]]:
Returns
-------
Dict[str, Dict[str, Any]]
The objectives id, its options and a value.
A dictionary with the changes.
"""
objective_names = run.get_objective_names()
objective_ids = run.get_objective_ids()
@@ -127,19 +131,30 @@ def load_dependency_inputs(self, run, _, inputs) -> Dict[str, Dict[str, Any]]:
@staticmethod
def process(run: AbstractRun, inputs: Dict[str, int]) -> Dict[str, Any]:
"""
Load the budget and the costs of the run. Get the correlations.
Return raw data based on a run and the input data.

Warning
-------
The returned data must be JSON serializable.

Note
----
The passed inputs are cleaned and therefore differ
compared to 'load_inputs' or 'load_dependency_inputs'.
Please see '_clean_inputs' for more information.

Parameters
----------
run : AbstractRun
The run to get the budget and the costs from.
The run to process.
inputs : Dict[str, int]
The input to get the objective id from.

Returns
-------
Dict[str, Any]
The correlations as well as the correlations symmetric.
Serialized dictionary with the correlations
as well as the correlations symmetric.
"""
objective_id = inputs["objective_id"]
budget_ids = run.get_budget_ids(include_combined=False)
@@ -187,18 +202,18 @@ def process(run: AbstractRun, inputs: Dict[str, int]) -> Dict[str, Any]:
@staticmethod
def get_output_layout(register: Callable) -> List[Any]:
"""
Get the html container for the layout of the output.
Get the layout for the output block.

Parameters
----------
register : Callable
Used for the id of the Div object.
Method to register outputs.
The register_input function is located in the Plugin superclass.

Returns
-------
List[Any]
The html container containing the layout of the output.
Layout for the output block.
"""
return [
html.Div(id=register("text", "children"), className="mb-3"),
@@ -219,14 +234,20 @@ def get_output_layout(register: Callable) -> List[Any]:
# Types dont match superclass
def load_outputs(run, _, outputs) -> List[Any]:
"""
Create the output table and safe the image.
Read the raw data and prepare it for the layout.

Note
----
The passed inputs are cleaned and therefore differ
compared to 'load_inputs' or 'load_dependency_inputs'.
Please see '_clean_inputs' for more information.

Parameters
----------
run
The run to get the budget from.
The selected run.
outputs
The outputs to get the correlation and its symmetric from.
Raw output from the run.

Returns
-------
99 changes: 61 additions & 38 deletions deepcave/plugins/hyperparameter/importances.py
Original file line number Diff line number Diff line change
@@ -47,18 +47,18 @@ class Importances(StaticPlugin):
@staticmethod
def get_input_layout(register: Callable) -> List[Any]:
"""
Get the html container for the layout of the input.
Get the layout for the input block.

Parameters
----------
register : Callable
Used to get the id of the objective.
Method to register (user) variables.
The register_input function is located in the Plugin superclass.

Returns
-------
List[Any]
An html container for the layout of the input.
Layout for the input block.
"""
return [
html.Div(
@@ -109,18 +109,18 @@ def get_input_layout(register: Callable) -> List[Any]:
@staticmethod
def get_filter_layout(register: Callable) -> List[html.Div]:
"""
Get the layout for a filtered html container.
Get the layout for the filter block.

Parameters
----------
register : Callable
Used for the id of the Checklist.
Method to register (user) variables.
The register_input function is located in the Plugin superclass.

Returns
-------
List[html.Div]
A filtered html container.
Layout for the filter block.
"""
return [
html.Div(
@@ -154,12 +154,15 @@ def get_filter_layout(register: Callable) -> List[html.Div]:

def load_inputs(self) -> Dict[str, Dict[str, Any]]:
"""
Load the method labels, values and different attributes.
Load the content for the defined inputs in 'get_input_layout'
and 'get_filter_layout'. This method is necessary to pre-load contents for the inputs.
If the plugin is called for the first time, or there are no results in the cache,
the plugin gets its content from this method.

Returns
-------
Dict[str, Dict[str, Any]]
The attributes of the inputs.
Content to be filled.
"""
method_labels = ["Local Parameter Importance (local)", "fANOVA (global)"]
method_values = ["local", "global"]
@@ -178,20 +181,24 @@ def load_inputs(self) -> Dict[str, Dict[str, Any]]:
# Types dont match superclass
def load_dependency_inputs(self, run, _: Any, inputs: Dict[str, Any]) -> Dict[str, Any]:
"""
Load the objective, budgets and hyperparameters (HPs) and its attributes.
Same as 'load_inputs' but called after inputs have changed.

Note
----
Only the changes have to be returned.
The returned dictionary will be merged with the inputs.

Parameters
----------
run
The run to get the objective from.
The selected run.
inputs : Dict[str, Any]
Contains information about the objective, budgets
and number of hyperparamaters (HPs).
Current content of the inputs.

Returns
-------
Dict[str, Any]
The objective, budgets, hyperparameters (HPs) and their attributes.
A dictionary with the changes.
"""
# Prepare objectives
objective_names = run.get_objective_names()
@@ -247,26 +254,36 @@ 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]):
def process(run: AbstractRun, inputs: Dict[str, Any]) -> Dict[str, Any]:
"""
Initialize the evaluator, calculate and get the processed data.
Return raw data based on the run and input data.

Warning
-------
The returned data must be JSON serializable.

Note
----
The passed inputs are cleaned and therefore differ
compared to 'load_inputs' or 'load_dependency_inputs'.
Please see '_clean_inputs' for more information.

Parameters
----------
run : AbstractRun
The run to get the objective from.
The run to process.
inputs : Dict[str, Any]
Contains information about the method and the number of trees.
The input data.

Returns
-------
The processed data.
Dict[str, Any]
A serialzied dictionary.

Raises
------
RuntimeError
If the number of trees is not specified.
RuntimeError
If the method is not found.
"""
objective = run.get_objective(inputs["objective_id"])
@@ -302,42 +319,49 @@ def process(run: AbstractRun, inputs: Dict[str, Any]):
@staticmethod
def get_output_layout(register: Callable) -> dcc.Graph:
"""
Get a graph with the layout of the output.
Get the layout for the output block.

Parameters
----------
register : Callable
A function to get the id for the graph.
Method to register outputs.
The register_input function is located in the Plugin superclass.

Returns
-------
dcc.Graph
The graph with the layout of the output.
Layout for the output block.
"""
return dcc.Graph(register("graph", "figure"), style={"height": config.FIGURE_HEIGHT})

@staticmethod
# Types dont match superclass
def load_outputs(run, inputs, outputs):
def load_outputs(run, inputs, outputs) -> go.Figure:
"""
Load the importances and the corresponding layout of the figure.
Read in raw data and prepare for layout.

Also save the image of the figure.

Note
----
The passed inputs are cleaned and therefore differ
compared to 'load_inputs' or 'load_dependency_inputs'.
Please see '_clean_inputs' for more information.

Also safes the image of the figure.

Parameters
----------
run
The run to get the budget from.
The selected run.
inputs
Containing the hyperparameter (HPs) names, the budget ids
and the number of hyperparamaters (HPs).
Input and filter values from the user.
outputs
Containing the budget id and importances.
Raw output from the run.

Returns
-------
The figure of the importances.
go.figure
The figure of the importances.
"""
# First selected, should always be shown first
selected_hp_names = inputs["hyperparameter_names"]
@@ -417,18 +441,18 @@ def load_outputs(run, inputs, outputs):
@staticmethod
def get_mpl_output_layout(register: Callable) -> html.Img:
"""
Get an html container of the output layout.
Get the layout for the matplotlib output block.

Parameters
----------
register : Callable
A function to get the id.
Method to register outputs.
The register_input function is located in the Plugin superclass.

Returns
-------
html.Img
An html container of the matplotlib output layout.
The layout for the matplotlib output block.
"""
return html.Img(
id=register("graph", "src"),
@@ -439,17 +463,16 @@ def get_mpl_output_layout(register: Callable) -> html.Img:
# Types dont match superclass
def load_mpl_outputs(run, inputs: Dict[str, Any], outputs):
"""
Load the importances and the corresponding layout of the matplotlib figure.
Read the raw data and prepare it for the layout.

Parameters
----------
run
The run to get the budget from.
The selected run.
inputs : Dict[str, Any]
Containing the hyperparameter (HPs) names, the budget ids
and the number of hyperparameters (HPs).
Input and filter values from the user.
outputs
Containing the budget id and importances.
Raw output from the run.

Returns
-------
Loading
Loading