Bug 1497575: [taskgraph] Factor out try parameter determination; r=dustin
authorTom Prince <mozilla@hocat.ca>
Wed, 17 Oct 2018 17:15:54 +0000
changeset 497463 29ccb9942a39045f8d9f7f35d894678a7c2c8e1c
parent 497462 47e77fc9d69909cf7454bc58f5ef8189bb6f847d
child 497464 21477e61b5e12d48fe081f0576f2b6816c3b1606
push id9996
push userarchaeopteryx@coole-files.de
push dateThu, 18 Oct 2018 18:37:15 +0000
treeherdermozilla-beta@8efe26839243 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdustin
bugs1497575
milestone64.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1497575: [taskgraph] Factor out try parameter determination; r=dustin Differential Revision: https://phabricator.services.mozilla.com/D8329
taskcluster/taskgraph/decision.py
--- a/taskcluster/taskgraph/decision.py
+++ b/taskcluster/taskgraph/decision.py
@@ -226,16 +226,19 @@ def get_decision_parameters(config, opti
     parameters['release_type'] = 'nightly'
     parameters['release_eta'] = ''
     parameters['release_enable_partners'] = False
     parameters['release_partners'] = []
     parameters['release_partner_config'] = {}
     parameters['release_partner_build_number'] = 1
     parameters['release_enable_emefree'] = False
     parameters['release_product'] = None
+    parameters['try_mode'] = None
+    parameters['try_task_config'] = None
+    parameters['try_options'] = None
 
     # owner must be an email, but sometimes (e.g., for ffxbld) it is not, in which
     # case, fake it
     if '@' not in parameters['owner']:
         parameters['owner'] += '@noreply.mozilla.org'
 
     # use the pushdate as build_date if given, else use current time
     parameters['build_date'] = parameters['pushdate'] or int(time.time())
@@ -266,52 +269,51 @@ def get_decision_parameters(config, opti
     if options.get('try_task_config_file'):
         task_config_file = os.path.abspath(options.get('try_task_config_file'))
     else:
         # if try_task_config.json is present, load it
         task_config_file = os.path.join(os.getcwd(), 'try_task_config.json')
 
     # load try settings
     if 'try' in project:
-        parameters['try_mode'] = None
-        if os.path.isfile(task_config_file):
-            logger.info("using try tasks from {}".format(task_config_file))
-            parameters['try_mode'] = 'try_task_config'
-            with open(task_config_file, 'r') as fh:
-                parameters['try_task_config'] = json.load(fh)
-        else:
-            parameters['try_task_config'] = None
-
-        if 'try:' in parameters['message']:
-            parameters['try_mode'] = 'try_option_syntax'
-            args = parse_message(parameters['message'])
-            parameters['try_options'] = args
-        else:
-            parameters['try_options'] = None
-
-        if parameters['try_mode']:
-            # The user has explicitly requested a set of jobs, so run them all
-            # regardless of optimization.  Their dependencies can be optimized,
-            # though.
-            parameters['optimize_target_tasks'] = False
-        else:
-            # For a try push with no task selection, apply the default optimization
-            # process to all of the tasks.
-            parameters['optimize_target_tasks'] = True
-
-    else:
-        parameters['try_mode'] = None
-        parameters['try_task_config'] = None
-        parameters['try_options'] = None
+        set_try_config(parameters, task_config_file)
 
     result = Parameters(**parameters)
     result.check()
     return result
 
 
+def set_try_config(parameters, task_config_file):
+    parameters['try_mode'] = None
+    if os.path.isfile(task_config_file):
+        logger.info("using try tasks from {}".format(task_config_file))
+        parameters['try_mode'] = 'try_task_config'
+        with open(task_config_file, 'r') as fh:
+            parameters['try_task_config'] = json.load(fh)
+    else:
+        parameters['try_task_config'] = None
+
+    if 'try:' in parameters['message']:
+        parameters['try_mode'] = 'try_option_syntax'
+        args = parse_message(parameters['message'])
+        parameters['try_options'] = args
+    else:
+        parameters['try_options'] = None
+
+    if parameters['try_mode']:
+        # The user has explicitly requested a set of jobs, so run them all
+        # regardless of optimization.  Their dependencies can be optimized,
+        # though.
+        parameters['optimize_target_tasks'] = False
+    else:
+        # For a try push with no task selection, apply the default optimization
+        # process to all of the tasks.
+        parameters['optimize_target_tasks'] = True
+
+
 def write_artifact(filename, data):
     logger.info('writing artifact file `{}`'.format(filename))
     if not os.path.isdir(ARTIFACTS_DIR):
         os.mkdir(ARTIFACTS_DIR)
     path = os.path.join(ARTIFACTS_DIR, filename)
     if filename.endswith('.yml'):
         with open(path, 'w') as f:
             yaml.safe_dump(data, f, allow_unicode=True, default_flow_style=False)