Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix spooker call: parse workflow attributes outside groovy function #49

Merged
merged 3 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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())
Loading