1
0
mirror of https://github.com/ARM-software/workload-automation.git synced 2025-01-31 18:21:14 +00:00

config/core: JobsGenerator: delay augmentation split

Delay the split of augmentations into instruments and output processors
until they are actually being accessed; keep them as a single set until
then. This makes tracking of merges from various configurations sources
easier
This commit is contained in:
sergei Trofimov 2018-04-27 14:15:20 +01:00 committed by Marc Bonnici
parent 98e86efbda
commit 5b03ac3afd

View File

@ -897,23 +897,35 @@ class JobGenerator(object):
@property @property
def enabled_instruments(self): def enabled_instruments(self):
self._read_enabled_instruments = True self._read_augmentations = True
return self._enabled_instruments.values() if self._enabled_instruments is None:
self._enabled_instruments = []
for entry in self._enabled_augmentations.merge_with(self.disabled_augmentations).values():
entry_cls = self.plugin_cache.get_plugin_class(entry)
if entry_cls.kind == 'instrument':
self._enabled_instruments.append(entry)
return self._enabled_instruments
@property @property
def enabled_processors(self): def enabled_processors(self):
self._read_enabled_processors = True self._read_augmentations = True
return self._enabled_processors.values() if self._enabled_processors is None:
self._enabled_processors = []
for entry in self._enabled_augmentations.merge_with(self.disabled_augmentations).values():
entry_cls = self.plugin_cache.get_plugin_class(entry)
if entry_cls.kind == 'output_processor':
self._enabled_processors.append(entry)
return self._enabled_processors
def __init__(self, plugin_cache): def __init__(self, plugin_cache):
self.plugin_cache = plugin_cache self.plugin_cache = plugin_cache
self.ids_to_run = [] self.ids_to_run = []
self.sections = [] self.sections = []
self.workloads = [] self.workloads = []
self._enabled_instruments = toggle_set() self._enabled_augmentations = toggle_set()
self._enabled_processors = toggle_set() self._enabled_instruments = None
self._read_enabled_instruments = False self._enabled_processors = None
self._read_enabled_processors = False self._read_augmentations = False
self.disabled_augmentations = set() self.disabled_augmentations = set()
self.job_spec_template = obj_dict(not_in_dict=['name']) self.job_spec_template = obj_dict(not_in_dict=['name'])
@ -954,24 +966,10 @@ class JobGenerator(object):
self.disabled_augmentations = self.disabled_augmentations.union(augmentations) self.disabled_augmentations = self.disabled_augmentations.union(augmentations)
def update_augmentations(self, value): def update_augmentations(self, value):
for entry in value: if self._read_augmentations:
entry_name = entry[1:] if entry.startswith('~') else entry msg = 'Cannot update augmentations after they have been accessed'
entry_cls = self.plugin_cache.get_plugin_class(entry_name)
if entry_cls.kind == 'instrument':
if self._read_enabled_instruments:
msg = "'enabled_instruments' cannot be updated after it has been accessed"
raise RuntimeError(msg) raise RuntimeError(msg)
self._enabled_instruments.add(entry) self._enabled_augmentations = self._enabled_augmentations.merge_with(value)
elif entry_cls.kind == 'output_processor':
if self._read_enabled_processors:
msg = "'enabled_processors' cannot be updated after it has been accessed"
raise RuntimeError(msg)
self._enabled_processors.add(entry)
else:
msg = 'Unknown augmentation type: {}'
raise ConfigError(msg.format(entry_cls.kind))
self._enabled_instruments = self._enabled_instruments.merge_with(self.disabled_augmentations)
self._enabled_processors = self._enabled_processors.merge_with(self.disabled_augmentations)
def only_run_ids(self, ids): def only_run_ids(self, ids):
if isinstance(ids, str): if isinstance(ids, str):