Skip to content

Commit

Permalink
Merge pull request #49 from CCBR/fix-spooker
Browse files Browse the repository at this point in the history
fix spooker call: parse workflow attributes outside groovy function
  • Loading branch information
kelly-sovacool authored Oct 16, 2024
2 parents 18e9f79 + 77168a1 commit 17fd6a5
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## CRISPIN development version

- CRISPIN is now archived in Zenodo as v1.0.0. You can cite it with <https://doi.org/10.5281/zenodo.13844209>. (@kelly-sovacool)
- Fix bug in spooker handler. (#49, @kelly-sovacool)

## CRISPIN 1.0.0

Expand Down
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
6 changes: 4 additions & 2 deletions main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
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 17fd6a5

Please sign in to comment.