Skip to content
This repository was archived by the owner on Apr 22, 2025. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 25 additions & 12 deletions sequence_processing_pipeline/Job.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import logging
from inspect import stack
import re
from collections import Counter, defaultdict


class Job:
Expand Down Expand Up @@ -263,24 +264,36 @@ def query_slurm(job_ids):
jobs[unique_id] = state

if unique_id != job_id:
child_jobs[unique_id] = job_id # job is a child job
# job is a child job
child_jobs[unique_id] = [job_id, state]

return jobs, child_jobs

while True:
jobs, child_jobs = query_slurm(job_ids)

for jid in job_ids:
logging.debug("JOB %s: %s" % (jid, jobs[jid]))
if callback is not None:
callback(jid=jid, status=jobs[jid])

children = [x for x in child_jobs if child_jobs[x] == jid]
if len(children) == 0:
logging.debug("\tNO CHILDREN")
for cid in children:
logging.debug("\tCHILD JOB %s: %s" % (cid, jobs[cid]))
status = [jobs[x] in Job.slurm_status_not_running for x in job_ids]
status = []
status_display = defaultdict(list)

# check main jobs
for job in job_ids:
status.append(jobs[job] in Job.slurm_status_not_running)
status_display[job].append(jobs[job])

# check children
for child_job, (parent_job, state) in child_jobs.items():
status_display[parent_job].append(state)
status.append(state in Job.slurm_status_not_running)

if callback is not None:
status_text = []
for parent_job, state in status_display.items():
msg = ', '.join([f'{x}: {y}' for x, y in
Counter(state).most_common()])
status_text.append(f'{parent_job}: {msg}')

# job_id is contained in status_text so jid='' is fine.
callback(jid='', status=' -- '.join(status_text))

if set(status) == {True}:
# all jobs either completed successfully or terminated.
Expand Down
1 change: 1 addition & 0 deletions sequence_processing_pipeline/templates/nuqc_job.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
### Commented out for now, but there is a possibility it will be needed
### in the future.
###SBATCH --gres=node_jobs:{{gres_value}}
#SBATCH --constraint="amd"


echo "---------------"
Expand Down
Loading