-
Notifications
You must be signed in to change notification settings - Fork 629
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
Config parsing error in 24.01.0-edge when using includeConfig
of assignment of function value
#4722
Comments
This kind of thing is not really supported in config files. If it ever works it is only by chance. I would try to find a different approach. One idea I had was that we could import the |
You can always embed the code directly where you are using it. For example, rewriting the second function as an expression: [
"asm5": "-P 1,19,39,3,81,1",
"asm10": "-P 1,9,16,2,41,1",
"asm15": "-P 1,7,11,2,33,1",
"asm20": "-P 1,4,6,2,26,1"
][params.smoothxg_poa_params] ?: "-P ${params.smoothxg_poa_params}" |
While this may work for this simple function I would not have any idea how to do it for the more complex one. |
I think you can inline the closure in the function call {
def wfmash_sparse_map_cmd = ""
if (params.wfmash_sparse_map == "auto") {
def n = params.n_haplotypes
def x = Math.log(n)/n * 10
wfmash_sparse_map_frac = 1
if (x < 1) {
def wfmash_sparse_map_frac = x
}
wfmash_sparse_map_cmd = "-x ${wfmash_sparse_map_frac}"
} else {
if (params.wfmash_sparse_map != null) {
wfmash_sparse_map_cmd = "-x ${params.wfmash_sparse_map}"
}
}
return wfmash_sparse_map_cmd
}() |
What may be simpler for users is that functions can be replaced with closures and be called in a similar way. workflow {
TASK( [ id: 'Susi' ] )
| view
}
process TASK {
input:
val meta
script:
def args = task.ext.args?: 'No message'
"""
echo $args
"""
output:
stdout
}
Using a custom scope could also help group the closures, but it's not necessary. |
I think the best solution is still to define these functions in the |
From a best practice point of view I agree. |
Bug report
Expected behavior and actual behavior
The expected behaviour is that nextflow should run and not throw an error.
The actual behaviour is that nextflow throws an error.
Steps to reproduce the problem
main.nf:
nextflow.config:
includeConfig 'test.config'
test.config:
Program output
Environment
Additional context
If the function is moved to the
nextflow.config
there is no problem, however when included viaincludeConfig
and assigned to a variable outside a scope, it produces the above error.The related Slack thread where this was discovered: https://nextflow.slack.com/archives/C02T98A23U7/p1707390130895379
The text was updated successfully, but these errors were encountered: