1
0
mirror of https://github.com/ARM-software/workload-automation.git synced 2025-02-20 20:09:11 +00:00

Merge pull request #503 from setrofim/energy-backend-param-fix

energy instrument backends parameter validation fix
This commit is contained in:
setrofim 2017-10-06 13:56:46 +01:00 committed by GitHub
commit 1fe3ed9f96
3 changed files with 21 additions and 8 deletions

View File

@ -118,6 +118,10 @@ class LoggingConfig(dict):
'color': True,
}
@staticmethod
def from_pod(pod):
return LoggingConfig(pod)
def __init__(self, config=None):
dict.__init__(self)
if isinstance(config, dict):
@ -136,6 +140,9 @@ class LoggingConfig(dict):
else:
raise ValueError(config)
def to_pod(self):
return self
def get_type_name(kind):
typename = str(kind)
@ -254,7 +261,7 @@ class ConfigurationPoint(object):
def set_value(self, obj, value=None, check_mandatory=True):
if value is None:
if self.default is not None:
value = self.default
value = self.kind(self.default)
elif check_mandatory and self.mandatory:
msg = 'No values specified for mandatory parameter "{}" in {}'
raise ConfigError(msg.format(self.name, obj.name))

View File

@ -29,7 +29,7 @@ from wa import Instrument, Parameter
from wa.framework import pluginloader
from wa.framework.plugin import Plugin
from wa.framework.exception import ConfigError
from wa.utils.types import list_of_strings, list_of_ints, list_or_string
from wa.utils.types import list_of_strings, list_of_ints, list_or_string, obj_dict
class EnergyInstrumentBackend(Plugin):
@ -214,18 +214,16 @@ class EnergyMeasurement(Instrument):
self.measurement_csv = None
self.loader = loader
self.backend = self.loader.get_plugin(self.instrument)
self.params = {}
self.params = obj_dict()
if self.backend.instrument.mode != CONTINUOUS:
msg = '{} instrument does not support continuous measurement collection'
raise ConfigError(msg.format(self.instrument))
supported_params = self.backend.get_parameters()
for name, value in supported_params.iteritems():
if name in self.instrument_parameters:
self.params[name] = self.instrument_parameters[name]
elif value.default:
self.params[name] = value.default
for name, param in supported_params.iteritems():
value = self.instrument_parameters.get(name)
param.set_value(self.params, value)
self.backend.validate_parameters(self.params)
def initialize(self, context):

View File

@ -107,6 +107,12 @@ def list_of(type_):
def extend(self, other):
list.extend(self, map(type_, other))
def from_pod(cls, pod):
return cls(map(type_, pod))
def _to_pod(self):
return self
def __setitem__(self, idx, value):
list.__setitem__(self, idx, type_(value))
@ -116,6 +122,8 @@ def list_of(type_):
"__setitem__": __setitem__,
"append": append,
"extend": extend,
"to_pod": _to_pod,
"from_pod": classmethod(from_pod),
})