mirror of
https://github.com/ARM-software/workload-automation.git
synced 2025-02-07 13:41:24 +00:00
Configuration: Added global_aliase
Previously `aliases` was conflated with global_aliases. This commit fixes this. `global_alias`'s are a name that can be used in top level configuration and set the values of one or more plugin parameters that use the same global_alias. `aliases` is a list of alternative names for a configuration point. Currently this is only used for instrumentation/instruments and workload_name/name but in the future it will likely be used when parameters have to be renamed to be more meaningful but still maintain backward compatibility.
This commit is contained in:
parent
9e6badbdf4
commit
e95ba608ec
@ -168,7 +168,8 @@ class ConfigurationPoint(object):
|
|||||||
description=None,
|
description=None,
|
||||||
constraint=None,
|
constraint=None,
|
||||||
merge=False,
|
merge=False,
|
||||||
aliases=None):
|
aliases=None,
|
||||||
|
global_alias=None):
|
||||||
"""
|
"""
|
||||||
Create a new Parameter object.
|
Create a new Parameter object.
|
||||||
|
|
||||||
@ -216,6 +217,9 @@ class ConfigurationPoint(object):
|
|||||||
``merge_config_values`` documentation for details.
|
``merge_config_values`` documentation for details.
|
||||||
:param aliases: Alternative names for the same configuration point.
|
:param aliases: Alternative names for the same configuration point.
|
||||||
These are largely for backwards compatibility.
|
These are largely for backwards compatibility.
|
||||||
|
:param global_alias: An alias for this parameter that can be specified at
|
||||||
|
the global level. A global_alias can map onto many
|
||||||
|
ConfigurationPoints.
|
||||||
"""
|
"""
|
||||||
self.name = identifier(name)
|
self.name = identifier(name)
|
||||||
if kind in KIND_MAP:
|
if kind in KIND_MAP:
|
||||||
@ -235,6 +239,7 @@ class ConfigurationPoint(object):
|
|||||||
self.constraint = constraint
|
self.constraint = constraint
|
||||||
self.merge = merge
|
self.merge = merge
|
||||||
self.aliases = aliases or []
|
self.aliases = aliases or []
|
||||||
|
self.global_alias = global_alias
|
||||||
|
|
||||||
if self.default is not None:
|
if self.default is not None:
|
||||||
try:
|
try:
|
||||||
@ -243,9 +248,9 @@ class ConfigurationPoint(object):
|
|||||||
raise ValueError('Default value "{}" is not valid'.format(self.default))
|
raise ValueError('Default value "{}" is not valid'.format(self.default))
|
||||||
|
|
||||||
def match(self, name):
|
def match(self, name):
|
||||||
if name == self.name:
|
if name == self.name or name in self.aliases:
|
||||||
return True
|
return True
|
||||||
elif name in self.aliases:
|
elif name == self.global_alias:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -44,9 +44,9 @@ class PluginCache(object):
|
|||||||
self._list_of_global_aliases = set()
|
self._list_of_global_aliases = set()
|
||||||
for plugin in self.loader.list_plugins():
|
for plugin in self.loader.list_plugins():
|
||||||
for param in plugin.parameters:
|
for param in plugin.parameters:
|
||||||
if param.aliases:
|
if param.global_alias:
|
||||||
self._global_alias_map[plugin.name][param.aliases] = param
|
self._global_alias_map[plugin.name][param.global_alias] = param
|
||||||
self._list_of_global_aliases.add(param.aliases)
|
self._list_of_global_aliases.add(param.global_alias)
|
||||||
|
|
||||||
def add_source(self, source):
|
def add_source(self, source):
|
||||||
if source in self.sources:
|
if source in self.sources:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user