-
Notifications
You must be signed in to change notification settings - Fork 735
Default values for process inputs #3687
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
Conversation
Signed-off-by: Ben Sherman <[email protected]>
This is a good start. If I understand it correctly it works at the level of the process composition ie if the argument is provided matches the ones expected. But I think there are use cases in which the argument is provided, but the associated channel brings no value (or null). A classic example may be this |
I think the case of a null value could be handled with a separate If the channel is empty, then the user can use |
In #3714 it is noted that
Is that really a necessary constraint to have? And what does "useless" actually mean on a technical level? It is not quite clear to me from reading through this and the other issue. |
@fabianegli see the docs example I added in this PR for a more detailed explanation. If your process declares an input B with no default value, after an input A with a default value, then you will always have to give a value for A when you call the process, because B comes after A. Thus the default value for A is useless because it can never be used. I think the caveat effectively goes away if combined with named inputs, because then you can specify the inputs in any order when you call the process. |
I understand the restriction an I am wondering what purpose it might serve. And my point is that I can't think of any situation I'd actually want it. If the defaults are introduced with named inputs, which removes this restriction I see this as something which might surprise some pipeline/module devs rather than a problem. |
Not sure what you mean. It's not an artificial restriction that we impose, it's a natural consequence of how arguments are passed in a function call. Most languages that support default values in function calls have this same limitation -- C++, Java, Python, etc. Also, I guess I should say that named arguments don't "remove" the restriction so much as they provide a workaround by allowing you to order arguments however you like. |
My questioning was aimed to find out wether this behaviour is desirable in this case - irrespective of wether it is introduced intentionally or not. The fact that it is prevalent in other languages seems to hint at it being sensible for some reasons that I am missing. As you say, in some cases it would allow a more organized workflows/processes definition by grouping related inputs independently of wether they have defaults or not. Because the named arguments already make arbitrary input orderings possible, I am not convinced that the effort to remove the order constraint would be worthwhile. |
0d59b4c
to
b93634e
Compare
Signed-off-by: Paolo Di Tommaso <[email protected]>
Signed-off-by: Ben Sherman <[email protected]>
81f7cb7
to
8a43489
Compare
Gonna fold this one into #4553 doing something like this: process foo {
input:
List<Path> inputs
String args = '--default-option'
output:
stdout
script:
"""
foo_cmd ${args} ${inputs}
"""
}
workflow {
foo( file('*.foo') )
} |
Implements default values for process inputs as requested in #3507
While we could merge this feature as is, I'd like to try to implement optional and named inputs as well, to make sure that they are designed to work together properly.