From 25c0fd7b8bc95bb972d7a9105cc3ef314965ee72 Mon Sep 17 00:00:00 2001 From: Sergei Trofimov Date: Mon, 17 Aug 2015 10:37:40 +0100 Subject: [PATCH] Allow setting classifiers via agenda. --- wlauto/core/agenda.py | 3 +++ wlauto/core/configuration.py | 6 +++++- wlauto/core/result.py | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/wlauto/core/agenda.py b/wlauto/core/agenda.py index 171a7932..55feae70 100644 --- a/wlauto/core/agenda.py +++ b/wlauto/core/agenda.py @@ -70,6 +70,7 @@ class AgendaWorkloadEntry(AgendaEntry): default=OrderedDict()) self.instrumentation = kwargs.pop('instrumentation', []) self.flash = kwargs.pop('flash', OrderedDict()) + self.classifiers = kwargs.pop('classifiers', OrderedDict()) if kwargs: raise ConfigError('Invalid entry(ies) in workload {}: {}'.format(self.id, ', '.join(kwargs.keys()))) @@ -96,6 +97,7 @@ class AgendaSectionEntry(AgendaEntry): default=OrderedDict()) self.instrumentation = kwargs.pop('instrumentation', []) self.flash = kwargs.pop('flash', OrderedDict()) + self.classifiers = kwargs.pop('classifiers', OrderedDict()) self.workloads = [] for w in kwargs.pop('workloads', []): self.workloads.append(agenda.get_workload_entry(w)) @@ -128,6 +130,7 @@ class AgendaGlobalEntry(AgendaEntry): default=OrderedDict()) self.instrumentation = kwargs.pop('instrumentation', []) self.flash = kwargs.pop('flash', OrderedDict()) + self.classifiers = kwargs.pop('classifiers', OrderedDict()) if kwargs: raise ConfigError('Invalid entries in global section: {}'.format(kwargs)) diff --git a/wlauto/core/configuration.py b/wlauto/core/configuration.py index 7ebf1910..0a981938 100644 --- a/wlauto/core/configuration.py +++ b/wlauto/core/configuration.py @@ -77,6 +77,7 @@ class WorkloadRunSpec(object): runtime_parameters=None, instrumentation=None, flash=None, + classifiers=None, ): # pylint: disable=W0622 self.id = id self.number_of_iterations = number_of_iterations @@ -88,6 +89,7 @@ class WorkloadRunSpec(object): self.workload_parameters = workload_parameters or OrderedDict() self.instrumentation = instrumentation or [] self.flash = flash or OrderedDict() + self.classifiers = classifiers or OrderedDict() self._workload = None self._section = None self.enabled = True @@ -96,7 +98,7 @@ class WorkloadRunSpec(object): if param in ['id', 'section_id', 'number_of_iterations', 'workload_name', 'label']: if value is not None: setattr(self, param, value) - elif param in ['boot_parameters', 'runtime_parameters', 'workload_parameters', 'flash']: + elif param in ['boot_parameters', 'runtime_parameters', 'workload_parameters', 'flash', 'classifiers']: setattr(self, param, merge_dicts(getattr(self, param), value, list_duplicates='last', dict_type=OrderedDict, should_normalize=False)) elif param in ['instrumentation']: @@ -167,6 +169,7 @@ class WorkloadRunSpec(object): other.workload_parameters = copy(self.workload_parameters) other.instrumentation = copy(self.instrumentation) other.flash = copy(self.flash) + other.classifiers = copy(self.classifiers) other._section = self._section # pylint: disable=protected-access other.enabled = self.enabled return other @@ -492,6 +495,7 @@ class RunConfiguration(object): RunConfigurationItem('runtime_parameters', 'dict', 'merge'), RunConfigurationItem('instrumentation', 'list', 'merge'), RunConfigurationItem('flash', 'dict', 'merge'), + RunConfigurationItem('classifiers', 'dict', 'merge'), ] # List of names that may be present in configuration (and it is valid for diff --git a/wlauto/core/result.py b/wlauto/core/result.py index bacb228c..1ec3c88c 100644 --- a/wlauto/core/result.py +++ b/wlauto/core/result.py @@ -254,13 +254,13 @@ class IterationResult(object): self.spec = spec self.id = spec.id self.workload = spec.workload + self.classifiers = copy(spec.classifiers) self.iteration = None self.status = self.NOT_STARTED self.output_directory = None self.events = [] self.metrics = [] self.artifacts = [] - self.classifiers = {} def add_metric(self, name, value, units=None, lower_is_better=False, classifiers=None): classifiers = merge_dicts(self.classifiers, classifiers or {},