Skip to content
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

Odd errors for named stdout output #5680

Open
njspix opened this issue Jan 17, 2025 · 3 comments
Open

Odd errors for named stdout output #5680

njspix opened this issue Jan 17, 2025 · 3 comments

Comments

@njspix
Copy link
Contributor

njspix commented Jan 17, 2025

Bug report

Expected behavior and actual behavior

Expected behavior: I should either be able to name a stdout output, or not
Actual: I can name a stdout output as long as it is part of a tuple, even if it's the only entry in the tuple

Steps to reproduce the problem

process sayHello {
    input:
        val number

    output:
        path("*.txt"), emit: test1
        tuple stdout, emit: test2

    script:
    """
        echo "Hello ${number}" | tee test_${number}.txt
    """
}

workflow {
    test = Channel.of(1, 2, 3)

    sayHello(test)
    sayHello.out.test2.view()
}

This runs sucessfully but produces a warning:
WARN: Output tuple must define at least two elements -- Check process sayHello

On the other hand, this will not run:

process sayHello {
    input:
        val number

    output:
        path("*.txt"), emit: test1
        stdout, emit: test2

    script:
    """
        echo "Hello ${number}" | tee test_${number}.txt
    """
}

workflow {
    test = Channel.of(1, 2, 3)

    sayHello(test)
    sayHello.out.test2.view()
}

Error:

ERROR ~ Script compilation error
- file : /varidata/research/projects/laird/nathan/projects/tmp/test.nf
- cause: Unexpected input: '{' @ line 1, column 18.
   process sayHello {

Environment

  • Nextflow version: 24.10.3.5933
  • Java version: openjdk 21-internal 2023-09-19
  • Operating system: Linux submit003 5.14.0-427.42.1.el9_4.x86_64 A process that define only an input of type 'each' never stops #1 SMP PREEMPT_DYNAMIC Thu Oct 31 14:01:51 UTC 2024 x86_64 GNU/Linux
  • Bash version: GNU bash, version 5.1.8(1)-release (x86_64-redhat-linux-gnu)

Additional context

Not sure if this a bug or a feature request. Thanks!

@bentsherman
Copy link
Member

You can think of stdout like a function call. Because there is no positional argument like there is for val or path, you don't need the comma before the emit option.

Also, I plopped this code into the VS Code extension (now with built-in language server) and it gave a better error message:

Image

The language server uses a more strict parser that will be integrated into Nextflow itself in the future, so you'll get the better error either way. Hope this clears things up

@njspix
Copy link
Contributor Author

njspix commented Jan 17, 2025

Thanks so much for clarifying! Is this noted anywhere in the docs?

@bentsherman
Copy link
Member

I think there is a note about it somewhere, don't remember

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants