Skip to content

Commit

Permalink
revised more plugin docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
KrissiHub committed Jan 21, 2024
1 parent 06276c6 commit affdb1a
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 43 deletions.
2 changes: 2 additions & 0 deletions deepcave/plugins/budget/budget_correlation.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,8 @@ def load_outputs(run, _, outputs) -> List[Any]:
compared to 'load_inputs' or 'load_dependency_inputs'.
Please see '_clean_inputs' for more information.
The returned components must be in the same position as defined in 'get_output_layout'.
Parameters
----------
run
Expand Down
3 changes: 1 addition & 2 deletions deepcave/plugins/hyperparameter/importances.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,6 @@ def load_outputs(run, inputs, outputs) -> go.Figure:
compared to 'load_inputs' or 'load_dependency_inputs'.
Please see '_clean_inputs' for more information.
Parameters
----------
run
Expand Down Expand Up @@ -462,7 +461,7 @@ def get_mpl_output_layout(register: Callable) -> html.Img:
def load_mpl_outputs(run, inputs: Dict[str, Any], outputs):
"""
Read the raw data and prepare it for the layout.
Parameters
----------
run
Expand Down
18 changes: 13 additions & 5 deletions deepcave/plugins/objective/configuration_cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,18 @@ def get_filter_layout(register: Callable) -> List[html.Div]:
),
]

def load_inputs(
self,
) -> Dict[str, Any]:
"""Load the inputs containing configuration and hyperparameter (HP) attributes."""
def load_inputs(self) -> Dict[str, Any]:
"""
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.
So, 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, Any]
The content to be filled.
"""
return {
"n_configs": {"min": 0, "max": 0, "marks": get_slider_marks(), "value": 0},
"hyperparameter_names": {"options": get_checklist_options(), "value": []},
Expand All @@ -152,7 +160,7 @@ def load_inputs(
# Types dont match superclass
def load_dependency_inputs(self, run, _, inputs) -> Dict[str, Any]:
"""
Same as load_inputs but called after inputs have changed.
Same as 'load_inputs' but called after inputs have changed.
It is restricted to three Hyperparameters.
Expand Down
82 changes: 57 additions & 25 deletions deepcave/plugins/summary/configurations.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,17 @@ def get_input_layout(register: Callable) -> List[html.Div]:
]

def load_inputs(self) -> Dict[str, Any]:
"""Get the inputs, containing information about a configuration."""
"""
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.
So, 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, Any]
The content to be filled
"""
return {
"config_id": {"min": 0, "max": 0, "marks": get_slider_marks(), "value": 0},
}
Expand All @@ -107,19 +117,25 @@ def load_dependency_inputs(
self, run, previous_inputs: Dict[str, Any], inputs: Dict[str, Any]
) -> Dict[str, Any]:
"""
Get selected values of the inputs.
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(s) to be analyzed.
The selected run.
previous_inputs :
Previous content of the inputs.
inputs : Dict[str, Any]
The inputs for the visualization.
The current content of the inputs.
Returns
-------
Dict[str, Any]
A dictionary of information about a configuration.
A dictionary with the changes.
"""
# Get selected values
config_id_value = inputs["config_id"]["value"]
Expand All @@ -140,19 +156,28 @@ def load_dependency_inputs(
# Types dont match superclass
def process(run, inputs) -> Dict[str, Any]:
"""
Process the given data, show information about the configuration space.
Return raw data based on a run and input data.
Warning
-------
The returned data must be JSON serializable.
Note
----
The passed inputs are cleaned and therefore differs compared to 'load_inputs' or 'load_dependency_inputs'.
Please see '_clean_inputs' for more information.
Parameters
----------
run :
The run to be analyzed.
The selected run.
inputs :
The inputs for the visualization.
The input data.
Returns
-------
Dict[str, Any]
A dictionary containing performance information about the configuration space.
A serialized dictionary.
"""
selected_config_id = int(inputs["config_id"])
origin = run.get_origin(selected_config_id)
Expand Down Expand Up @@ -237,18 +262,18 @@ def get_output_layout(
register: Callable,
) -> List[Any]:
"""
Get an html container as well as a dash bootstrap component (DBC) for the output layout.
Get the layout for the output block.
Parameters
----------
register : Callable
Used for the id of the Div and Graph objects.
Method used to register outputs.
The register_input function is located in the Plugin superclass.
Returns
-------
List[Any]
An html container as well as a dash bootstrap component (DBC) for the output layout.
The layouts for the outputs.
"""
return [
html.Div(id=register("overview_table", "children"), className="mb-3"),
Expand Down Expand Up @@ -299,19 +324,19 @@ def _get_objective_figure(
_: Any, outputs: Dict[str, Dict[str, Dict[Any, Any]]], run: AbstractRun
) -> go.Figure:
"""
Get the objective figure and save as image.
Get the figure for the visualization of the objectives.
Parameters
----------
outputs : Dict[str, Dict[str, Dict[Any, Any]]]
Contains performance information.
Raw outputs from the run.
run : AbstractRun
The run to be analyzed.
The selected run.
Returns
-------
go.Figure
A plotly objective figure.
The figure of the objectives.
"""
objective_data = []
for i, (metric, values) in enumerate(outputs["performances"].items()):
Expand Down Expand Up @@ -368,19 +393,19 @@ def _get_configspace_figure(
inputs: Any, outputs: Dict[str, str], run: AbstractRun
) -> go.Figure:
"""
Get the configuration space figure.
Get the figure for the visualization of the configuration space.
Parameters
----------
outputs : Dict[str, str]
Contains the configuration space data frame.
Raw outputs from the run.
run : AbstractRun
The run to be analyzed.
The selected run.
Returns
-------
go.Figure
A plotly configuration space figure.
The figure of the configuration space.
"""
df = deserialize(outputs["cs_df"], dtype=pd.DataFrame)

Expand Down Expand Up @@ -429,21 +454,28 @@ def _get_configspace_figure(
# Types dont match superclass
def load_outputs(run, inputs, outputs) -> List[Any]:
"""
Load the outputs create the table containing performances and configuration space.
Read in the raw data and prepare them for the layout.
Note
----
The passed inputs are cleaned and therefore differs compared to 'load_inputs' or 'load_dependency_inputs'.
Please see '_clean_inputs' for more information.
The returned components must be in the same position as defined in 'get_output_layout'.
Parameters
----------
run
The run to be analyzed.
The selected run.
inputs
Contains information about the configuration.
Input and filter values from the user.
outputs
Contains information about the performances, and the configuration space.
Raw output from the run.
Returns
-------
List[Any]
A list of the created tables containing the information.
A list of the created tables containing output information.
"""
config_id = inputs["config_id"]
config = run.get_config(config_id)
Expand Down
32 changes: 21 additions & 11 deletions deepcave/plugins/summary/footprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
The module contains a static plugin class for defining the footprint.
## Classes
- FootPrint: Visualize the footprint of a configuration.
- FootPrint: A static plugin for the footprint of a configuration.
"""

from typing import Any, Callable, Dict, List, Union
Expand All @@ -32,7 +32,7 @@ class FootPrint(StaticPlugin):
"""
Visualize the footprint of a configuration.
Represent a static plugin for the footprint.
A static plugin for the footprint.
"""

id = "footprint"
Expand All @@ -42,20 +42,20 @@ class FootPrint(StaticPlugin):
activate_run_selection = True

@staticmethod
def get_input_layout(register: Callable) -> List[Union[dbc.Row, html.Div]]:
def get_input_layout(register: Callable) -> List[Any]:
"""
Get the input layout as html container and dash bootstrap component (DBC).
Get the layout for the input block.
Parameters
----------
register : Callable
Used to get the id for the select object and the slider.
Method to register (user) variables.
The register_input function is located in the Plugin superclass.
Returns
-------
List[Union[dbc.Row, html.Div]]
An html container and a dash bootstrap component (DBC) of the layout of the input.
List[Any]
The layouts for the input block.
"""
return [
dbc.Row(
Expand Down Expand Up @@ -111,18 +111,18 @@ def get_input_layout(register: Callable) -> List[Union[dbc.Row, html.Div]]:
@staticmethod
def get_filter_layout(register: Callable) -> List[dbc.Row]:
"""
Get the filtered layout for a dash bootstrap component (DBC).
Get layout for the filter block.
Parameters
----------
register : Callable
Used for the id of the select object.
Method to register (user) variables.
The register_input function is located in the Plugin superclass.
Returns
-------
List[dbc.Row]
A filtered layout with a dash bootstrap component (DBC).
The layouts for the filter block.
"""
return [
dbc.Row(
Expand Down Expand Up @@ -152,7 +152,17 @@ def get_filter_layout(register: Callable) -> List[dbc.Row]:
]

def load_inputs(self) -> Dict[str, Dict[str, Any]]:
"""Get the inputs, containing details, and border/supports information."""
"""
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.
So, 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 content to be filled.
"""
return {
"details": {"value": 0.5},
"show_borders": {"options": get_select_options(binary=True), "value": "true"},
Expand Down

0 comments on commit affdb1a

Please sign in to comment.