Skip to content

Commit

Permalink
fix: parse workflow attributes outside groovy function
Browse files Browse the repository at this point in the history
  • Loading branch information
kelly-sovacool committed Oct 16, 2024
1 parent 18e9f79 commit f5ed7c9
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 5 deletions.
5 changes: 5 additions & 0 deletions bin/crispin
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

TOOLDIR=$(realpath $(dirname $(dirname ${BASH_SOURCE})))

${TOOLDIR}/main.py "$@"
7 changes: 3 additions & 4 deletions lib/Utils.groovy
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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()
}
Expand Down
4 changes: 3 additions & 1 deletion main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
16 changes: 16 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
@@ -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())

0 comments on commit f5ed7c9

Please sign in to comment.