diff --git a/CHANGELOG.md b/CHANGELOG.md index ee73188..a88e028 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## CRISPIN development version - CRISPIN is now archived in Zenodo as v1.0.0. You can cite it with . (@kelly-sovacool) +- Fix bug in spooker handler. (#49, @kelly-sovacool) ## CRISPIN 1.0.0 diff --git a/bin/crispin b/bin/crispin new file mode 100755 index 0000000..8fcdf75 --- /dev/null +++ b/bin/crispin @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +TOOLDIR=$(realpath $(dirname $(dirname ${BASH_SOURCE}))) + +${TOOLDIR}/main.py "$@" diff --git a/lib/Utils.groovy b/lib/Utils.groovy index db78a83..acae2da 100644 --- a/lib/Utils.groovy +++ b/lib/Utils.groovy @@ -1,8 +1,7 @@ class Utils { // run spooker for the workflow - public static String spooker(workflow) { - def pipeline_name = "${workflow.manifest.name.tokenize('/')[-1]}" - def command_string = "spooker ${workflow.launchDir} ${pipeline_name}" + public static String spooker(launch_dir, pipeline_name) { + def command_string = "spooker ${launch_dir} ${pipeline_name}" def out = new StringBuilder() def err = new StringBuilder() try { @@ -12,7 +11,7 @@ class Utils { } catch(IOException e) { err = e } - new FileWriter("${workflow.launchDir}/log/spooker.log").with { + new FileWriter("${launch_dir}/log/spooker.log").with { write("${out}\n${err}") flush() } diff --git a/main.nf b/main.nf index b2d4d30..602266c 100644 --- a/main.nf +++ b/main.nf @@ -27,8 +27,10 @@ include { DRUGZ } from './modules/local/drugz.nf' workflow.onComplete { if (!workflow.stubRun && !workflow.commandLine.contains('-preview')) { - println "Running spooker" - def message = Utils.spooker(workflow) + def pipeline_name = "${workflow.manifest.name.tokenize('/')[-1]}" + def launch_dir = "${workflow.launchDir}" + println "Running: spooker $launch_dir $pipeline_name" + def message = Utils.spooker(launch_dir, pipeline_name) if (message) { println message } diff --git a/main.py b/main.py new file mode 100755 index 0000000..2b8c3f7 --- /dev/null +++ b/main.py @@ -0,0 +1,16 @@ +#!/usr/bin/env python +import os +import re +import sys + +# add script directory to the path to allow champagne CLI to work out-of-the-box +# without the need to install it via pip first +SCRIPT_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), "src") +sys.path.append(SCRIPT_DIR) +from src.__main__ import main + +if ( + __name__ == "__main__" +): # this block is adapted from the executable file created by `pip install` + sys.argv[0] = re.sub(r"(-script\.pyw|\.exe)?$", "", sys.argv[0]) + sys.exit(main())