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

Side by Side Diff: appengine/findit/util_scripts/crash_queries/crash_iterator.py

Issue 2432203003: [Predator] Run predator. (Closed)
Patch Set: Rebase. Created 4 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 # 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 from datetime import date 5 from datetime import date
6 from datetime import datetime 6 from datetime import datetime
7 from datetime import timedelta 7 from datetime import timedelta
8 8
9 from crash.type_enums import CrashClient 9 from crash.type_enums import CrashClient
10 import iterator 10 import iterator
11 from model.crash.cracas_crash_analysis import CracasCrashAnalysis 11 from model.crash.cracas_crash_analysis import CracasCrashAnalysis
12 from model.crash.fracas_crash_analysis import FracasCrashAnalysis 12 from model.crash.fracas_crash_analysis import FracasCrashAnalysis
13 import remote_api
14 13
15 _DEFAULT_BATCH_SIZE = 1000 14 _DEFAULT_BATCH_SIZE = 1000
16 _TODAY = date.today().strftime('%Y-%m-%d') 15 _TODAY = date.today().strftime('%Y-%m-%d')
17 _A_YEAR_AGO = (date.today() - timedelta(days=365)).strftime('%Y-%m-%d') 16 _A_YEAR_AGO = (date.today() - timedelta(days=365)).strftime('%Y-%m-%d')
18 17
19 COMMON_CRASH_FIELDS = ['crashed_version', 'stack_trace', 'signature',
20 'platform', 'client_id', 'customized_data']
21
22 18
23 # TODO(katesonia): Switch to use fuction of objects encapsulating CrashClients, 19 # TODO(katesonia): Switch to use fuction of objects encapsulating CrashClients,
24 # after the refactoring is done. 20 # after the refactoring is done.
25 # TODO(crbug.com/662540): Add unittests. 21 # TODO(crbug.com/662540): Add unittests.
26 def GetAnalysisClassForClient(client_id): # pragma: no cover. 22 def GetAnalysisClassForClient(client_id): # pragma: no cover.
27 if client_id == CrashClient.FRACAS: 23 if client_id == CrashClient.FRACAS:
28 return FracasCrashAnalysis 24 return FracasCrashAnalysis
29 elif client_id == CrashClient.CRACAS: 25 elif client_id == CrashClient.CRACAS:
30 return CracasCrashAnalysis 26 return CracasCrashAnalysis
31 elif client_id == CrashClient.CLUSTERFUZZ: 27 elif client_id == CrashClient.CLUSTERFUZZ:
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 start_date (str): Only iterate testcases after this date including this 69 start_date (str): Only iterate testcases after this date including this
74 date, format '%Y-%m-%d'. 70 date, format '%Y-%m-%d'.
75 end_date (str): Only iterate testcases before this date excluding this date, 71 end_date (str): Only iterate testcases before this date excluding this date,
76 format '%Y-%m-%d'. 72 format '%Y-%m-%d'.
77 batch_size (int): The number of crashes to query at one time. 73 batch_size (int): The number of crashes to query at one time.
78 batch_run (bool): If True, iterate batches of crashes, if 74 batch_run (bool): If True, iterate batches of crashes, if
79 False, iterate each crash. 75 False, iterate each crash.
80 76
81 An example is available in crash_printer/print_crash.py. 77 An example is available in crash_printer/print_crash.py.
82 """ 78 """
83 if fields is None:
84 fields = COMMON_CRASH_FIELDS
85
86 if property_values is None: 79 if property_values is None:
87 property_values = {} 80 property_values = {}
88 81
89 query = GetQueryForClient(client_id, property_values, start_date, end_date) 82 query = GetQueryForClient(client_id, property_values, start_date, end_date)
90 for crash in iterator.Iterate(query, fields, app_id, batch_size=batch_size, 83 for crash in iterator.Iterate(query, app_id, fields=fields,
84 batch_size=batch_size,
91 batch_run=batch_run): 85 batch_run=batch_run):
92 yield crash 86 yield crash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698