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

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

Issue 27218005: rebaseline_server: add --editable and --reload flags (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: windowTitle Created 7 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
« no previous file with comments | « no previous file | gm/rebaseline_server/server.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 Repackage expected/actual GM results as needed by our HTML rebaseline viewer. 9 Repackage expected/actual GM results as needed by our HTML rebaseline viewer.
10 """ 10 """
11 11
12 # System-level imports 12 # System-level imports
13 import fnmatch 13 import fnmatch
14 import json 14 import json
15 import logging 15 import logging
16 import os 16 import os
17 import re 17 import re
18 import sys 18 import sys
19 import time
19 20
20 # Imports from within Skia 21 # Imports from within Skia
21 # 22 #
22 # We need to add the 'gm' directory, so that we can import gm_json.py within 23 # We need to add the 'gm' directory, so that we can import gm_json.py within
23 # that directory. That script allows us to parse the actual-results.json file 24 # that directory. That script allows us to parse the actual-results.json file
24 # written out by the GM tool. 25 # written out by the GM tool.
25 # Make sure that the 'gm' dir is in the PYTHONPATH, but add it at the *end* 26 # Make sure that the 'gm' dir is in the PYTHONPATH, but add it at the *end*
26 # so any dirs that are already in the PYTHONPATH will be preferred. 27 # so any dirs that are already in the PYTHONPATH will be preferred.
27 GM_DIRECTORY = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) 28 GM_DIRECTORY = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
28 if GM_DIRECTORY not in sys.path: 29 if GM_DIRECTORY not in sys.path:
(...skipping 17 matching lines...) Expand all
46 47
47 def __init__(self, actuals_root, expected_root): 48 def __init__(self, actuals_root, expected_root):
48 """ 49 """
49 Args: 50 Args:
50 actuals_root: root directory containing all actual-results.json files 51 actuals_root: root directory containing all actual-results.json files
51 expected_root: root directory containing all expected-results.json files 52 expected_root: root directory containing all expected-results.json files
52 """ 53 """
53 self._actual_builder_dicts = Results._get_dicts_from_root(actuals_root) 54 self._actual_builder_dicts = Results._get_dicts_from_root(actuals_root)
54 self._expected_builder_dicts = Results._get_dicts_from_root(expected_root) 55 self._expected_builder_dicts = Results._get_dicts_from_root(expected_root)
55 self._combine_actual_and_expected() 56 self._combine_actual_and_expected()
57 self._timestamp = int(time.time())
58
59 def get_timestamp(self):
60 """Return the time at which this object was created, in seconds past epoch
61 (UTC).
62 """
63 return self._timestamp
56 64
57 def get_results_of_type(self, type): 65 def get_results_of_type(self, type):
58 """Return results of some/all tests (depending on 'type' parameter). 66 """Return results of some/all tests (depending on 'type' parameter).
59 67
60 Args: 68 Args:
61 type: string describing which types of results to include; must be one 69 type: string describing which types of results to include; must be one
62 of the RESULTS_* constants 70 of the RESULTS_* constants
63 71
64 Results are returned as a dictionary in this form: 72 Results are returned as a dictionary in this form:
65 73
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 def _get_dicts_from_root(root, pattern='*.json'): 114 def _get_dicts_from_root(root, pattern='*.json'):
107 """Read all JSON dictionaries within a directory tree. 115 """Read all JSON dictionaries within a directory tree.
108 116
109 Args: 117 Args:
110 root: path to root of directory tree 118 root: path to root of directory tree
111 pattern: which files to read within root (fnmatch-style pattern) 119 pattern: which files to read within root (fnmatch-style pattern)
112 120
113 Returns: 121 Returns:
114 A meta-dictionary containing all the JSON dictionaries found within 122 A meta-dictionary containing all the JSON dictionaries found within
115 the directory tree, keyed by the builder name of each dictionary. 123 the directory tree, keyed by the builder name of each dictionary.
124
125 Raises:
126 IOError if root does not refer to an existing directory
116 """ 127 """
128 if not os.path.isdir(root):
129 raise IOError('no directory found at path %s' % root)
117 meta_dict = {} 130 meta_dict = {}
118 for dirpath, dirnames, filenames in os.walk(root): 131 for dirpath, dirnames, filenames in os.walk(root):
119 for matching_filename in fnmatch.filter(filenames, pattern): 132 for matching_filename in fnmatch.filter(filenames, pattern):
120 builder = os.path.basename(dirpath) 133 builder = os.path.basename(dirpath)
121 if builder.endswith('-Trybot'): 134 if builder.endswith('-Trybot'):
122 continue 135 continue
123 fullpath = os.path.join(dirpath, matching_filename) 136 fullpath = os.path.join(dirpath, matching_filename)
124 meta_dict[builder] = gm_json.LoadFromFile(fullpath) 137 meta_dict[builder] = gm_json.LoadFromFile(fullpath)
125 return meta_dict 138 return meta_dict
126 139
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 category_dict: category dict-of-dicts to modify 291 category_dict: category dict-of-dicts to modify
279 category_name: category name, as a string 292 category_name: category name, as a string
280 category_values: list of values we want to make sure are represented 293 category_values: list of values we want to make sure are represented
281 for this category 294 for this category
282 """ 295 """
283 if not category_dict.get(category_name): 296 if not category_dict.get(category_name):
284 category_dict[category_name] = {} 297 category_dict[category_name] = {}
285 for category_value in category_values: 298 for category_value in category_values:
286 if not category_dict[category_name].get(category_value): 299 if not category_dict[category_name].get(category_value):
287 category_dict[category_name][category_value] = 0 300 category_dict[category_name][category_value] = 0
OLDNEW
« no previous file with comments | « no previous file | gm/rebaseline_server/server.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698