1
0
mirror of https://github.com/ARM-software/workload-automation.git synced 2025-03-22 02:29:10 +00:00

energy_measurement: Check for failure of Instrument::get_data

Devlib's get_data API can return None when something goes wrong -
this currently results in us attempting to add a non-existent
artifact.

To avoid this confusion, check and use the return value from
get_data, instead of assuming that it will write data to its
'outfile' parameter.
This commit is contained in:
Brendan Jackman 2017-10-09 16:17:02 +01:00
parent 12edabf753
commit b4a608da95

View File

@ -29,7 +29,7 @@ from devlib.utils.misc import which
from wa import Instrument, Parameter from wa import Instrument, Parameter
from wa.framework import pluginloader from wa.framework import pluginloader
from wa.framework.plugin import Plugin from wa.framework.plugin import Plugin
from wa.framework.exception import ConfigError from wa.framework.exception import ConfigError, InstrumentError
from wa.utils.types import list_of_strings, list_of_ints, list_or_string, obj_dict from wa.utils.types import list_of_strings, list_of_ints, list_or_string, obj_dict
@ -296,8 +296,13 @@ class EnergyMeasurement(Instrument):
name = 'energy_instrument_output' name = 'energy_instrument_output'
outfile = os.path.join(context.output_directory, '{}.csv'.format(name)) outfile = os.path.join(context.output_directory, '{}.csv'.format(name))
self.measurement_csvs[device] = instrument.get_data(outfile) measurements = instrument.get_data(outfile)
context.add_artifact(name, outfile, 'data', if not measurements:
raise InstrumentError("Failed to collect energy data from {}"
.format(self.backend.name))
self.measurement_csvs[device] = measurements
context.add_artifact(name, measurements.path, 'data',
classifiers={'device': device}) classifiers={'device': device})
self.extract_metrics(context) self.extract_metrics(context)