Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(456)

Side by Side Diff: dashboard/dashboard/pinpoint/models/quest/read_value.py

Issue 3014663002: [pinpoint] Add trace links.
Patch Set: Created 3 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # Copyright 2016 The Chromium Authors. All rights reserved. 1 # Copyright 2016 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import json 5 import json
6 6
7 from dashboard.pinpoint.models.quest import execution 7 from dashboard.pinpoint.models.quest import execution
8 from dashboard.pinpoint.models.quest import quest 8 from dashboard.pinpoint.models.quest import quest
9 from dashboard.services import isolate_service 9 from dashboard.services import isolate_service
10 10
(...skipping 24 matching lines...) Expand all
35 return _ReadChartJsonValueExecution(self._chart, self._tir_label, 35 return _ReadChartJsonValueExecution(self._chart, self._tir_label,
36 self._trace, isolate_hash) 36 self._trace, isolate_hash)
37 37
38 38
39 class _ReadChartJsonValueExecution(execution.Execution): 39 class _ReadChartJsonValueExecution(execution.Execution):
40 40
41 def __init__(self, chart, tir_label, trace, isolate_hash): 41 def __init__(self, chart, tir_label, trace, isolate_hash):
42 super(_ReadChartJsonValueExecution, self).__init__() 42 super(_ReadChartJsonValueExecution, self).__init__()
43 self._chart = chart 43 self._chart = chart
44 self._tir_label = tir_label 44 self._tir_label = tir_label
45 self._trace = trace or 'summary' 45 self._trace = trace
46 self._isolate_hash = isolate_hash 46 self._isolate_hash = isolate_hash
47 47
48 self._trace_url = None
49
48 def _AsDict(self): 50 def _AsDict(self):
49 return {} 51 if not self._trace_url:
shatch 2017/09/27 11:55:50 Getting a failure here with no attribute _trace_ur
52 return {}
53 return {'trace_url': self._trace_url}
50 54
51 def _Poll(self): 55 def _Poll(self):
52 chartjson = _RetrieveOutputJson(self._isolate_hash, 'chartjson-output.json') 56 chartjson = _RetrieveOutputJson(self._isolate_hash, 'chartjson-output.json')
53 57
54 if self._tir_label: 58 if self._tir_label:
55 chart_name = '@@'.join((self._tir_label, self._chart)) 59 chart_name = '@@'.join((self._tir_label, self._chart))
56 else: 60 else:
57 chart_name = self._chart 61 chart_name = self._chart
58 if chart_name not in chartjson['charts']: 62 if chart_name not in chartjson['charts']:
59 raise ReadValueError('The chart "%s" is not in the results.' % 63 raise ReadValueError('The chart "%s" is not in the results.' % chart_name)
60 chart_name)
61 if self._trace not in chartjson['charts'][chart_name]:
62 raise ReadValueError('The trace "%s" is not in the results.' %
63 self._trace)
64 chart = chartjson['charts'][chart_name][self._trace]
65 64
65 trace_name = self._trace or 'summary'
66 if trace_name not in chartjson['charts'][chart_name]:
67 raise ReadValueError('The trace "%s" is not in the results.' % trace_name)
68
69 chart = chartjson['charts'][chart_name][trace_name]
66 if chart['type'] == 'list_of_scalar_values': 70 if chart['type'] == 'list_of_scalar_values':
67 result_values = chart['values'] 71 result_values = chart['values']
68 elif chart['type'] == 'histogram': 72 elif chart['type'] == 'histogram':
69 result_values = _ResultValuesFromHistogram(chart['buckets']) 73 result_values = _ResultValuesFromHistogram(chart['buckets'])
70 elif chart['type'] == 'scalar': 74 elif chart['type'] == 'scalar':
71 result_values = [chart['value']] 75 result_values = [chart['value']]
72 76
77 if self._trace:
shatch 2017/09/27 11:55:50 The bug linked (technically the one duped and clos
perezju 2017/09/27 12:24:06 chartjson (I think) only keeps a link to one of th
78 self._trace_url = chartjson['charts']['trace'][self._trace]['cloud_url']
79
73 self._Complete(result_values=tuple(result_values)) 80 self._Complete(result_values=tuple(result_values))
74 81
75 82
76 def _ResultValuesFromHistogram(buckets): 83 def _ResultValuesFromHistogram(buckets):
77 total_count = sum(bucket['count'] for bucket in buckets) 84 total_count = sum(bucket['count'] for bucket in buckets)
78 85
79 result_values = [] 86 result_values = []
80 for bucket in buckets: 87 for bucket in buckets:
81 # TODO: Assumes the bucket is evenly distributed. 88 # TODO: Assumes the bucket is evenly distributed.
82 bucket_mean = (bucket['low'] + bucket.get('high', bucket['low'])) / 2 89 bucket_mean = (bucket['low'] + bucket.get('high', bucket['low'])) / 2
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 self._Complete(result_values=(result_value,)) 140 self._Complete(result_values=(result_value,))
134 141
135 142
136 def _RetrieveOutputJson(isolate_hash, filename): 143 def _RetrieveOutputJson(isolate_hash, filename):
137 output_files = isolate_service.Retrieve(isolate_hash)['files'] 144 output_files = isolate_service.Retrieve(isolate_hash)['files']
138 145
139 if filename not in output_files: 146 if filename not in output_files:
140 raise ReadValueError("The test didn't produce %s." % filename) 147 raise ReadValueError("The test didn't produce %s." % filename)
141 output_json_isolate_hash = output_files[filename]['h'] 148 output_json_isolate_hash = output_files[filename]['h']
142 return json.loads(isolate_service.Retrieve(output_json_isolate_hash)) 149 return json.loads(isolate_service.Retrieve(output_json_isolate_hash))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698