-
Notifications
You must be signed in to change notification settings - Fork 667
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
load any nextflow.config that is at the same level as a .nf #4205
Comments
Nextflow currently does the following:
So the configuration is already resolved when the script is executed, but modules are loaded during script execution... I guess the idea here is that module config should only apply to the module script. When loading a module, maybe we could create a temporary "augmented config" which includes the config from (1) plus the module config. However, most config scopes apply to the entire workflow, so I think a module config would only make sense to use the |
the idea would be to be able to ship altogether config, script and test for a given module, subworkflow or even pipeline in the long term along the lines... |
Can you give an example of what such a config would look like, so that we can see which scopes you are using? |
I'm thinking just to deal with the ext directives and publishdir, so something like: https://github.com/nf-core/sarek/blob/master/conf/modules/aligner.config |
In @maxulysse's example, I would separate each of those withLabel selectors into an individual nextflow.config file:
If you wanted to re-use a process, you could use the withName/withLabel selector. So the contents might be (pretending
p.s I know the example is rubbish. Scoping might be tricky. |
We are trying to standardise the way we pass configuration around nf-core pipelines for modules / subworkflows / workflows. At the moment, we have a An example of a proposed structure for modules / subworkflows / workflows if we are able to ship a
The modules / subworkflows / workflows |
Here me out...how about a config context? process MYPROCESS {
...
}
workflow MYWORKFLOW {
...
}
config {
...
}
// later, in a file far, far away...
include { MYPROCESS } from workflows/myworkflow.nf
// auto imports the config in the same file. |
The example config given by Maxime only has process config, so why can't these settings just be process directives in the module? |
You mean include process selectors in the module along with the actual process definition? Sorry, didn't quite understand. |
I think he means inline process BWAMEM2_MEM {
publishDir = [
mode: params.publish_dir_mode,
path: { "${params.outdir}/preprocessing/" },
pattern: "*bam",
// Only save if (save_mapped OR (no_markduplicates AND save_output_as_bam)) AND only a single BAM file per sample
saveAs: { (params.save_output_as_bam && (params.save_mapped || params.skip_tools && params.skip_tools.split(',').contains('markduplicates'))) && (meta.size * meta.num_lanes == 1) ? "mapped/${meta.id}/${it}" : null }
]
// container etc..
input:
// ...
} But my problem with this, and also with the idea of shipping a I feel like I'm missing a key point here.. |
Don't think we should keep the publishing logic in the process definition as this will need to be updated in instances where the same module is being used in multiple subworkflows. This would just be a "vanilla" configuration that is shipped with the module / subworkflow / workflow that would have sensible publishing and additional logic to determine how to run that particular component. We could then even have an additional command that patches the config much like Additionally, this means we won't need a massive Config is instead shipped with each component, changed if required and most importantly packaged with the NF scripts to make it easier to share. But to add to that, the config shipped with NF script should have lower precedence than the pipeline-level config just in case developers want to override it. |
Ok cool, yeah that makes sense to me - have a default config to ship with the module and then the pipeline dev edits it as required via patching functionality. I imagine it'll largely be addition of lines rather than editing existing ones, so shouldn't be too difficult. So @bentsherman I think it's a question of config parsing priority. Anything defined directly within |
Yeah, the precedence will need some thought in terms of hierarchy. The vanilla config from a module should be able to be overwritten by the vanilla config from a subworkflow should be able to be overwritten by the vanilla config from a workflow should be able to be overwritten by the pipeline config. |
This seems backwards from the usual hierarchy, usually the more specific configs override the less specific configs. What if we extend the |
Yeah I was wondering this as well - whether we could have a whole load of |
Not sure it would be that straightforward. This might warrant a proper brainstorming session! I'll set something up. Also, that would only work with those using nf-core tooling and not the rest of the NF community. |
See #4112 , we are thinking about adding a |
How about we just try to kill off module-level config as much as possible, instead of coming up with a new way to ship a default config? So for example, taking a typical block and dissecting it line by line: ext.args = '--keep-exon-attrs -F -T'
publishDir = [
path: { "${params.outdir}/genome" },
mode: params.publish_dir_mode,
saveAs: { filename -> filename.equals('versions.yml') ? null : filename },
enabled: params.save_reference
]
So a pseudo-code final state could look something like this:
process {
publishDirMode = "copy"
publishBaseDir = params.outdir
}
withName: 'UNTAR_.*' {
ext.args = '--keep-exon-attrs -F -T'
ext.publish = params.save_reference
}
process GFFREAD {
publish task.ext.publish
publishPath "genome"
// ...
output:
path "*.gtf" , emit: gtf, publish: false
path "versions.yml" , emit: versions
// ...
} |
not sure I agree with you on the first point, but I like where all of this is going |
First point being "kill off module-level config"? Yes that was maybe a little strong. "Remove duplicated / boilerplate code" perhaps.. |
I think both are needed. I mean it makes sense a rethinking the At the same time it's desirable to have a |
I'm trying to split the Which is actually why I was requesting this feature, and why we want it in a reverse order. |
Closing in favor of #4422 |
New feature
load any nextflow.config that is at the same level as a .nf
Usage scenario
It would greatly help the re-usability and share-ability of nf-core modules/subworkflows.
Suggest implementation
Basically similarly to what we're already doing for script templates and bin scripts
EDIT : added a suggest implementation
The text was updated successfully, but these errors were encountered: