|
| 1 | +# Adding handlers for displaying status of the |
| 2 | +# pipeline and for getting job information for |
| 3 | +# previously submitted jobs using `jobby`: |
| 4 | +# https://github.com/OpenOmics/scribble/blob/main/scripts/jobby/jobby |
| 5 | +if config['options']['mode'] == 'slurm': |
| 6 | + onstart: |
| 7 | + shell( |
| 8 | + """ |
| 9 | + # Move any job information for a previous |
| 10 | + # instance of the pipeline to logfiles |
| 11 | + sleep 5; rm -f COMPLETED FAILED RUNNING; |
| 12 | + touch RUNNING |
| 13 | + for f in job_information_*.tsv; do |
| 14 | + # Skip over non-existant files |
| 15 | + [ -e "${{f}}" ] || continue |
| 16 | + mv ${{f}} logfiles/; |
| 17 | + done |
| 18 | +
|
| 19 | + for f in failed_jobs_*.tsv; do |
| 20 | + # Skip over non-existant files |
| 21 | + [ -e "${{f}}" ] || continue |
| 22 | + mv ${{f}} logfiles/; |
| 23 | + done |
| 24 | + """ |
| 25 | + ) |
| 26 | + |
| 27 | + onsuccess: |
| 28 | + shell( |
| 29 | + """ |
| 30 | + # Get job information on all |
| 31 | + # previously submitted jobs |
| 32 | + sleep 15; rm -f COMPLETED FAILED RUNNING; |
| 33 | + timestamp=$(date +"%Y-%m-%d_%H-%M-%S"); |
| 34 | + ./workflow/scripts/jobby \\ |
| 35 | + $(grep --color=never "^Submitted .* external jobid" logfiles/snakemake.log \\ |
| 36 | + | awk '{{print $NF}}' \\ |
| 37 | + | sed "s/['.]//g" \\ |
| 38 | + | sort \\ |
| 39 | + | uniq \\ |
| 40 | + | tr "\\n" " " |
| 41 | + ) \\ |
| 42 | + > job_information_${{timestamp}}.tsv \\ |
| 43 | + || {{ |
| 44 | + # Handles edge case were only "rule all" |
| 45 | + # is run and no child jobs are submitted |
| 46 | + touch job_information_${{timestamp}}.tsv |
| 47 | + }} |
| 48 | +
|
| 49 | + # Get information on any child |
| 50 | + # job(s) that may have failed |
| 51 | + grep --color=never \\ |
| 52 | + '^jobid\\|FAILED' \\ |
| 53 | + job_information_${{timestamp}}.tsv \\ |
| 54 | + > failed_jobs_${{timestamp}}.tsv \\ |
| 55 | + || {{ |
| 56 | + # Handles edge case were only "rule all" |
| 57 | + # is run and no child jobs are submitted |
| 58 | + touch failed_jobs_${{timestamp}}.tsv |
| 59 | + }} |
| 60 | + touch COMPLETED |
| 61 | + """ |
| 62 | + ) |
| 63 | + |
| 64 | + onerror: |
| 65 | + shell( |
| 66 | + """ |
| 67 | + # Get job information on all |
| 68 | + # previously submitted jobs |
| 69 | + sleep 15; rm -f COMPLETED FAILED RUNNING; |
| 70 | + timestamp=$(date +"%Y-%m-%d_%H-%M-%S"); |
| 71 | + ./workflow/scripts/jobby \\ |
| 72 | + $(grep --color=never "^Submitted .* external jobid" logfiles/snakemake.log \\ |
| 73 | + | awk '{{print $NF}}' \\ |
| 74 | + | sed "s/['.]//g" \\ |
| 75 | + | sort \\ |
| 76 | + | uniq \\ |
| 77 | + | tr "\\n" " " |
| 78 | + ) \\ |
| 79 | + > job_information_${{timestamp}}.tsv \\ |
| 80 | + || {{ |
| 81 | + # Handles edge case were only "rule all" |
| 82 | + # is run and no child jobs are submitted |
| 83 | + touch job_information_${{timestamp}}.tsv |
| 84 | + }} |
| 85 | +
|
| 86 | + # Get information on any child |
| 87 | + # job(s) that may have failed |
| 88 | + grep --color=never \\ |
| 89 | + '^jobid\\|FAILED' \\ |
| 90 | + job_information_${{timestamp}}.tsv \\ |
| 91 | + > failed_jobs_${{timestamp}}.tsv \\ |
| 92 | + || {{ |
| 93 | + # Handles edge case were only "rule all" |
| 94 | + # is run and no child jobs are submitted |
| 95 | + touch failed_jobs_${{timestamp}}.tsv |
| 96 | + }} |
| 97 | + touch FAILED |
| 98 | + """ |
| 99 | + ) |
0 commit comments