From 97d822c2b742b59c55a3db31cfaaeaceb57bf568 Mon Sep 17 00:00:00 2001 From: Sebastian Goscik Date: Tue, 27 Sep 2016 11:25:39 +0100 Subject: [PATCH] Configuration: Added a new module for generating the default config file This commit also adds a missing scription to the `csv` result processor --- wlauto/core/configuration/default.py | 42 ++++++++++++++++++++++++++++ wlauto/result_processors/standard.py | 6 ++-- 2 files changed, 45 insertions(+), 3 deletions(-) create mode 100644 wlauto/core/configuration/default.py diff --git a/wlauto/core/configuration/default.py b/wlauto/core/configuration/default.py new file mode 100644 index 00000000..0d520ca9 --- /dev/null +++ b/wlauto/core/configuration/default.py @@ -0,0 +1,42 @@ +from wlauto.core.configuration.configuration import WAConfiguration, RunConfiguration +from wlauto.core.configuration.plugin_cache import PluginCache +from wlauto.utils.serializer import yaml +from wlauto.utils.doc import strip_inlined_text + +DEFAULT_INSTRUMENTS = ['execution_time', + 'interrupts', + 'cpufreq', + 'status', + 'standard', + 'csv'] + + +def _format_yaml_comment(param, short_description=False): + comment = param.description + comment = strip_inlined_text(comment) + if short_description: + comment = comment.split('\n\n')[0] + comment = comment.replace('\n', '\n# ') + comment = "# {}\n".format(comment) + return comment + + +def _format_instruments(output): + plugin_cache = PluginCache() + output.write("instrumentation:\n") + for plugin in DEFAULT_INSTRUMENTS: + plugin_cls = plugin_cache.loader.get_plugin_class(plugin) + output.writelines(_format_yaml_comment(plugin_cls, short_description=True)) + output.write(" - {}\n".format(plugin)) + output.write("\n") + + +def generate_default_config(path): + with open(path, 'w') as output: + for param in WAConfiguration.config_points + RunConfiguration.config_points: + entry = {param.name: param.default} + comment = _format_yaml_comment(param) + output.writelines(comment) + yaml.dump(entry, output, default_flow_style=False) + output.write("\n") + _format_instruments(output) diff --git a/wlauto/result_processors/standard.py b/wlauto/result_processors/standard.py index 254fb21b..8bd2f254 100644 --- a/wlauto/result_processors/standard.py +++ b/wlauto/result_processors/standard.py @@ -56,14 +56,14 @@ class StandardProcessor(ResultProcessor): class CsvReportProcessor(ResultProcessor): - """ + + name = 'csv' + description = """ Creates a ``results.csv`` in the output directory containing results for all iterations in CSV format, each line containing a single metric. """ - name = 'csv' - parameters = [ Parameter('use_all_classifiers', kind=bool, default=False, global_alias='use_all_classifiers',