Skip to content

Commit

Permalink
Resolve merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
Marvin Erdmann authored and Marvin Erdmann committed Dec 6, 2024
2 parents a74ec41 + 5eb49f4 commit ec6c765
Show file tree
Hide file tree
Showing 11 changed files with 611 additions and 71 deletions.
65 changes: 52 additions & 13 deletions src/ConfigManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,33 @@ def generate_benchmark_configs(self, app_modules: list[dict]) -> None:
self.application = _get_instance_with_sub_options(app_modules, app_name)

application_config = self.application.get_parameter_options()
application_config = ConfigManager._query_for_config(
application_config, f"(Option for {application_answer['application']})")

submodule_options = self.application.get_available_submodule_options()
submodule_answer = checkbox(key='submodules', message="What submodule do you want?",
choices=submodule_options)
more_app_config = {}

full_application_config = ConfigManager._query_for_config(
application_config, f"(Option for {application_answer['application']})")
depending_submodules = False

available_submodules = []
for parameter in application_config:
if ("depending_submodule" in application_config[parameter] and
application_config[parameter]["depending_submodule"]):
available_submodules = self.application.get_available_submodules(full_application_config[parameter])
depending_submodules = True
if not depending_submodules:
available_submodules = self.application.get_available_submodule_options()
submodule_answer = checkbox(key='submodules',
message="What submodule do you want?",
choices=available_submodules)
for option in submodule_answer["submodules"]:
if self.application.depending_parameters:
more_app_config = self.application.get_depending_parameters(option, full_application_config)
more_app_config = (ConfigManager._query_for_config
(more_app_config, f"(Option for {self.application.__class__.__name__})"))
full_application_config = full_application_config | more_app_config
self.config = {
"application": {
"name": app_name,
"config": application_config,
"config": full_application_config,
"submodules": [self.query_module(self.application.get_submodule(sm), sm) for sm in
submodule_answer["submodules"]],
},
Expand All @@ -109,15 +125,38 @@ def query_module(self, module: Core, module_friendly_name: str) -> ConfigModule:
:return: Config module with the choices of the user
"""
module_config = module.get_parameter_options()
module_config = ConfigManager._query_for_config(module_config,
f"(Option for {module.__class__.__name__})")
available_submodules = module.get_available_submodule_options()
submodule_answer = checkbox(key='submodules', message="What submodule do you want?",
choices=available_submodules)
full_module_config = ConfigManager._query_for_config(module_config, f"(Option for {module.__class__.__name__})")
depending_submodules = False
available_submodules = []
for parameter in module_config:
if ("depending_submodule" in module_config[parameter] and
module_config[parameter]["depending_submodule"]):
available_submodules = module.get_available_submodules(full_module_config[parameter])
depending_submodules = True
if not depending_submodules:
available_submodules = module.get_available_submodule_options()
more_module_config = {}
if available_submodules:
if len(available_submodules) == 1:
logging.info(
f"Skipping asking for submodule, since only 1 option ({available_submodules[0]}) is available.")
submodule_answer = {"submodules": [available_submodules[0]]}
else:
submodule_answer = checkbox(key='submodules',
message="What submodule do you want?",
choices=available_submodules)
for option in submodule_answer:
if module.depending_parameters:
more_module_config = module.get_depending_parameters(option, full_module_config)
more_module_config = (ConfigManager._query_for_config
(more_module_config, f"(Option for {module.__class__.__name__})"))
full_module_config = full_module_config | more_module_config
else:
submodule_answer = {"submodules": []}

return {
"name": module_friendly_name,
"config": module_config,
"config": full_module_config,
"submodules": [self.query_module(module.get_submodule(sm), sm) for sm in
submodule_answer["submodules"]]
}
Expand Down
3 changes: 2 additions & 1 deletion src/Plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@
from collections import defaultdict
import logging

import matplotlib.pyplot as plt
import matplotlib
from matplotlib import pyplot as plt
import seaborn as sns
import pandas as pd

matplotlib.use('Agg')
matplotlib.rcParams['savefig.dpi'] = 300
sns.set(style="darkgrid")

Expand Down
25 changes: 24 additions & 1 deletion src/modules/Core.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import sys
from abc import ABC, abstractmethod
from typing import final

from utils import _get_instance_with_sub_options
from Metrics import Metrics

Expand All @@ -31,10 +32,11 @@ def __init__(self, name: str = None):
"""
Constructor method.
:param name: name used to identify this QUARK module. If not specified class name will be used as default.
:param name: Name used to identify this QUARK module. If not specified class name will be used as default.
"""
self.submodule_options = []
self.sub_options = []
self.depending_parameters = False
self.preprocessed_input = None
self.postprocessed_input = None
if name is None:
Expand Down Expand Up @@ -67,6 +69,27 @@ def get_parameter_options(self) -> dict:
raise NotImplementedError("Please don't use the base version of get_parameter_options. "
"Implement your own override instead.")

def get_available_submodules(self, option: list) -> list:
"""
If the module has submodules depending on certain options, this method should adjust the submodule_options
accordingly.
:param option: List of chosen options
:return: List of available submodules
"""
return []

def get_depending_parameters(self, option: str, config: dict) -> dict:
"""
If the module has parameters depending on certain options, this method should return the parameters for the
given option.
:param option: The chosen option
:param config: Current config dictionary
:return: The parameters for the given option
"""
return {}

@final
def get_submodule(self, option: str) -> Core:
"""
Expand Down
Loading

0 comments on commit ec6c765

Please sign in to comment.