mirror of
https://github.com/ARM-software/workload-automation.git
synced 2025-01-19 04:21:17 +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:
parent
1eaffb6744
commit
42b3f4cf9f
@ -27,6 +27,7 @@ from devlib.utils.types import identifier
|
|||||||
from wa import ComplexCommand, SubCommand, pluginloader, settings
|
from wa import ComplexCommand, SubCommand, pluginloader, settings
|
||||||
from wa.framework.target.descriptor import list_target_descriptions
|
from wa.framework.target.descriptor import list_target_descriptions
|
||||||
from wa.framework.exception import ConfigError, CommandError
|
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,
|
from wa.utils.misc import (ensure_directory_exists as _d, capitalize,
|
||||||
ensure_file_directory_exists as _f)
|
ensure_file_directory_exists as _f)
|
||||||
from wa.utils.serializer import yaml
|
from wa.utils.serializer import yaml
|
||||||
@ -51,6 +52,7 @@ class CreateAgendaSubcommand(SubCommand):
|
|||||||
self.parser.add_argument('-o', '--output', metavar='FILE',
|
self.parser.add_argument('-o', '--output', metavar='FILE',
|
||||||
help='Output file. If not specfied, STDOUT will be used instead.')
|
help='Output file. If not specfied, STDOUT will be used instead.')
|
||||||
|
|
||||||
|
# pylint: disable=too-many-branches
|
||||||
def execute(self, state, args):
|
def execute(self, state, args):
|
||||||
agenda = OrderedDict()
|
agenda = OrderedDict()
|
||||||
agenda['config'] = OrderedDict(augmentations=[], iterations=args.iterations)
|
agenda['config'] = OrderedDict(augmentations=[], iterations=args.iterations)
|
||||||
@ -71,7 +73,15 @@ class CreateAgendaSubcommand(SubCommand):
|
|||||||
extcls = pluginloader.get_plugin_class(name)
|
extcls = pluginloader.get_plugin_class(name)
|
||||||
config = pluginloader.get_default_config(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 = OrderedDict()
|
||||||
entry['name'] = extcls.name
|
entry['name'] = extcls.name
|
||||||
if name != extcls.name:
|
if name != extcls.name:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user