Skip to content

Commit 87764e2

Browse files
authored
Clean up main.py
1 parent 028c571 commit 87764e2

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

main.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -146,18 +146,17 @@ def allocate_runners_for_jobs(workflow_data, token, repo_api_base_url, repo_url,
146146
For each queued job in a workflow, allocate the ephemeral SLURM runner if appropriate.
147147
Returns the count of new allocations made.
148148
"""
149+
new_allocations = 0
150+
149151
if "workflow_runs" not in workflow_data:
150152
logger.error("No workflow_runs in data.")
151-
return 0
153+
return new_allocations
152154

153-
new_allocations = 0
154155
number_of_queued_workflows = len(workflow_data["workflow_runs"])
155156

156157
for i in range(number_of_queued_workflows):
157158
workflow_id = workflow_data["workflow_runs"][i]["id"]
158159
branch = workflow_data["workflow_runs"][i]["head_branch"]
159-
# if branch != "alexboden/test-slurm-gha-runner" and branch != "alexboden/test-ci-apptainer":
160-
# continue
161160
job_data = get_all_jobs(workflow_id, token, repo_api_base_url)
162161
if not job_data:
163162
continue
@@ -242,10 +241,10 @@ def allocate_actions_runner(job_id, token, repo_api_base_url, repo_url, repo_nam
242241
)
243242

244243
# For example, you might only allocate if "slurm-runner" in labels
245-
# if "slurm-runner" not in labels:
246-
# logger.info("Skipping job because it is not labeled for slurm-runner.")
247-
# del allocated_jobs[(repo_name, job_id)]
248-
# return False
244+
if "slurm-runner" not in labels:
245+
logger.info("Skipping job because it is not labeled for slurm-runner.")
246+
del allocated_jobs[(repo_name, job_id)]
247+
return False
249248

250249
runner_size_label = labels[0]
251250

@@ -260,7 +259,7 @@ def allocate_actions_runner(job_id, token, repo_api_base_url, repo_url, repo_nam
260259
# sbatch resource allocation command
261260
command = [
262261
"sbatch",
263-
f"--output=/var/log/slurm-ci/slurm-ci-%j.out",
262+
f"--output=/var/log/slurm-ci/slurm-ci-%j.out",
264263
f"--job-name=slurm-{runner_size_label}-{job_id}",
265264
f"--mem-per-cpu={runner_resources['mem-per-cpu']}",
266265
f"--cpus-per-task={runner_resources['cpu']}",
@@ -328,6 +327,7 @@ def allocate_actions_runner(job_id, token, repo_api_base_url, repo_url, repo_nam
328327
logger.error(f"Exception occurred in allocate_actions_runner for job_id {job_id}: {e}")
329328
if job_id in allocated_jobs:
330329
del allocated_jobs[job_id]
330+
331331
def check_slurm_status():
332332
"""
333333
Checks the status of SLURM jobs and removes completed or failed entries from allocated_jobs.

0 commit comments

Comments
 (0)