raptor_extra_options.py (2481B)
1 # This Source Code Form is subject to the terms of the Mozilla Public 2 # License, v. 2.0. If a copy of the MPL was not distributed with this 3 # file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 5 6 import logging 7 8 from taskgraph.util.taskcluster import get_task_definition 9 10 from .registry import register_callback_action 11 from .util import create_tasks, fetch_graph_and_labels 12 13 logger = logging.getLogger(__name__) 14 15 16 @register_callback_action( 17 title="Raptor Extra Options", 18 name="raptor-extra-options", 19 symbol="rxo", 20 description=( 21 "Allows the user to rerun raptor-browsertime tasks with additional arguments." 22 ), 23 order=200, 24 context=[{"test-type": "raptor"}], 25 schema={ 26 "type": "object", 27 "properties": { 28 "extra_options": { 29 "type": "string", 30 "default": "", 31 "description": "A space-delimited string of extra options " 32 "to be passed into a raptor-browsertime test." 33 "This also works with options with values, where the values " 34 "should be set as an assignment e.g. browser-cycles=3 " 35 "Passing multiple extra options could look something this: " 36 "`verbose browser-cycles=3` where the test runs with verbose " 37 "mode on and the browser cycles only 3 times.", 38 } 39 }, 40 }, 41 available=lambda parameters: True, 42 ) 43 def raptor_extra_options_action( 44 parameters, graph_config, input, task_group_id, task_id 45 ): 46 decision_task_id, full_task_graph, label_to_taskid, _ = fetch_graph_and_labels( 47 parameters, graph_config 48 ) 49 task = get_task_definition(task_id) 50 label = task["metadata"]["name"] 51 52 def modifier(task): 53 if task.label != label: 54 return task 55 56 if task.task["payload"]["env"].get("PERF_FLAGS"): 57 task.task["payload"]["env"]["PERF_FLAGS"] += " " + input.get( 58 "extra_options" 59 ) 60 else: 61 task.task["payload"]["env"].setdefault( 62 "PERF_FLAGS", input.get("extra_options") 63 ) 64 65 task.task["extra"]["treeherder"]["symbol"] += "-rxo" 66 task.task["extra"]["treeherder"]["groupName"] += " (extra options run)" 67 return task 68 69 create_tasks( 70 graph_config, 71 [label], 72 full_task_graph, 73 label_to_taskid, 74 parameters, 75 decision_task_id, 76 modifier=modifier, 77 )