From f5ed7c96a5b530ed42348458cfff9990a9fa769d Mon Sep 17 00:00:00 2001 From: Kelly Sovacool Date: Wed, 16 Oct 2024 12:00:31 -0400 Subject: [PATCH 1/3] fix: parse workflow attributes outside groovy function --- bin/crispin | 5 +++++ lib/Utils.groovy | 7 +++---- main.nf | 4 +++- main.py | 16 ++++++++++++++++ 4 files changed, 27 insertions(+), 5 deletions(-) create mode 100755 bin/crispin create mode 100755 main.py 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..f808523 100644 --- a/main.nf +++ b/main.nf @@ -28,7 +28,9 @@ 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}" + 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()) From 8f8ef6b44093718a9c65c5b70f821d2811a5ae53 Mon Sep 17 00:00:00 2001 From: Kelly Sovacool Date: Wed, 16 Oct 2024 14:19:37 -0400 Subject: [PATCH 2/3] chore: update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) 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 From 77168a158dc15836d87931e1154694a222109ec4 Mon Sep 17 00:00:00 2001 From: Kelly Sovacool Date: Wed, 16 Oct 2024 14:24:06 -0400 Subject: [PATCH 3/3] style: print spooker command --- main.nf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.nf b/main.nf index f808523..602266c 100644 --- a/main.nf +++ b/main.nf @@ -27,9 +27,9 @@ include { DRUGZ } from './modules/local/drugz.nf' workflow.onComplete { if (!workflow.stubRun && !workflow.commandLine.contains('-preview')) { - println "Running spooker" 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