mirror of
https://github.com/ARM-software/workload-automation.git
synced 2025-09-02 11:22:41 +01:00
Add support for Python 3
Add support for running under Python 3, while maintaining compatibility with Python 2. See http://python-future.org/compatible_idioms.html for more details behind these changes.
This commit is contained in:
committed by
Marc Bonnici
parent
c3ddb31d4d
commit
b3de85455a
@@ -14,9 +14,10 @@
|
||||
#
|
||||
|
||||
import os
|
||||
import csv
|
||||
from collections import OrderedDict
|
||||
|
||||
from devlib.utils.csvutil import csvwriter
|
||||
|
||||
from wa import OutputProcessor, Parameter
|
||||
from wa.utils.types import list_of_strings
|
||||
from wa.utils.cpustates import report_power_stats
|
||||
@@ -29,14 +30,14 @@ def _get_cpustates_description():
|
||||
"""
|
||||
output_lines = []
|
||||
lines = iter(report_power_stats.__doc__.split('\n'))
|
||||
line = lines.next()
|
||||
line = next(lines)
|
||||
while True:
|
||||
try:
|
||||
if line.strip().startswith(':param'):
|
||||
while line.strip():
|
||||
line = lines.next()
|
||||
line = next(lines)
|
||||
output_lines.append(line)
|
||||
line = lines.next()
|
||||
line = next(lines)
|
||||
except StopIteration:
|
||||
break
|
||||
return '\n'.join(output_lines)
|
||||
@@ -105,7 +106,7 @@ class CpuStatesProcessor(OutputProcessor):
|
||||
split_wfi_states=self.split_wfi_states,
|
||||
)
|
||||
|
||||
for report in reports.itervalues():
|
||||
for report in reports.values():
|
||||
output.add_artifact(report.name, report.filepath, kind='data')
|
||||
|
||||
iteration_id = (output.id, output.label, output.iteration)
|
||||
@@ -118,7 +119,7 @@ class CpuStatesProcessor(OutputProcessor):
|
||||
|
||||
parallel_rows = []
|
||||
powerstate_rows = []
|
||||
for iteration_id, reports in self.iteration_reports.iteritems():
|
||||
for iteration_id, reports in self.iteration_reports.items():
|
||||
job_id, workload, iteration = iteration_id
|
||||
parallel_report = reports['parallel-stats']
|
||||
powerstate_report = reports['power-state-stats']
|
||||
@@ -132,8 +133,7 @@ class CpuStatesProcessor(OutputProcessor):
|
||||
for s in stats])
|
||||
|
||||
outpath = output.get_path('parallel-stats.csv')
|
||||
with open(outpath, 'w') as wfh:
|
||||
writer = csv.writer(wfh)
|
||||
with csvwriter(outpath) as writer:
|
||||
writer.writerow(['id', 'workload', 'iteration', 'cluster',
|
||||
'number_of_cores', 'total_time',
|
||||
'%time', '%running_time'])
|
||||
@@ -141,8 +141,7 @@ class CpuStatesProcessor(OutputProcessor):
|
||||
output.add_artifact('run-parallel-stats', outpath, kind='export')
|
||||
|
||||
outpath = output.get_path('power-state-stats.csv')
|
||||
with open(outpath, 'w') as wfh:
|
||||
writer = csv.writer(wfh)
|
||||
with csvwriter(outpath) as writer:
|
||||
headers = ['id', 'workload', 'iteration', 'state']
|
||||
headers += ['{} CPU{}'.format(c, i)
|
||||
for i, c in enumerate(powerstate_report.core_names)]
|
||||
|
@@ -1,4 +1,6 @@
|
||||
import csv
|
||||
import sys
|
||||
|
||||
from devlib.utils.csvutil import csvwriter
|
||||
|
||||
from wa import OutputProcessor, Parameter
|
||||
from wa.framework.exception import ConfigError
|
||||
@@ -64,7 +66,7 @@ class CsvReportProcessor(OutputProcessor):
|
||||
classifiers = set([])
|
||||
for out in outputs:
|
||||
for metric in out.metrics:
|
||||
classifiers.update(metric.classifiers.keys())
|
||||
classifiers.update(list(metric.classifiers.keys()))
|
||||
extra_columns = list(classifiers)
|
||||
elif self.extra_columns:
|
||||
extra_columns = self.extra_columns
|
||||
@@ -72,8 +74,7 @@ class CsvReportProcessor(OutputProcessor):
|
||||
extra_columns = []
|
||||
|
||||
outfile = output.get_path('results.csv')
|
||||
with open(outfile, 'wb') as wfh:
|
||||
writer = csv.writer(wfh)
|
||||
with csvwriter(outfile) as writer:
|
||||
writer.writerow(['id', 'workload', 'iteration', 'metric', ] +
|
||||
extra_columns + ['value', 'units'])
|
||||
|
||||
|
@@ -49,8 +49,8 @@ class StatusTxtReporter(OutputProcessor):
|
||||
txt = '{}/{} iterations completed without error\n'
|
||||
wfh.write(txt.format(counter[Status.OK], len(output.jobs)))
|
||||
wfh.write('\n')
|
||||
status_lines = [map(str, [o.id, o.label, o.iteration, o.status,
|
||||
o.event_summary])
|
||||
status_lines = [list(map(str, [o.id, o.label, o.iteration, o.status,
|
||||
o.event_summary]))
|
||||
for o in output.jobs]
|
||||
write_table(status_lines, wfh, align='<<>><')
|
||||
|
||||
|
Reference in New Issue
Block a user