1
0
mirror of https://github.com/ARM-software/workload-automation.git synced 2024-10-05 18:31:12 +01:00

fw/ConfigutationPoints: Add support for deprecated parameters

Allow specifying a ConfigutationPoint is deprecated. This means that any
supplied configuration will not be used however execution will continue
with a warning displayed to the user.
This commit is contained in:
Marc Bonnici 2020-02-10 11:47:33 +00:00
parent 5f00a94121
commit d0f099700a
3 changed files with 24 additions and 6 deletions

View File

@ -13,6 +13,7 @@
# limitations under the License.
import os
import logging
from copy import copy, deepcopy
from collections import OrderedDict, defaultdict
@ -36,6 +37,8 @@ Status = enum(['UNKNOWN', 'NEW', 'PENDING',
'STARTED', 'CONNECTED', 'INITIALIZED', 'RUNNING',
'OK', 'PARTIAL', 'FAILED', 'ABORTED', 'SKIPPED'])
logger = logging.getLogger('config')
##########################
### CONFIG POINT TYPES ###
@ -192,7 +195,8 @@ class ConfigurationPoint(object):
constraint=None,
merge=False,
aliases=None,
global_alias=None):
global_alias=None,
deprecated=False):
"""
Create a new Parameter object.
@ -243,6 +247,9 @@ class ConfigurationPoint(object):
:param global_alias: An alias for this parameter that can be specified at
the global level. A global_alias can map onto many
ConfigurationPoints.
:param deprecated: Specify that this parameter is deprecated and its
config should be ignored. If supplied WA will display
a warning to the user however will continue execution.
"""
self.name = identifier(name)
if kind in KIND_MAP:
@ -266,6 +273,7 @@ class ConfigurationPoint(object):
self.merge = merge
self.aliases = aliases or []
self.global_alias = global_alias
self.deprecated = deprecated
if self.default is not None:
try:
@ -281,6 +289,8 @@ class ConfigurationPoint(object):
return False
def set_value(self, obj, value=None, check_mandatory=True):
if self.deprecated:
return
if value is None:
if self.default is not None:
value = self.kind(self.default)
@ -303,6 +313,10 @@ class ConfigurationPoint(object):
def validate(self, obj, check_mandatory=True):
value = getattr(obj, self.name, None)
if self.deprecated:
msg = 'Depreciated parameter supplied for "{}" in "{}". Config will be ignored.'
logger.warning(msg.format(self.name, obj.name))
return
if value is not None:
self.validate_value(obj.name, value)
else:

View File

@ -246,7 +246,7 @@ class Plugin(with_metaclass(PluginMeta, object)):
@classmethod
def get_default_config(cls):
return {p.name: p.default for p in cls.parameters}
return {p.name: p.default for p in cls.parameters if not p.deprecated}
@property
def dependencies_directory(self):

View File

@ -69,11 +69,14 @@ def instantiate_target(tdesc, params, connect=None, extra_platform_params=None):
for name, value in params.items():
if name in target_params:
tp[name] = value
if not target_params[name].deprecated:
tp[name] = value
elif name in platform_params:
pp[name] = value
if not platform_params[name].deprecated:
pp[name] = value
elif name in conn_params:
cp[name] = value
if not conn_params[name].deprecated:
cp[name] = value
elif name in assistant_params:
pass
else:
@ -129,7 +132,8 @@ class TargetDescription(object):
config = {}
for pattr in param_attrs:
for p in getattr(self, pattr):
config[p.name] = p.default
if not p.deprecated:
config[p.name] = p.default
return config
def _set(self, attr, vals):