112
112
113
113
114
114
@transforms .add
115
- def rewrite_when_to_optimization (config , jobs ):
116
- for job in jobs :
115
+ async def rewrite_when_to_optimization (config , jobs ):
116
+ async for job in jobs :
117
117
when = job .pop ("when" , {})
118
118
if not when :
119
119
yield job
@@ -132,8 +132,8 @@ def rewrite_when_to_optimization(config, jobs):
132
132
133
133
134
134
@transforms .add
135
- def set_implementation (config , jobs ):
136
- for job in jobs :
135
+ async def set_implementation (config , jobs ):
136
+ async for job in jobs :
137
137
impl , os = worker_type_implementation (config .graph_config , job ["worker-type" ])
138
138
if os :
139
139
job .setdefault ("tags" , {})["os" ] = os
@@ -148,8 +148,8 @@ def set_implementation(config, jobs):
148
148
149
149
150
150
@transforms .add
151
- def set_label (config , jobs ):
152
- for job in jobs :
151
+ async def set_label (config , jobs ):
152
+ async for job in jobs :
153
153
if "label" not in job :
154
154
if "name" not in job :
155
155
raise Exception ("job has neither a name nor a label" )
@@ -160,8 +160,8 @@ def set_label(config, jobs):
160
160
161
161
162
162
@transforms .add
163
- def add_resource_monitor (config , jobs ):
164
- for job in jobs :
163
+ async def add_resource_monitor (config , jobs ):
164
+ async for job in jobs :
165
165
if job .get ("attributes" , {}).get ("resource-monitor" ):
166
166
worker_implementation , worker_os = worker_type_implementation (
167
167
config .graph_config , job ["worker-type" ]
@@ -204,13 +204,13 @@ def get_attribute(dict, key, attributes, attribute_name):
204
204
205
205
206
206
@transforms .add
207
- def use_fetches (config , jobs ):
207
+ async def use_fetches (config , jobs ):
208
208
artifact_names = {}
209
209
aliases = {}
210
210
extra_env = {}
211
211
212
+ jobs = [j async for j in jobs ]
212
213
if config .kind in ("toolchain" , "fetch" ):
213
- jobs = list (jobs )
214
214
for job in jobs :
215
215
run = job .get ("run" , {})
216
216
label = job ["label" ]
@@ -353,12 +353,12 @@ def cmp_artifacts(a):
353
353
354
354
355
355
@transforms .add
356
- def make_task_description (config , jobs ):
356
+ async def make_task_description (config , jobs ):
357
357
"""Given a build description, create a task description"""
358
358
# import plugin modules first, before iterating over jobs
359
359
import_sibling_modules (exceptions = ("common.py" ,))
360
360
361
- for job in jobs :
361
+ async for job in jobs :
362
362
# always-optimized tasks never execute, so have no workdir
363
363
if job ["worker" ]["implementation" ] in ("docker-worker" , "generic-worker" ):
364
364
job ["run" ].setdefault ("workdir" , "/builds/worker" )
0 commit comments