mirror of
https://github.com/ARM-software/workload-automation.git
synced 2025-02-27 15:29:00 +00: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:
parent
5f00a94121
commit
d0f099700a
wa/framework
@ -13,6 +13,7 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import logging
|
||||||
from copy import copy, deepcopy
|
from copy import copy, deepcopy
|
||||||
from collections import OrderedDict, defaultdict
|
from collections import OrderedDict, defaultdict
|
||||||
|
|
||||||
@ -36,6 +37,8 @@ Status = enum(['UNKNOWN', 'NEW', 'PENDING',
|
|||||||
'STARTED', 'CONNECTED', 'INITIALIZED', 'RUNNING',
|
'STARTED', 'CONNECTED', 'INITIALIZED', 'RUNNING',
|
||||||
'OK', 'PARTIAL', 'FAILED', 'ABORTED', 'SKIPPED'])
|
'OK', 'PARTIAL', 'FAILED', 'ABORTED', 'SKIPPED'])
|
||||||
|
|
||||||
|
logger = logging.getLogger('config')
|
||||||
|
|
||||||
|
|
||||||
##########################
|
##########################
|
||||||
### CONFIG POINT TYPES ###
|
### CONFIG POINT TYPES ###
|
||||||
@ -192,7 +195,8 @@ class ConfigurationPoint(object):
|
|||||||
constraint=None,
|
constraint=None,
|
||||||
merge=False,
|
merge=False,
|
||||||
aliases=None,
|
aliases=None,
|
||||||
global_alias=None):
|
global_alias=None,
|
||||||
|
deprecated=False):
|
||||||
"""
|
"""
|
||||||
Create a new Parameter object.
|
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
|
:param global_alias: An alias for this parameter that can be specified at
|
||||||
the global level. A global_alias can map onto many
|
the global level. A global_alias can map onto many
|
||||||
ConfigurationPoints.
|
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)
|
self.name = identifier(name)
|
||||||
if kind in KIND_MAP:
|
if kind in KIND_MAP:
|
||||||
@ -266,6 +273,7 @@ class ConfigurationPoint(object):
|
|||||||
self.merge = merge
|
self.merge = merge
|
||||||
self.aliases = aliases or []
|
self.aliases = aliases or []
|
||||||
self.global_alias = global_alias
|
self.global_alias = global_alias
|
||||||
|
self.deprecated = deprecated
|
||||||
|
|
||||||
if self.default is not None:
|
if self.default is not None:
|
||||||
try:
|
try:
|
||||||
@ -281,6 +289,8 @@ class ConfigurationPoint(object):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
def set_value(self, obj, value=None, check_mandatory=True):
|
def set_value(self, obj, value=None, check_mandatory=True):
|
||||||
|
if self.deprecated:
|
||||||
|
return
|
||||||
if value is None:
|
if value is None:
|
||||||
if self.default is not None:
|
if self.default is not None:
|
||||||
value = self.kind(self.default)
|
value = self.kind(self.default)
|
||||||
@ -303,6 +313,10 @@ class ConfigurationPoint(object):
|
|||||||
|
|
||||||
def validate(self, obj, check_mandatory=True):
|
def validate(self, obj, check_mandatory=True):
|
||||||
value = getattr(obj, self.name, None)
|
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:
|
if value is not None:
|
||||||
self.validate_value(obj.name, value)
|
self.validate_value(obj.name, value)
|
||||||
else:
|
else:
|
||||||
|
@ -246,7 +246,7 @@ class Plugin(with_metaclass(PluginMeta, object)):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_default_config(cls):
|
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
|
@property
|
||||||
def dependencies_directory(self):
|
def dependencies_directory(self):
|
||||||
|
@ -69,11 +69,14 @@ def instantiate_target(tdesc, params, connect=None, extra_platform_params=None):
|
|||||||
|
|
||||||
for name, value in params.items():
|
for name, value in params.items():
|
||||||
if name in target_params:
|
if name in target_params:
|
||||||
tp[name] = value
|
if not target_params[name].deprecated:
|
||||||
|
tp[name] = value
|
||||||
elif name in platform_params:
|
elif name in platform_params:
|
||||||
pp[name] = value
|
if not platform_params[name].deprecated:
|
||||||
|
pp[name] = value
|
||||||
elif name in conn_params:
|
elif name in conn_params:
|
||||||
cp[name] = value
|
if not conn_params[name].deprecated:
|
||||||
|
cp[name] = value
|
||||||
elif name in assistant_params:
|
elif name in assistant_params:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
@ -129,7 +132,8 @@ class TargetDescription(object):
|
|||||||
config = {}
|
config = {}
|
||||||
for pattr in param_attrs:
|
for pattr in param_attrs:
|
||||||
for p in getattr(self, pattr):
|
for p in getattr(self, pattr):
|
||||||
config[p.name] = p.default
|
if not p.deprecated:
|
||||||
|
config[p.name] = p.default
|
||||||
return config
|
return config
|
||||||
|
|
||||||
def _set(self, attr, vals):
|
def _set(self, attr, vals):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user