Workflow inputs are always channels by definition. If a basic data type, such as a number, string, list, etc, is provided, it is implicitly converted to a value channel.
However, passing a class as input to a workflow does not implicitly convert it to a channel. Emitting it does.
Expected behavior and actual behavior
When calling println(x.getClass()) where x was a class Foo passed as a workflow input, it would display class groovyx.gpars.dataflow.DataflowBroadcast but it displays class Foo instead.
Steps to reproduce the problem
class Foo {}
workflow sub {
take:
foo
main:
println(foo.getClass())
}
workflow {
foo = new Foo()
sub(foo)
}
Program output
N E X T F L O W ~ version 23.10.1
Launching demo.nf [trusting_baekeland] DSL2 - revision: f032671f38
class Foo
Environment
Nextflow version: 23.10.1
Java version: openjdk version "20.0.2-internal" 2023-07-18
Operating system: Ubuntu Jammy Jellyfish
Bash version: GNU bash, version 5.1.16(1)-release (x86_64-pc-linux-gnu)
Additional context
Personally, I think it's the right choice not to implicitly convert anything to a channel in the input or output, but given that Nextflow does convert outputs to a channel, it should probably continue doing so. So the current behavior is only a "bug" in that it doesn't match the documentation. I'd prefer to change the documentation to match current behavior, not the other way around.
If it were easy to extract the class instance from a value channel and use it as a class in the logic of the subworkflow, that would be OK too. Otherwise, such implicit conversions take away a substantial form of control from the writer of the code, create problems by accident when users don't notice this note, and are only helpful to users who do understand this point as minor occasional syntactic sugar.
I believe this was corrected a while ago, the "latest" docs are just lagging behind. This will be addressed soon so that the "latest" docs are updated nightly instead of twice yearly
Bug report
The nextflow documentation says:
However, passing a class as input to a workflow does not implicitly convert it to a channel. Emitting it does.
Expected behavior and actual behavior
When calling println(x.getClass()) where x was a
class Foo
passed as a workflow input, it would displayclass groovyx.gpars.dataflow.DataflowBroadcast
but it displaysclass Foo
instead.Steps to reproduce the problem
Program output
N E X T F L O W ~ version 23.10.1 Launching
demo.nf
[trusting_baekeland] DSL2 - revision: f032671f38 class FooEnvironment
Additional context
Personally, I think it's the right choice not to implicitly convert anything to a channel in the input or output, but given that Nextflow does convert outputs to a channel, it should probably continue doing so. So the current behavior is only a "bug" in that it doesn't match the documentation. I'd prefer to change the documentation to match current behavior, not the other way around.
If it were easy to extract the class instance from a value channel and use it as a class in the logic of the subworkflow, that would be OK too. Otherwise, such implicit conversions take away a substantial form of control from the writer of the code, create problems by accident when users don't notice this note, and are only helpful to users who do understand this point as minor occasional syntactic sugar.