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

Side by Side Diff: gm/rebaseline_server/server.py

Issue 688353003: Add support for rebaselining from trybots. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 1 month 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 #!/usr/bin/python 1 #!/usr/bin/python
2 2
3 """ 3 """
4 Copyright 2013 Google Inc. 4 Copyright 2013 Google Inc.
5 5
6 Use of this source code is governed by a BSD-style license that can be 6 Use of this source code is governed by a BSD-style license that can be
7 found in the LICENSE file. 7 found in the LICENSE file.
8 8
9 HTTP server for our HTML rebaseline viewer. 9 HTTP server for our HTML rebaseline viewer.
10 """ 10 """
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 255
256 file_handle.write('\n</ul></body></html>') 256 file_handle.write('\n</ul></body></html>')
257 257
258 258
259 class Server(object): 259 class Server(object):
260 """ HTTP server for our HTML rebaseline viewer. """ 260 """ HTTP server for our HTML rebaseline viewer. """
261 261
262 def __init__(self, 262 def __init__(self,
263 actuals_dir=DEFAULT_ACTUALS_DIR, 263 actuals_dir=DEFAULT_ACTUALS_DIR,
264 json_filename=DEFAULT_JSON_FILENAME, 264 json_filename=DEFAULT_JSON_FILENAME,
265 rietveld_issue=None,
265 gm_summaries_bucket=DEFAULT_GM_SUMMARIES_BUCKET, 266 gm_summaries_bucket=DEFAULT_GM_SUMMARIES_BUCKET,
266 port=DEFAULT_PORT, export=False, editable=True, 267 port=DEFAULT_PORT, export=False, editable=True,
267 reload_seconds=0, config_pairs=None, builder_regex_list=None, 268 reload_seconds=0, config_pairs=None, builder_regex_list=None,
268 boto_file_path=None, 269 boto_file_path=None,
269 imagediffdb_threads=imagediffdb.DEFAULT_NUM_WORKER_THREADS): 270 imagediffdb_threads=imagediffdb.DEFAULT_NUM_WORKER_THREADS):
270 """ 271 """
271 Args: 272 Args:
272 actuals_dir: directory under which we will check out the latest actual 273 actuals_dir: directory under which we will check out the latest actual
273 GM results 274 GM results
274 json_filename: basename of the JSON summary file to load for each builder 275 json_filename: basename of the JSON summary file to load for each builder
276 rietveld_issue: download json_filename files from latest trybot runs on
277 this codereview.chromium.org issue.
275 gm_summaries_bucket: Google Storage bucket to download json_filename 278 gm_summaries_bucket: Google Storage bucket to download json_filename
276 files from; if None or '', don't fetch new actual-results files 279 files from; if None or '', don't fetch new actual-results files
277 at all, just compare to whatever files are already in actuals_dir 280 at all, just compare to whatever files are already in actuals_dir
278 port: which TCP port to listen on for HTTP requests 281 port: which TCP port to listen on for HTTP requests
279 export: whether to allow HTTP clients on other hosts to access this server 282 export: whether to allow HTTP clients on other hosts to access this server
280 editable: whether HTTP clients are allowed to submit new GM baselines 283 editable: whether HTTP clients are allowed to submit new GM baselines
281 (SKP baseline modifications are performed using an entirely different 284 (SKP baseline modifications are performed using an entirely different
282 mechanism, not affected by this parameter) 285 mechanism, not affected by this parameter)
283 reload_seconds: polling interval with which to check for new results; 286 reload_seconds: polling interval with which to check for new results;
284 if 0, don't check for new results at all 287 if 0, don't check for new results at all
285 config_pairs: List of (string, string) tuples; for each tuple, compare 288 config_pairs: List of (string, string) tuples; for each tuple, compare
286 actual results of these two configs. If None or empty, 289 actual results of these two configs. If None or empty,
287 don't compare configs at all. 290 don't compare configs at all.
288 builder_regex_list: List of regular expressions specifying which builders 291 builder_regex_list: List of regular expressions specifying which builders
289 we will process. If None, process all builders. 292 we will process. If None, process all builders.
290 boto_file_path: Path to .boto file giving us credentials to access 293 boto_file_path: Path to .boto file giving us credentials to access
291 Google Storage buckets; if None, we will only be able to access 294 Google Storage buckets; if None, we will only be able to access
292 public GS buckets. 295 public GS buckets.
293 imagediffdb_threads: How many threads to spin up within imagediffdb. 296 imagediffdb_threads: How many threads to spin up within imagediffdb.
294 """ 297 """
295 self._actuals_dir = actuals_dir 298 self._actuals_dir = actuals_dir
296 self._json_filename = json_filename 299 self._json_filename = json_filename
300 self._rietveld_issue = rietveld_issue
297 self._gm_summaries_bucket = gm_summaries_bucket 301 self._gm_summaries_bucket = gm_summaries_bucket
298 self._port = port 302 self._port = port
299 self._export = export 303 self._export = export
300 self._editable = editable 304 self._editable = editable
301 self._reload_seconds = reload_seconds 305 self._reload_seconds = reload_seconds
302 self._config_pairs = config_pairs or [] 306 self._config_pairs = config_pairs or []
303 self._builder_regex_list = builder_regex_list 307 self._builder_regex_list = builder_regex_list
304 self.truncate_results = False 308 self.truncate_results = False
305 309
306 if boto_file_path: 310 if boto_file_path:
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 the same time. 382 the same time.
379 383
380 Args: 384 Args:
381 invalidate: if True, invalidate self._results immediately upon entry; 385 invalidate: if True, invalidate self._results immediately upon entry;
382 otherwise, we will let readers see those results until we 386 otherwise, we will let readers see those results until we
383 replace them 387 replace them
384 """ 388 """
385 with self.results_rlock: 389 with self.results_rlock:
386 if invalidate: 390 if invalidate:
387 self._results = None 391 self._results = None
392
393 if self._rietveld_issue:
394 logging.info(
395 'Updating GM result summaries in %s from rietveld_issue %s ...'
396 % (self._actuals_dir, self._rietveld_issue))
397
398 # Clean out actuals_dir first, in case some builders have gone away
rmistry 2014/11/05 13:39:16 There is a lot of code duplication here with the s
bungeman-skia 2014/11/07 22:56:53 Done.
399 # since we last ran.
400 if os.path.isdir(self._actuals_dir):
401 shutil.rmtree(self._actuals_dir)
402
403 # Get the list of actuals we care about.
404 all_actuals = download_actuals.get_rietveld_actuals(
405 self._rietveld_issue, self._json_filename)
406
407 if self._builder_regex_list:
408 matching_builders = []
409 for builder in all_actuals:
410 for regex in self._builder_regex_list:
411 if re.match(regex, builder):
412 matching_builders.append(builder)
413 break # go on to the next builder, no need to try more regexes
414 else:
415 matching_builders = all_actuals.keys()
416
417 # Download the JSON file for each builder we care about.
418 #
419 # TODO(epoger): When this is a large number of builders, we would be
420 # better off downloading them in parallel!
421 for builder in matching_builders:
422 self._gs.download_file(
423 source_bucket=all_actuals[builder][0],
424 source_path=all_actuals[builder][1],
425 source_generation=all_actuals[builder][2],
426 dest_path=os.path.join(self._actuals_dir, builder,
427 self._json_filename),
428 create_subdirs_if_needed=True)
429
388 if self._gm_summaries_bucket: 430 if self._gm_summaries_bucket:
389 logging.info( 431 logging.info(
390 'Updating GM result summaries in %s from gm_summaries_bucket %s ...' 432 'Updating GM result summaries in %s from gm_summaries_bucket %s ...'
391 % (self._actuals_dir, self._gm_summaries_bucket)) 433 % (self._actuals_dir, self._gm_summaries_bucket))
392 434
393 # Clean out actuals_dir first, in case some builders have gone away 435 # Clean out actuals_dir first, in case some builders have gone away
394 # since we last ran. 436 # since we last ran.
395 if os.path.isdir(self._actuals_dir): 437 if os.path.isdir(self._actuals_dir):
396 shutil.rmtree(self._actuals_dir) 438 shutil.rmtree(self._actuals_dir)
397 439
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after
892 parser.add_argument('--editable', action='store_true', 934 parser.add_argument('--editable', action='store_true',
893 help=('Allow HTTP clients to submit new GM baselines; ' 935 help=('Allow HTTP clients to submit new GM baselines; '
894 'SKP baselines can be edited regardless of this ' 936 'SKP baselines can be edited regardless of this '
895 'setting.')) 937 'setting.'))
896 parser.add_argument('--export', action='store_true', 938 parser.add_argument('--export', action='store_true',
897 help=('Instead of only allowing access from HTTP clients ' 939 help=('Instead of only allowing access from HTTP clients '
898 'on localhost, allow HTTP clients on other hosts ' 940 'on localhost, allow HTTP clients on other hosts '
899 'to access this server. WARNING: doing so will ' 941 'to access this server. WARNING: doing so will '
900 'allow users on other hosts to modify your ' 942 'allow users on other hosts to modify your '
901 'GM expectations, if combined with --editable.')) 943 'GM expectations, if combined with --editable.'))
944 parser.add_argument('--rietveld_issue',
945 help=('Download json_filename files from latest trybot'
946 'runs on this codereview.chromium.org issue.'))
902 parser.add_argument('--gm-summaries-bucket', 947 parser.add_argument('--gm-summaries-bucket',
903 help=('Google Cloud Storage bucket to download ' 948 help=('Google Cloud Storage bucket to download '
904 'JSON_FILENAME files from. ' 949 'JSON_FILENAME files from. '
905 'Defaults to %(default)s ; if set to ' 950 'Defaults to %(default)s ; if set to '
906 'empty string, just compare to actual-results ' 951 'empty string, just compare to actual-results '
907 'already found in ACTUALS_DIR.'), 952 'already found in ACTUALS_DIR.'),
908 default=DEFAULT_GM_SUMMARIES_BUCKET) 953 default=DEFAULT_GM_SUMMARIES_BUCKET)
909 parser.add_argument('--json-filename', 954 parser.add_argument('--json-filename',
910 help=('JSON summary filename to read for each builder; ' 955 help=('JSON summary filename to read for each builder; '
911 'defaults to %(default)s.'), 956 'defaults to %(default)s.'),
(...skipping 20 matching lines...) Expand all
932 'process, to speed up testing.')) 977 'process, to speed up testing.'))
933 args = parser.parse_args() 978 args = parser.parse_args()
934 if args.compare_configs: 979 if args.compare_configs:
935 config_pairs = CONFIG_PAIRS_TO_COMPARE 980 config_pairs = CONFIG_PAIRS_TO_COMPARE
936 else: 981 else:
937 config_pairs = None 982 config_pairs = None
938 983
939 global _SERVER 984 global _SERVER
940 _SERVER = Server(actuals_dir=args.actuals_dir, 985 _SERVER = Server(actuals_dir=args.actuals_dir,
941 json_filename=args.json_filename, 986 json_filename=args.json_filename,
987 rietveld_issue=args.rietveld_issue,
942 gm_summaries_bucket=args.gm_summaries_bucket, 988 gm_summaries_bucket=args.gm_summaries_bucket,
943 port=args.port, export=args.export, editable=args.editable, 989 port=args.port, export=args.export, editable=args.editable,
944 reload_seconds=args.reload, config_pairs=config_pairs, 990 reload_seconds=args.reload, config_pairs=config_pairs,
945 builder_regex_list=args.builders, boto_file_path=args.boto, 991 builder_regex_list=args.builders, boto_file_path=args.boto,
946 imagediffdb_threads=args.threads) 992 imagediffdb_threads=args.threads)
947 if args.truncate: 993 if args.truncate:
948 _SERVER.truncate_results = True 994 _SERVER.truncate_results = True
949 _SERVER.run() 995 _SERVER.run()
950 996
951 997
952 if __name__ == '__main__': 998 if __name__ == '__main__':
953 main() 999 main()
OLDNEW
« gm/rebaseline_server/download_actuals.py ('K') | « gm/rebaseline_server/download_actuals.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698