diff --git a/profiles/graham/config.yaml b/profiles/graham/config.yaml index 78ae83d8c..5177e2a72 100644 --- a/profiles/graham/config.yaml +++ b/profiles/graham/config.yaml @@ -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 diff --git a/workflow/scripts/slurm_status.py b/workflow/scripts/slurm_status.py new file mode 100644 index 000000000..b95d53190 --- /dev/null +++ b/workflow/scripts/slurm_status.py @@ -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")