Skip to content

Commit

Permalink
add slurm status check
Browse files Browse the repository at this point in the history
  • Loading branch information
ktmeaton committed Oct 2, 2020
1 parent aa7e551 commit f5da223
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions profiles/graham/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ log-handler-script: workflow/scripts/slack_log.py

# slurm execution
cluster: "sbatch -t {resources.time_min} --mem={resources.mem_mb} -c {resources.cpus} -o /home/keaton/projects/def-briang/keaton/plague-phylogeography/workflow/logs_slurm/{rule}_{wildcards} -e /home/keaton/projects/def-briang/keaton/plague-phylogeography/workflow/logs_slurm/{rule}_{wildcards}"
cluster-status: workflow/scripts/slurm_status.py
15 changes: 15 additions & 0 deletions workflow/scripts/slurm_status.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env python
import subprocess
import sys

jobid = sys.argv[1]

output = str(subprocess.check_output("sacct -j %s --format State --noheader | head -1 | awk '{print $1}'" % jobid, shell=True).strip())

running_status=["PENDING", "CONFIGURING", "COMPLETING", "RUNNING", "SUSPENDED"]
if "COMPLETED" in output:
print("success")
elif any(r in output for r in running_status):
print("running")
else:
print("failed")

0 comments on commit f5da223

Please sign in to comment.