-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding pre- and post-processing hooks
- Loading branch information
1 parent
5ffd58c
commit a5ae210
Showing
2 changed files
with
835 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
# Adding handlers for displaying status of the | ||
# pipeline and for getting job information for | ||
# previously submitted jobs using `jobby`: | ||
# https://github.com/OpenOmics/scribble/blob/main/scripts/jobby/jobby | ||
if config['options']['mode'] == 'slurm': | ||
onstart: | ||
shell( | ||
""" | ||
# Move any job information for a previous | ||
# instance of the pipeline to logfiles | ||
sleep 5; rm -f COMPLETED FAILED RUNNING; | ||
touch RUNNING | ||
for f in job_information_*.tsv; do | ||
# Skip over non-existant files | ||
[ -e "${{f}}" ] || continue | ||
mv ${{f}} logfiles/; | ||
done | ||
for f in failed_jobs_*.tsv; do | ||
# Skip over non-existant files | ||
[ -e "${{f}}" ] || continue | ||
mv ${{f}} logfiles/; | ||
done | ||
""" | ||
) | ||
|
||
onsuccess: | ||
shell( | ||
""" | ||
# Get job information on all | ||
# previously submitted jobs | ||
sleep 15; rm -f COMPLETED FAILED RUNNING; | ||
timestamp=$(date +"%Y-%m-%d_%H-%M-%S"); | ||
./workflow/scripts/jobby \\ | ||
$(grep --color=never "^Submitted .* external jobid" logfiles/snakemake.log \\ | ||
| awk '{{print $NF}}' \\ | ||
| sed "s/['.]//g" \\ | ||
| sort \\ | ||
| uniq \\ | ||
| tr "\\n" " " | ||
) \\ | ||
> job_information_${{timestamp}}.tsv \\ | ||
|| {{ | ||
# Handles edge case were only "rule all" | ||
# is run and no child jobs are submitted | ||
touch job_information_${{timestamp}}.tsv | ||
}} | ||
# Get information on any child | ||
# job(s) that may have failed | ||
grep --color=never \\ | ||
'^jobid\\|FAILED' \\ | ||
job_information_${{timestamp}}.tsv \\ | ||
> failed_jobs_${{timestamp}}.tsv \\ | ||
|| {{ | ||
# Handles edge case were only "rule all" | ||
# is run and no child jobs are submitted | ||
touch failed_jobs_${{timestamp}}.tsv | ||
}} | ||
touch COMPLETED | ||
""" | ||
) | ||
|
||
onerror: | ||
shell( | ||
""" | ||
# Get job information on all | ||
# previously submitted jobs | ||
sleep 15; rm -f COMPLETED FAILED RUNNING; | ||
timestamp=$(date +"%Y-%m-%d_%H-%M-%S"); | ||
./workflow/scripts/jobby \\ | ||
$(grep --color=never "^Submitted .* external jobid" logfiles/snakemake.log \\ | ||
| awk '{{print $NF}}' \\ | ||
| sed "s/['.]//g" \\ | ||
| sort \\ | ||
| uniq \\ | ||
| tr "\\n" " " | ||
) \\ | ||
> job_information_${{timestamp}}.tsv \\ | ||
|| {{ | ||
# Handles edge case were only "rule all" | ||
# is run and no child jobs are submitted | ||
touch job_information_${{timestamp}}.tsv | ||
}} | ||
# Get information on any child | ||
# job(s) that may have failed | ||
grep --color=never \\ | ||
'^jobid\\|FAILED' \\ | ||
job_information_${{timestamp}}.tsv \\ | ||
> failed_jobs_${{timestamp}}.tsv \\ | ||
|| {{ | ||
# Handles edge case were only "rule all" | ||
# is run and no child jobs are submitted | ||
touch failed_jobs_${{timestamp}}.tsv | ||
}} | ||
touch FAILED | ||
""" | ||
) |
Oops, something went wrong.