Skip to content

Commit d2966fb

Browse files
committed
Improvements to Azure CI executor.
Uses only 1 thread of scheduling without any extra idle threads.
1 parent 7bac40b commit d2966fb

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

python/powerlift/src/powerlift/executors/azure_ci.py

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,11 @@ def _wait_for_completed_worker(results):
1818
return None
1919

2020
while True:
21-
completed = False
2221
for worker_id, result in results.items():
2322
if result is None or result.done():
24-
completed = True
25-
break
26-
if completed:
27-
del results[worker_id]
28-
return worker_id
29-
else:
30-
time.sleep(1)
23+
del results[worker_id]
24+
return worker_id
25+
time.sleep(1)
3126

3227

3328
def _run(tasks, azure_json, num_cores, mem_size_gb, n_running_containers, delete_group_container_on_complete, batch_id):
@@ -58,7 +53,10 @@ def _run(tasks, azure_json, num_cores, mem_size_gb, n_running_containers, delete
5853

5954
# Run until completion.
6055
container_counter = 0
61-
results = {x: None for x in range(n_running_containers)}
56+
n_tasks = len(tasks)
57+
n_containers = min(n_tasks, n_running_containers)
58+
results = {x: None for x in range(n_containers)}
59+
container_group_names = set()
6260
while len(tasks) != 0:
6361
params = tasks.pop(0)
6462
worker_id = _wait_for_completed_worker(results)
@@ -95,10 +93,11 @@ def _run(tasks, azure_json, num_cores, mem_size_gb, n_running_containers, delete
9593
restart_policy=ContainerGroupRestartPolicy.never,
9694
)
9795
container_group_name = f"powerlift-container-group-{worker_id}-{batch_id}"
98-
9996
result = aci_client.container_groups.begin_create_or_update(
10097
resource_group.name, container_group_name, container_group
10198
)
99+
100+
container_group_names.add(container_group_name)
102101
results[worker_id] = result
103102

104103
# Wait for all container groups to complete
@@ -107,8 +106,7 @@ def _run(tasks, azure_json, num_cores, mem_size_gb, n_running_containers, delete
107106

108107
# Delete all container groups
109108
if delete_group_container_on_complete:
110-
for worker_id in range(n_running_containers):
111-
container_group_name = f"powerlift-container-group-{worker_id}-{batch_id}"
109+
for container_group_name in container_group_names:
112110
aci_client.container_groups.begin_delete(
113111
resource_group_name, container_group_name
114112
)
@@ -170,7 +168,7 @@ def __init__(
170168
"resource_group": resource_group,
171169
}
172170
self._batch_id = random.getrandbits(64)
173-
super().__init__(store=store, n_cpus=n_running_containers, raise_exception=raise_exception, wheel_filepaths=wheel_filepaths)
171+
super().__init__(store=store, n_cpus=1, raise_exception=raise_exception, wheel_filepaths=wheel_filepaths)
174172

175173
def delete_credentials(self):
176174
"""Deletes credentials in object for accessing Azure Resources."""

0 commit comments

Comments
 (0)