1
0
mirror of https://github.com/ARM-software/workload-automation.git synced 2025-01-18 12:06:08 +00:00

commands/create: Add special case for EnergyInstruemntBackends

Previously when using the create command for adding
EnergyInstruemntBackends they were treated like any other plugin and
generated incorrect configuration. Now automatically add the
`energy_measurement` instrument and populate it's configuration with the
relevant defaults for the specified Backend.
This commit is contained in:
Marc Bonnici 2018-08-02 10:37:42 +01:00
parent 1eaffb6744
commit 42b3f4cf9f

View File

@ -27,6 +27,7 @@ from devlib.utils.types import identifier
from wa import ComplexCommand, SubCommand, pluginloader, settings
from wa.framework.target.descriptor import list_target_descriptions
from wa.framework.exception import ConfigError, CommandError
from wa.instruments.energy_measurement import EnergyInstrumentBackend
from wa.utils.misc import (ensure_directory_exists as _d, capitalize,
ensure_file_directory_exists as _f)
from wa.utils.serializer import yaml
@ -51,6 +52,7 @@ class CreateAgendaSubcommand(SubCommand):
self.parser.add_argument('-o', '--output', metavar='FILE',
help='Output file. If not specfied, STDOUT will be used instead.')
# pylint: disable=too-many-branches
def execute(self, state, args):
agenda = OrderedDict()
agenda['config'] = OrderedDict(augmentations=[], iterations=args.iterations)
@ -71,7 +73,15 @@ class CreateAgendaSubcommand(SubCommand):
extcls = pluginloader.get_plugin_class(name)
config = pluginloader.get_default_config(name)
if extcls.kind == 'workload':
# Handle special case for EnergyInstrumentBackends
if issubclass(extcls, EnergyInstrumentBackend):
if 'energy_measurement' not in agenda['config']['augmentations']:
energy_config = pluginloader.get_default_config('energy_measurement')
agenda['config']['augmentations'].append('energy_measurement')
agenda['config']['energy_measurement'] = energy_config
agenda['config']['energy_measurement']['instrument'] = name
agenda['config']['energy_measurement']['instrument_parameters'] = config
elif extcls.kind == 'workload':
entry = OrderedDict()
entry['name'] = extcls.name
if name != extcls.name: