Commit c7001b9f authored by WJH58's avatar WJH58
Browse files

add scripts necessary for shark

parent 3f384cd7
#!/usr/bin/env python3
import argparse
import subprocess
import time
"BOOT_FAIL": "failed",
"CANCELLED": "failed",
"COMPLETED": "success",
"CONFIGURING": "running",
"COMPLETING": "running",
"DEADLINE": "failed",
"FAILED": "failed",
"NODE_FAIL": "failed",
"OUT_OF_MEMORY": "failed",
"PENDING": "running",
"PREEMPTED": "failed",
"RUNNING": "running",
"RESIZING": "running",
"SUSPENDED": "running",
"TIMEOUT": "failed"
def fetch_status(batch_id, attempts: int = 3, wait_time_seconds: float = 3):
"""fetch the status for the batch id"""
sacct_args = ["sacct", "-j", batch_id, "-o", "State", "--parsable2",
for _ in range(attempts):
output = subprocess.check_output(sacct_args).decode("utf-8").strip()
if output:
raise TimeoutError(f"Failed to get state for job id: {batch_id}.")
# The first output is the state of the overall job
# See
# for details
job_status = output.split("\n")[0]
# If the job was cancelled manually, it will say by who, e.g "CANCELLED by 12345"
# We only care that it was cancelled
if job_status.startswith("CANCELLED by"):
return "CANCELLED"
# Otherwise, return the status
return STATE_MAP[job_status]
except KeyError:
raise NotImplementedError(f"Encountered unknown status {job_status} "
f"when parsing output:\n{output}")
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("batch_id", type=str)
args = parser.parse_args()
status = fetch_status(args.batch_id)
#! /bin/bash
#SBATCH --job-name=mini_snakemake
#SBATCH --mail-type=ALL
#SBATCH --mail-user
#SBATCH -t 48:00:00
#SBATCH --mem=60000
echo Start time : `date`
snakemake -p \
--snakefile Snakefile \
--latency-wait 60 \
--wait-for-files \
--rerun-incomplete \
--use-conda \
--cluster "sbatch --parsable --partition=all --mem=60g --ntasks=1 --cpus-per-task=8 --time=60:00:00 --hint=multithread" \
--cluster-status "./" \
--jobs 30
echo End time : `date`
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment