Skip to content

Commit 22990ce

Browse files
authored
Generalize the add_tasks butler script. (#4640)
So that it can be used to restart other kinds of tasks on arbitrary testcases. Bug: https://crbug.com/389589679
1 parent 750dfd2 commit 22990ce

File tree

2 files changed

+31
-44
lines changed

2 files changed

+31
-44
lines changed

butler.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,10 @@ def main():
338338
'script_name',
339339
help='The script module name under `./local/butler/scripts`.')
340340
parser_run.add_argument(
341-
'--script_args', action='append', help='Script specific arguments')
341+
'--script_args',
342+
action='extend',
343+
nargs='+',
344+
help='Script specific arguments')
342345
parser_run.add_argument(
343346
'--non-dry-run',
344347
action='store_true',

src/local/butler/scripts/add_tasks.py

Lines changed: 27 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -15,51 +15,35 @@
1515
from clusterfuzz._internal.base import tasks
1616
from clusterfuzz._internal.datastore import data_handler
1717

18+
_TASK_NAMES = [
19+
'minimize',
20+
'analyze',
21+
'regression',
22+
'progression',
23+
]
24+
1825

1926
def execute(args):
20-
"""Adds task to queue. Ignores |args|."""
21-
del args
27+
"""Adds tasks to queue."""
28+
if args.script_args is None or len(args.script_args) < 2:
29+
print('Usage: add_tasks --script_args TASK_NAME TESTCASE_IDS...')
30+
return
31+
32+
task_name = args.script_args[0]
33+
if task_name not in _TASK_NAMES:
34+
print(f'Unknown task name {task_name}. Valid options: ' +
35+
','.join(_TASK_NAMES))
36+
return
37+
38+
testcase_ids = args.script_args[1:]
2239

23-
testcase_ids = [
24-
6370177092354048,
25-
4744808593555456,
26-
5227780266459136,
27-
6574395942174720,
28-
5244277185511424,
29-
6510914580709376,
30-
5775142323945472,
31-
6011445988753408,
32-
4906124947947520,
33-
6530929128308736,
34-
5352929858879488,
35-
4822064720445440,
36-
6196499218104320,
37-
5648685870284800,
38-
5743771882815488,
39-
6572216783142912,
40-
6312222733041664,
41-
4645517271171072,
42-
4563799747002368,
43-
4938153525706752,
44-
6726867197296640,
45-
5648258588147712,
46-
6071687468482560,
47-
6341729695236096,
48-
5161211645591552,
49-
5737435933638656,
50-
5841772634636288,
51-
6063675576090624,
52-
6283270358499328,
53-
4920378535116800,
54-
6026859015766016,
55-
4797038180892672,
56-
6469710677737472,
57-
6733155834724352,
58-
6217441478639616,
59-
5871576352227328,
60-
]
6140
for testcase_id in testcase_ids:
6241
testcase = data_handler.get_testcase_by_id(testcase_id)
63-
print(f'Restarted {testcase_id}.')
64-
queue = tasks.default_queue()
65-
tasks.add_task('analyze', str(testcase_id), testcase.job_type, queue)
42+
queue = tasks.queue_for_testcase(testcase)
43+
44+
print(f'Adding task: {task_name} {testcase_id} {testcase.job_type}')
45+
if not args.non_dry_run:
46+
print(' Skipping for dry-run mode.')
47+
continue
48+
49+
tasks.add_task(task_name, testcase_id, testcase.job_type, queue)

0 commit comments

Comments
 (0)