nextflow-io / nextflow

A DSL for data-driven computational pipelines
http://nextflow.io
Apache License 2.0
2.75k stars 628 forks source link

Use of input repeaters ("each") in DSL2 #1966

Open birnbera opened 3 years ago

birnbera commented 3 years ago

Not sure I'm missing something super obvious, but is each supported in DSL2? The following doesn't work:

nextflow.enable.dsl=2

numbers = Channel.of(1, 2, 3)
letters = Channel.of('A', 'B')

process test {
    echo true

    input:
        each val(number)
        val(letter)

    script:
    """
    echo $number $letter
    """
}

workflow {
    test(numbers, letters)
}

I would have expected to see an output like (with possibly different order, etc):

1 A
2 A
3 A
1 B
2 B
3 B

Instead, I get:

N E X T F L O W  ~  version 20.07.1
Launching `test.nf` [tiny_davinci] - revision: f20ada7690
No such variable: number

 -- Check script 'test.nf' at line: 10 or see '.nextflow.log' file for more details

Here's the nextflow log:

Mar-11 22:24:41.226 [main] DEBUG nextflow.cli.Launcher - $> nextflow run test.nf
Mar-11 22:24:41.459 [main] INFO  nextflow.cli.CmdRun - N E X T F L O W  ~  version 20.07.1
Mar-11 22:24:41.475 [main] INFO  nextflow.cli.CmdRun - Launching `test.nf` [tiny_davinci] - revision: f20ada7690
Mar-11 22:24:41.497 [main] DEBUG nextflow.config.ConfigBuilder - Found config local: ####
Mar-11 22:24:41.498 [main] DEBUG nextflow.config.ConfigBuilder - Parsing config file: ####
Mar-11 22:24:41.526 [main] DEBUG nextflow.config.ConfigBuilder - Applying config profile: `standard`
Mar-11 22:24:42.024 [main] DEBUG nextflow.Session - Session uuid: d9ea5922-42be-42e0-ac92-4e043667b0c2
Mar-11 22:24:42.024 [main] DEBUG nextflow.Session - Run name: tiny_davinci
Mar-11 22:24:42.025 [main] DEBUG nextflow.Session - Executor pool size: 8
Mar-11 22:24:42.230 [main] DEBUG nextflow.cli.CmdRun - 
  Version: 20.07.1 build 5412
  Created: 24-07-2020 15:18 UTC 
  System: Linux 3.10.0-1127.19.1.el7.x86_64
  Runtime: Groovy 2.5.11 on OpenJDK 64-Bit Server VM 11.0.2+9
  Encoding: UTF-8 (UTF-8)
  Process: ####
  CPUs: 8 - Mem: 62 GB (12.3 GB) - Swap: 0 (0)
Mar-11 22:24:42.283 [main] DEBUG nextflow.Session - Work-dir: ####
Mar-11 22:24:42.351 [main] DEBUG nextflow.Session - Observer factory: TowerFactory
Mar-11 22:24:42.355 [main] DEBUG nextflow.Session - Observer factory: DefaultObserverFactory
Mar-11 22:24:42.716 [main] DEBUG nextflow.Session - Session start invoked
Mar-11 22:24:42.924 [main] DEBUG nextflow.script.ScriptRunner - > Launching execution
Mar-11 22:24:43.010 [main] DEBUG nextflow.Session - Workflow process names [dsl2]: test
Mar-11 22:24:43.074 [main] DEBUG nextflow.Session - Session aborted -- Cause: Unknown variable 'number'
Mar-11 22:24:43.087 [main] ERROR nextflow.cli.Launcher - @unknown
groovy.lang.MissingPropertyException: Unknown variable 'number'
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
    at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:80)
    at org.codehaus.groovy.reflection.CachedConstructor.doConstructorInvoke(CachedConstructor.java:74)
    at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrap.callConstructor(ConstructorSite.java:84)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:59)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:237)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:265)
    at nextflow.script.ProcessConfig.getProperty(ProcessConfig.groovy:273)
    at org.codehaus.groovy.runtime.InvokerHelper.getProperty(InvokerHelper.java:190)
    at groovy.lang.Closure.getPropertyTryThese(Closure.java:313)
    at groovy.lang.Closure.getPropertyDelegateFirst(Closure.java:303)
    at groovy.lang.Closure.getProperty(Closure.java:288)
    at org.codehaus.groovy.runtime.callsite.PogoGetPropertySite.getProperty(PogoGetPropertySite.java:49)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGroovyObjectGetProperty(AbstractCallSite.java:309)
    at Script_6d4d1d16$_runScript_closure1.doCall(Script_6d4d1d16:10)
    at Script_6d4d1d16$_runScript_closure1.doCall(Script_6d4d1d16)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:101)
    at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:323)
    at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:263)
    at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1041)
    at groovy.lang.Closure.call(Closure.java:405)
    at groovy.lang.Closure.call(Closure.java:399)
    at nextflow.script.ProcessDef.initialize(ProcessDef.groovy:111)
    at nextflow.script.ProcessDef.run(ProcessDef.groovy:165)
    at nextflow.script.BindableDef.invoke_a(BindableDef.groovy:52)
    at nextflow.script.ComponentDef.invoke_o(ComponentDef.groovy:41)
    at nextflow.script.WorkflowBinding.invokeMethod(WorkflowBinding.groovy:90)
    at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeOnDelegationObjects(ClosureMetaClass.java:397)
    at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:339)
    at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:64)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:51)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:156)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:176)
    at Script_6d4d1d16$_runScript_closure2$_closure4.doCall(Script_6d4d1d16:20)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:101)
    at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:323)
    at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:263)
    at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1041)
    at groovy.lang.Closure.call(Closure.java:405)
    at groovy.lang.Closure.call(Closure.java:399)
    at nextflow.script.WorkflowDef.run0(WorkflowDef.groovy:182)
    at nextflow.script.WorkflowDef.run(WorkflowDef.groovy:169)
    at nextflow.script.BindableDef.invoke_a(BindableDef.groovy:52)
    at nextflow.script.ChainableDef$invoke_a.call(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:115)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:127)
    at nextflow.script.BaseScript.runDsl2(BaseScript.groovy:191)
    at nextflow.script.BaseScript.run(BaseScript.groovy:200)
    at nextflow.script.ScriptParser.runScript(ScriptParser.groovy:219)
    at nextflow.script.ScriptRunner.run(ScriptRunner.groovy:219)
    at nextflow.script.ScriptRunner.execute(ScriptRunner.groovy:127)
    at nextflow.cli.CmdRun.run(CmdRun.groovy:274)
    at nextflow.cli.Launcher.run(Launcher.groovy:466)
    at nextflow.cli.Launcher.main(Launcher.groovy:648)
pditommaso commented 3 years ago

Kind of bug. Using each number works

birnbera commented 3 years ago

Great, thanks for that tip! As you say, it works if you leave off the val qualifier.

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.