- 
                Notifications
    You must be signed in to change notification settings 
- Fork 201
feat: allow setting launchDir in params #4638
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
|  | @@ -44,15 +44,18 @@ rule chipseq_pipeline: | |
| gtf="data/genome.gtf", | ||
| # any --<argname> pipeline file arguments can be given here as <argname>=<path> | ||
| output: | ||
| "results/multiqc/broadPeak/multiqc_report.html", | ||
| multiqc_report="results/multiqc/broadPeak/multiqc_report.html", | ||
| # directory from which nextflow is launched, will contain the `.nextflow` directory | ||
| launch_dir=directory("some_directory"), | ||
| params: | ||
| pipeline="nf-core/chipseq", | ||
| revision="2.0.0", | ||
| profile=["test", "docker"], | ||
| launch_dir=lambda wildcards, output: output.launch_dir, | ||
| # The chosen pipeline expects an --outdir to be given. | ||
| # We infer this from the output file path. Since that file path can be changed | ||
| # e.g. in case of cloud storage, we use a lambda function to infer the outdir. | ||
| outdir=lambda wildcards, output: str(Path(output[0]).parents[-2]), | ||
| outdir=lambda wildcards, output: str(Path(output.multiqc_report).parents[-2]), | ||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chainVerify the outdir calculation after path resolution changes. The calculation  
 Run this script to check how the wrapper handles params that contain paths: 🏁 Script executed: #!/bin/bash
# Description: Check if outdir and other path params are handled correctly after chdir
# Look for param handling around the chdir operation
rg -A 15 -B 5 'snakemake\.params' utils/nextflow/wrapper.pyLength of output: 1277 🏁 Script executed: #!/bin/bash
# Locate add_parameter definition and inspect its behavior
rg -n 'def add_parameter' -A5 utils/nextflow/wrapper.pyLength of output: 0 🏁 Script executed: #!/bin/bash
# Search for add_parameter definition and usage across the repo
rg -n "add_parameter" -n .Length of output: 237 Make  🤖 Prompt for AI Agents | ||
| # any --<argname> pipeline arguments can be given here as <argname>=<value> | ||
| handover: True | ||
| wrapper: | ||
|  | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
Semantically,
launch_dirshould not be an output.Declaring
launch_diras adirectory()output is semantically incorrect. Snakemake outputs are artifacts produced by the rule, butlaunch_diris merely a working directory where Nextflow runs. The.nextflowdirectory created inside it is the actual artifact.Additionally, since the wrapper changes the working directory to
launch_dirbefore running Nextflow, all relative paths (inputs, outputs, and theoutdirparam) will be resolved relative tosome_directoryinstead of the Snakemake working directory. This means:output.multiqc_reportdeclared as"results/multiqc/broadPeak/multiqc_report.html"will be created at"some_directory/results/multiqc/broadPeak/multiqc_report.html""results/multiqc/broadPeak/multiqc_report.html"(relative to the Snakemake working directory)Consider these alternatives:
Option 1: Pre-create the directory and pass it as a param
output: multiqc_report="results/multiqc/broadPeak/multiqc_report.html", - # directory from which nextflow is launched, will contain the `.nextflow` directory - launch_dir=directory("some_directory"), params: pipeline="nf-core/chipseq", revision="2.0.0", profile=["test", "docker"], - launch_dir=lambda wildcards, output: output.launch_dir, + launch_dir="some_directory",Then add a rule to create the directory before running the test:
Option 2: Make the wrapper convert paths to absolute before chdir
The wrapper should resolve all Snakemake input/output/params paths to absolute paths before changing directories, ensuring they remain valid after the
chdir.Run this script to verify whether the current implementation handles path resolution correctly:
🏁 Script executed:
Length of output: 263
Remove
launch_dirfrom outputs and resolve paths beforechdirlaunch_diris not a produced artifact and must be aparam(or pre-created by a separate rule), not adirectory()output.os.chdir(launch_dir)without converting Snakemake inputs/outputs (e.g."results/…/multiqc_report.html") to absolute paths, so the rule will write files undersome_directory/…and Snakemake won’t find them.some_directoryin a preparatory rule and passing it as a simple param, oros.path.abspath(...)before performingos.chdir.🤖 Prompt for AI Agents