Commit c769911c authored by Caleb Rouleau's avatar Caleb Rouleau Committed by Commit Bot

[Benchmarking] Fix error condition.

https://logs.chromium.org/logs/chrome/buildbucket/cr-buildbucket.appspot.com/8893636477245975664/+/steps/dawn_perf_tests_on_ATI_GPU_on_Mac_on_Mac-10.13.3/0/logs/Merge_script_log/0

Traceback (most recent call last):
  File /b/s/w/ir/cache/builder/src/tools/perf/process_perf_results.py, line 361, in process_perf_results
    configuration_name, build_properties, extra_links, output_results_dir)
  File /b/s/w/ir/cache/builder/src/tools/perf/process_perf_results.py, line 548, in _handle_perf_results
    is_reference, upload_failure=not upload_succeed)
  File /b/s/w/ir/cache/builder/src/tools/perf/process_perf_results.py, line 580, in _write_perf_data_to_logfile
    json.dump(results, output_json_file,
UnboundLocalError: local variable 'results' referenced before assignment

Bug: 1035590
Change-Id: I6d0fd9373f94d6484ce42cf867a50e302ef428d2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1976294
Auto-Submit: Caleb Rouleau <crouleau@chromium.org>
Reviewed-by: default avatarJohn Chen <johnchen@chromium.org>
Commit-Queue: John Chen <johnchen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#726502}
parent 78124b49
......@@ -573,21 +573,23 @@ def _write_perf_data_to_logfile(benchmark_name, output_file,
viewer_url = None
# logdog file to write perf results to
if os.path.exists(output_file):
results = None
with open(output_file) as f:
try:
results = json.load(f)
except ValueError:
print('Error parsing perf results JSON for benchmark %s' %
benchmark_name)
try:
output_json_file = logdog_helper.open_text(benchmark_name)
json.dump(results, output_json_file,
indent=4, separators=(',', ': '))
except ValueError as e:
print('ValueError: "%s" while dumping output to logdog' % e)
finally:
output_json_file.close()
viewer_url = output_json_file.get_viewer_url()
if results:
try:
output_json_file = logdog_helper.open_text(benchmark_name)
json.dump(results, output_json_file,
indent=4, separators=(',', ': '))
except ValueError as e:
print('ValueError: "%s" while dumping output to logdog' % e)
finally:
output_json_file.close()
viewer_url = output_json_file.get_viewer_url()
else:
print("Perf results JSON file doesn't exist for benchmark %s" %
benchmark_name)
......@@ -600,7 +602,8 @@ def _write_perf_data_to_logfile(benchmark_name, output_file,
# add links for the perf results and the dashboard url to
# the logs section of buildbot
if is_ref:
logdog_dict[base_benchmark_name]['perf_results_ref'] = viewer_url
if viewer_url:
logdog_dict[base_benchmark_name]['perf_results_ref'] = viewer_url
if upload_failure:
logdog_dict[base_benchmark_name]['ref_upload_failed'] = 'True'
else:
......@@ -610,7 +613,8 @@ def _write_perf_data_to_logfile(benchmark_name, output_file,
configuration_name, RESULTS_URL,
build_properties['got_revision_cp'],
_GetMachineGroup(build_properties)))
logdog_dict[base_benchmark_name]['perf_results'] = viewer_url
if viewer_url:
logdog_dict[base_benchmark_name]['perf_results'] = viewer_url
if upload_failure:
logdog_dict[base_benchmark_name]['upload_failed'] = 'True'
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment