OLD | NEW |
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 """ |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 'ignore-failure': false, | 173 'ignore-failure': false, |
174 'reviewed-by-human': true, | 174 'reviewed-by-human': true, |
175 }, | 175 }, |
176 ... | 176 ... |
177 ], # end of 'testData' list | 177 ], # end of 'testData' list |
178 } | 178 } |
179 """ | 179 """ |
180 return self._results[type] | 180 return self._results[type] |
181 | 181 |
182 @staticmethod | 182 @staticmethod |
| 183 def _ignore_builder(builder): |
| 184 """Returns True if we should ignore expectations and actuals for a builder. |
| 185 |
| 186 This allows us to ignore builders for which we don't maintain expectations |
| 187 (trybots, Valgrind, ASAN, TSAN), and avoid problems like |
| 188 https://code.google.com/p/skia/issues/detail?id=2036 ('rebaseline_server |
| 189 produces error when trying to add baselines for ASAN/TSAN builders') |
| 190 |
| 191 Args: |
| 192 builder: name of this builder, as a string |
| 193 |
| 194 Returns: |
| 195 True if we should ignore expectations and actuals for this builder. |
| 196 """ |
| 197 return (builder.endswith('-Trybot') or |
| 198 ('Valgrind' in builder) or |
| 199 ('TSAN' in builder) or |
| 200 ('ASAN' in builder)) |
| 201 |
| 202 @staticmethod |
183 def _read_dicts_from_root(root, pattern='*.json'): | 203 def _read_dicts_from_root(root, pattern='*.json'): |
184 """Read all JSON dictionaries within a directory tree. | 204 """Read all JSON dictionaries within a directory tree. |
185 | 205 |
186 Args: | 206 Args: |
187 root: path to root of directory tree | 207 root: path to root of directory tree |
188 pattern: which files to read within root (fnmatch-style pattern) | 208 pattern: which files to read within root (fnmatch-style pattern) |
189 | 209 |
190 Returns: | 210 Returns: |
191 A meta-dictionary containing all the JSON dictionaries found within | 211 A meta-dictionary containing all the JSON dictionaries found within |
192 the directory tree, keyed by the builder name of each dictionary. | 212 the directory tree, keyed by the builder name of each dictionary. |
193 | 213 |
194 Raises: | 214 Raises: |
195 IOError if root does not refer to an existing directory | 215 IOError if root does not refer to an existing directory |
196 """ | 216 """ |
197 if not os.path.isdir(root): | 217 if not os.path.isdir(root): |
198 raise IOError('no directory found at path %s' % root) | 218 raise IOError('no directory found at path %s' % root) |
199 meta_dict = {} | 219 meta_dict = {} |
200 for dirpath, dirnames, filenames in os.walk(root): | 220 for dirpath, dirnames, filenames in os.walk(root): |
201 for matching_filename in fnmatch.filter(filenames, pattern): | 221 for matching_filename in fnmatch.filter(filenames, pattern): |
202 builder = os.path.basename(dirpath) | 222 builder = os.path.basename(dirpath) |
203 # If we are reading from the collection of actual results, skip over | 223 if Results._ignore_builder(builder): |
204 # the Trybot results (we don't maintain baselines for them). | |
205 if builder.endswith('-Trybot'): | |
206 continue | 224 continue |
207 fullpath = os.path.join(dirpath, matching_filename) | 225 fullpath = os.path.join(dirpath, matching_filename) |
208 meta_dict[builder] = gm_json.LoadFromFile(fullpath) | 226 meta_dict[builder] = gm_json.LoadFromFile(fullpath) |
209 return meta_dict | 227 return meta_dict |
210 | 228 |
211 @staticmethod | 229 @staticmethod |
212 def _write_dicts_to_root(meta_dict, root, pattern='*.json'): | 230 def _write_dicts_to_root(meta_dict, root, pattern='*.json'): |
213 """Write all per-builder dictionaries within meta_dict to files under | 231 """Write all per-builder dictionaries within meta_dict to files under |
214 the root path. | 232 the root path. |
215 | 233 |
(...skipping 13 matching lines...) Expand all Loading... |
229 IOError if root does not refer to an existing directory | 247 IOError if root does not refer to an existing directory |
230 KeyError if the set of per-builder dictionaries written out was | 248 KeyError if the set of per-builder dictionaries written out was |
231 different than expected | 249 different than expected |
232 """ | 250 """ |
233 if not os.path.isdir(root): | 251 if not os.path.isdir(root): |
234 raise IOError('no directory found at path %s' % root) | 252 raise IOError('no directory found at path %s' % root) |
235 actual_builders_written = [] | 253 actual_builders_written = [] |
236 for dirpath, dirnames, filenames in os.walk(root): | 254 for dirpath, dirnames, filenames in os.walk(root): |
237 for matching_filename in fnmatch.filter(filenames, pattern): | 255 for matching_filename in fnmatch.filter(filenames, pattern): |
238 builder = os.path.basename(dirpath) | 256 builder = os.path.basename(dirpath) |
239 # We should never encounter Trybot *expectations*, but if we are | 257 if Results._ignore_builder(builder): |
240 # writing into the actual-results dir, skip the Trybot actuals. | |
241 # (I don't know why we would ever write into the actual-results dir, | |
242 # though.) | |
243 if builder.endswith('-Trybot'): | |
244 continue | 258 continue |
245 per_builder_dict = meta_dict.get(builder) | 259 per_builder_dict = meta_dict.get(builder) |
246 if per_builder_dict is not None: | 260 if per_builder_dict is not None: |
247 fullpath = os.path.join(dirpath, matching_filename) | 261 fullpath = os.path.join(dirpath, matching_filename) |
248 gm_json.WriteToFile(per_builder_dict, fullpath) | 262 gm_json.WriteToFile(per_builder_dict, fullpath) |
249 actual_builders_written.append(builder) | 263 actual_builders_written.append(builder) |
250 | 264 |
251 # Check: did we write out the set of per-builder dictionaries we | 265 # Check: did we write out the set of per-builder dictionaries we |
252 # expected to? | 266 # expected to? |
253 expected_builders_written = sorted(meta_dict.keys()) | 267 expected_builders_written = sorted(meta_dict.keys()) |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 help='Directory within which to download images and generate diffs') | 533 help='Directory within which to download images and generate diffs') |
520 args = parser.parse_args() | 534 args = parser.parse_args() |
521 results = Results(actuals_root=args.actuals, | 535 results = Results(actuals_root=args.actuals, |
522 expected_root=args.expectations, | 536 expected_root=args.expectations, |
523 generated_images_root=args.workdir) | 537 generated_images_root=args.workdir) |
524 gm_json.WriteToFile(results.get_results_of_type(RESULTS_ALL), args.outfile) | 538 gm_json.WriteToFile(results.get_results_of_type(RESULTS_ALL), args.outfile) |
525 | 539 |
526 | 540 |
527 if __name__ == '__main__': | 541 if __name__ == '__main__': |
528 main() | 542 main() |
OLD | NEW |