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

Side by Side Diff: frontend/tko/rpc_interface.py

Issue 3541002: Revert "Merge remote branch 'cros/upstream' into tempbranch2" (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/autotest.git
Patch Set: Created 10 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 | Annotate | Revision Log
OLDNEW
1 import os, pickle, datetime, itertools, operator 1 import os, pickle, datetime, itertools, operator
2 from django.db import models as dbmodels 2 from django.db import models as dbmodels
3 from autotest_lib.frontend.afe import rpc_utils, model_logic 3 from autotest_lib.frontend.afe import rpc_utils, model_logic
4 from autotest_lib.frontend.afe import models as afe_models, readonly_connection 4 from autotest_lib.frontend.afe import models as afe_models, readonly_connection
5 from autotest_lib.frontend.tko import models, tko_rpc_utils, graphing_utils 5 from autotest_lib.frontend.tko import models, tko_rpc_utils, graphing_utils
6 from autotest_lib.frontend.tko import preconfigs 6 from autotest_lib.frontend.tko import preconfigs
7 7
8 # table/spreadsheet view support 8 # table/spreadsheet view support
9 9
10 def get_test_views(**filter_data): 10 def get_test_views(**filter_data):
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 166
167 all_iterations = iteration_attr.keys() + iteration_perf.keys() 167 all_iterations = iteration_attr.keys() + iteration_perf.keys()
168 max_iterations = max(all_iterations + [0]) 168 max_iterations = max(all_iterations + [0])
169 169
170 # merge the iterations into a single list of attr & perf dicts 170 # merge the iterations into a single list of attr & perf dicts
171 return [{'attr': iteration_attr.get(index, {}), 171 return [{'attr': iteration_attr.get(index, {}),
172 'perf': iteration_perf.get(index, {})} 172 'perf': iteration_perf.get(index, {})}
173 for index in xrange(1, max_iterations + 1)] 173 for index in xrange(1, max_iterations + 1)]
174 174
175 175
176 def _job_keyvals_to_dict(keyvals):
177 return dict((keyval.key, keyval.value) for keyval in keyvals)
178
179
180 def get_detailed_test_views(**filter_data): 176 def get_detailed_test_views(**filter_data):
181 test_views = models.TestView.list_objects(filter_data) 177 test_views = models.TestView.list_objects(filter_data)
182
183 tests_by_id = models.Test.objects.in_bulk([test_view['test_idx'] 178 tests_by_id = models.Test.objects.in_bulk([test_view['test_idx']
184 for test_view in test_views]) 179 for test_view in test_views])
185 tests = tests_by_id.values() 180 tests = tests_by_id.values()
186 models.Test.objects.populate_relationships(tests, models.TestAttribute, 181 models.Test.objects.populate_relationships(tests, models.TestAttribute,
187 'attributes') 182 'attributes')
188 models.Test.objects.populate_relationships(tests, models.IterationAttribute, 183 models.Test.objects.populate_relationships(tests, models.IterationAttribute,
189 'iteration_attributes') 184 'iteration_attributes')
190 models.Test.objects.populate_relationships(tests, models.IterationResult, 185 models.Test.objects.populate_relationships(tests, models.IterationResult,
191 'iteration_results') 186 'iteration_results')
192 models.Test.objects.populate_relationships(tests, models.TestLabel, 187 models.Test.objects.populate_relationships(tests, models.TestLabel,
193 'labels') 188 'labels')
194
195 jobs_by_id = models.Job.objects.in_bulk([test_view['job_idx']
196 for test_view in test_views])
197 jobs = jobs_by_id.values()
198 models.Job.objects.populate_relationships(jobs, models.JobKeyval,
199 'keyvals')
200
201 for test_view in test_views: 189 for test_view in test_views:
202 test = tests_by_id[test_view['test_idx']] 190 test = tests_by_id[test_view['test_idx']]
203 test_view['attributes'] = _attributes_to_dict(test.attributes) 191 test_view['attributes'] = _attributes_to_dict(test.attributes)
204 test_view['iterations'] = _format_iteration_keyvals(test) 192 test_view['iterations'] = _format_iteration_keyvals(test)
205 test_view['labels'] = [label.name for label in test.labels] 193 test_view['labels'] = [label.name for label in test.labels]
206
207 job = jobs_by_id[test_view['job_idx']]
208 test_view['job_keyvals'] = _job_keyvals_to_dict(job.keyvals)
209
210 return rpc_utils.prepare_for_serialization(test_views) 194 return rpc_utils.prepare_for_serialization(test_views)
211 195
212 # graphing view support 196 # graphing view support
213 197
214 def get_hosts_and_tests(): 198 def get_hosts_and_tests():
215 """\ 199 """\
216 Gets every host that has had a benchmark run on it. Additionally, also 200 Gets every host that has had a benchmark run on it. Additionally, also
217 gets a dictionary mapping the host names to the benchmarks. 201 gets a dictionary mapping the host names to the benchmarks.
218 """ 202 """
219 203
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 result['test_labels'] = get_test_labels(sort_by=['name']) 419 result['test_labels'] = get_test_labels(sort_by=['name'])
436 result['current_user'] = rpc_utils.prepare_for_serialization( 420 result['current_user'] = rpc_utils.prepare_for_serialization(
437 afe_models.User.current_user().get_object_dict()) 421 afe_models.User.current_user().get_object_dict())
438 result['benchmark_key'] = benchmark_key 422 result['benchmark_key'] = benchmark_key
439 result['tko_perf_view'] = tko_perf_view 423 result['tko_perf_view'] = tko_perf_view
440 result['tko_test_view'] = model_fields 424 result['tko_test_view'] = model_fields
441 result['preconfigs'] = preconfigs.manager.all_preconfigs() 425 result['preconfigs'] = preconfigs.manager.all_preconfigs()
442 result['motd'] = rpc_utils.get_motd() 426 result['motd'] = rpc_utils.get_motd()
443 427
444 return result 428 return result
OLDNEW
« no previous file with comments | « frontend/client/src/autotest/common/ui/SimplifiedList.java ('k') | frontend/tko/rpc_interface_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698