aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBob Haarman <inglorion@chromium.org>2020-09-19 00:00:06 +0000
committerBob Haarman <inglorion@chromium.org>2020-09-25 21:42:42 +0000
commit8223d16e040748ad6a91a87f3ce1cfc13db37f4b (patch)
treeb58dc769d183b3af7c76e6a6cec2800343d4e4f9
parent4f7eb71f9fa78f8710e1deb57d441f51fa74af3b (diff)
downloadtoolchain-utils-8223d16e040748ad6a91a87f3ce1cfc13db37f4b.tar.gz
fix formatting/lint issues pointed out by repohooks
Previous changes resulted in some complaints about formatting and Python 3 compatibility from the repo hooks. This change fixes those. BUG=None TEST=repo upload --cbr . # check that it no longer complains Change-Id: I99cc51dcb8d499d59b7b47817f4cef8fa6ba5059 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/2419831 Tested-by: Bob Haarman <inglorion@chromium.org> Reviewed-by: Manoj Gupta (OoO) <manojgupta@chromium.org>
-rwxr-xr-xandroid_bench_suite/fix_skia_results.py20
-rwxr-xr-xauto_delete_nightly_test_data.py14
-rw-r--r--crosperf/experiment_runner.py34
-rw-r--r--crosperf/results_report.py9
4 files changed, 40 insertions, 37 deletions
diff --git a/android_bench_suite/fix_skia_results.py b/android_bench_suite/fix_skia_results.py
index bdab80a9..84dee5a5 100755
--- a/android_bench_suite/fix_skia_results.py
+++ b/android_bench_suite/fix_skia_results.py
@@ -5,6 +5,7 @@
# found in the LICENSE file.
#
# pylint: disable=cros-logging-import
+
"""Transforms skia benchmark results to ones that crosperf can understand."""
from __future__ import print_function
@@ -57,7 +58,9 @@ def _GetTimeMultiplier(label_name):
def _GetTimeDenom(ms):
- """Given a list of times (in milliseconds), find a time unit in which
+ """Express times in a common time unit.
+
+ Given a list of times (in milliseconds), find a time unit in which
they can all be expressed.
Returns the unit name, and `ms` normalized to that time unit.
@@ -95,9 +98,9 @@ def _TransformBenchmarks(raw_benchmarks):
# statistic...
benchmarks = raw_benchmarks['results']
results = []
- for bench_name, bench_result in benchmarks.iteritems():
+ for bench_name, bench_result in benchmarks.items():
try:
- for cfg_name, keyvals in bench_result.iteritems():
+ for cfg_name, keyvals in bench_result.items():
# Some benchmarks won't have timing data (either it won't exist at all,
# or it'll be empty); skip them.
samples = keyvals.get('samples')
@@ -110,17 +113,16 @@ def _TransformBenchmarks(raw_benchmarks):
friendly_name = _GetFamiliarName(bench_name)
if len(results) < len(samples):
- results.extend({
- 'retval': 0
- } for _ in range(len(samples) - len(results)))
+ results.extend(
+ {'retval': 0} for _ in range(len(samples) - len(results)))
time_mul = _GetTimeMultiplier(friendly_name)
- for sample, app in itertools.izip(samples, results):
+ for sample, app in itertools.zip(samples, results):
assert friendly_name not in app
app[friendly_name] = sample * time_mul
except (KeyError, ValueError) as e:
- logging.error('While converting "%s" (key: %s): %s',
- bench_result, bench_name, e.message)
+ logging.error('While converting "%s" (key: %s): %s', bench_result,
+ bench_name, e)
raise
# Realistically, [results] should be multiple results, where each entry in the
diff --git a/auto_delete_nightly_test_data.py b/auto_delete_nightly_test_data.py
index 884afce2..c3c2e24c 100755
--- a/auto_delete_nightly_test_data.py
+++ b/auto_delete_nightly_test_data.py
@@ -52,8 +52,8 @@ def CleanNumberedDir(s, dry_run=False):
## Now delete the numbered dir Before forcibly removing the directory, just
## check 's' to make sure it matches the expected pattern. A valid dir to be
## removed must be '/usr/local/google/crostc/(SUN|MON|TUE...|SAT)'.
- valid_dir_pattern = (
- '^' + NIGHTLY_TESTS_WORKSPACE + '/(' + '|'.join(DIR_BY_WEEKDAY) + ')')
+ valid_dir_pattern = ('^' + NIGHTLY_TESTS_WORKSPACE + '/(' +
+ '|'.join(DIR_BY_WEEKDAY) + ')')
if not re.search(valid_dir_pattern, s):
print('Trying to delete an invalid dir "{0}" (must match "{1}"), '
'please check.'.format(s, valid_dir_pattern))
@@ -193,8 +193,8 @@ def CleanOldCLs(days_to_preserve='1', dry_run=False):
ce = command_executer.GetCommandExecuter()
chromeos_root = os.path.join(constants.CROSTC_WORKSPACE, 'chromeos')
# Find Old CLs.
- old_cls_cmd = (
- 'gerrit --raw search "owner:me status:open age:%sd"' % days_to_preserve)
+ old_cls_cmd = ('gerrit --raw search "owner:me status:open age:%sd"' %
+ days_to_preserve)
_, cls, _ = ce.ChrootRunCommandWOutput(
chromeos_root, old_cls_cmd, print_to_console=False)
# Convert any whitespaces to spaces.
@@ -210,20 +210,20 @@ def CleanOldCLs(days_to_preserve='1', dry_run=False):
return ce.ChrootRunCommand(
chromeos_root, abandon_cls_cmd, print_to_console=False)
+
def CleanChromeTelemetryTmpFiles(dry_run):
rv = 0
ce = command_executer.GetCommandExecuter()
tmp_dir = os.path.join(constants.CROSTC_WORKSPACE, 'chromeos', '.cache',
'distfiles', 'target', 'chrome-src-internal', 'src',
- 'tmp');
+ 'tmp')
cmd = f'rm -fr {shlex.quote(tmp_dir)}/tmp*telemetry_Crosperf'
if dry_run:
print(f'Going to execute:\n{cmd}')
else:
rv = ce.RunCommand(cmd, print_to_console=False)
if rv == 0:
- print(f'Successfully cleaned chrome tree tmp directory '
- f'{tmp_dir!r} .')
+ print(f'Successfully cleaned chrome tree tmp directory ' f'{tmp_dir!r} .')
else:
print(f'Some directories were not removed under chrome tree '
f'tmp directory {tmp_dir!r}.')
diff --git a/crosperf/experiment_runner.py b/crosperf/experiment_runner.py
index 6a46adfc..8ba85a4c 100644
--- a/crosperf/experiment_runner.py
+++ b/crosperf/experiment_runner.py
@@ -35,8 +35,8 @@ def _WriteJSONReportToFile(experiment, results_dir, json_report):
compiler_string = 'llvm' if has_llvm else 'gcc'
board = experiment.labels[0].board
filename = 'report_%s_%s_%s.%s.json' % (board, json_report.date,
- json_report.time.replace(':', '.'),
- compiler_string)
+ json_report.time.replace(
+ ':', '.'), compiler_string)
fullname = os.path.join(results_dir, filename)
report_text = json_report.GetReport()
with open(fullname, 'w') as out_file:
@@ -157,13 +157,13 @@ class ExperimentRunner(object):
def _ClearCacheEntries(self, experiment):
for br in experiment.benchmark_runs:
cache = ResultsCache()
- cache.Init(
- br.label.chromeos_image, br.label.chromeos_root,
- br.benchmark.test_name, br.iteration, br.test_args, br.profiler_args,
- br.machine_manager, br.machine, br.label.board, br.cache_conditions,
- br.logger(), br.log_level, br.label, br.share_cache,
- br.benchmark.suite, br.benchmark.show_all_results,
- br.benchmark.run_local, br.benchmark.cwp_dso)
+ cache.Init(br.label.chromeos_image, br.label.chromeos_root,
+ br.benchmark.test_name, br.iteration, br.test_args,
+ br.profiler_args, br.machine_manager, br.machine,
+ br.label.board, br.cache_conditions, br.logger(), br.log_level,
+ br.label, br.share_cache, br.benchmark.suite,
+ br.benchmark.show_all_results, br.benchmark.run_local,
+ br.benchmark.cwp_dso)
cache_dir = cache.GetCacheDirForWrite()
if os.path.exists(cache_dir):
self.l.LogOutput('Removing cache dir: %s' % cache_dir)
@@ -246,8 +246,8 @@ class ExperimentRunner(object):
subject = '%s: %s' % (experiment.name, ' vs. '.join(label_names))
text_report = TextResultsReport.FromExperiment(experiment, True).GetReport()
- text_report += (
- '\nResults are stored in %s.\n' % experiment.results_directory)
+ text_report += ('\nResults are stored in %s.\n' %
+ experiment.results_directory)
text_report = "<pre style='font-size: 13px'>%s</pre>" % text_report
html_report = HTMLResultsReport.FromExperiment(experiment).GetReport()
attachment = EmailSender.Attachment('report.html', html_report)
@@ -275,8 +275,8 @@ class ExperimentRunner(object):
all_failed = True
topstats_file = os.path.join(results_directory, 'topstats.log')
- self.l.LogOutput(
- 'Storing top statistics of each benchmark run into %s.' % topstats_file)
+ self.l.LogOutput('Storing top statistics of each benchmark run into %s.' %
+ topstats_file)
with open(topstats_file, 'w') as top_fd:
for benchmark_run in experiment.benchmark_runs:
if benchmark_run.result:
@@ -322,8 +322,8 @@ class ExperimentRunner(object):
self.l.LogOutput('Storing email message body in %s.' % results_directory)
msg_file_path = os.path.join(results_directory, 'msg_body.html')
text_report = TextResultsReport.FromExperiment(experiment, True).GetReport()
- text_report += (
- '\nResults are stored in %s.\n' % experiment.results_directory)
+ text_report += ('\nResults are stored in %s.\n' %
+ experiment.results_directory)
msg_body = "<pre style='font-size: 13px'>%s</pre>" % text_report
FileUtils().WriteFile(msg_file_path, msg_body)
@@ -348,8 +348,8 @@ class MockExperimentRunner(ExperimentRunner):
super(MockExperimentRunner, self).__init__(experiment, json_report)
def _Run(self, experiment):
- self.l.LogOutput(
- "Would run the following experiment: '%s'." % experiment.name)
+ self.l.LogOutput("Would run the following experiment: '%s'." %
+ experiment.name)
def _PrintTable(self, experiment):
self.l.LogOutput('Would print the experiment table.')
diff --git a/crosperf/results_report.py b/crosperf/results_report.py
index ff8c119d..dc80b53b 100644
--- a/crosperf/results_report.py
+++ b/crosperf/results_report.py
@@ -418,8 +418,8 @@ class TextResultsReport(ResultsReport):
cpu_info = experiment.machine_manager.GetAllCPUInfo(experiment.labels)
sections.append(self._MakeSection('CPUInfo', cpu_info))
- totaltime = (
- time.time() - experiment.start_time) if experiment.start_time else 0
+ totaltime = (time.time() -
+ experiment.start_time) if experiment.start_time else 0
totaltime_str = 'Total experiment time:\n%d min' % (totaltime // 60)
cooldown_waittime_list = ['Cooldown wait time:']
# When running experiment on multiple DUTs cooldown wait time may vary
@@ -430,8 +430,9 @@ class TextResultsReport(ResultsReport):
cooldown_waittime_list.append('DUT %s: %d min' % (dut, waittime // 60))
cooldown_waittime_str = '\n'.join(cooldown_waittime_list)
sections.append(
- self._MakeSection('Duration', '\n\n'.join(
- [totaltime_str, cooldown_waittime_str])))
+ self._MakeSection('Duration',
+ '\n\n'.join([totaltime_str,
+ cooldown_waittime_str])))
return '\n'.join(sections)