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

Better handle error reporting for syntax errors #3325

Closed
pditommaso opened this issue Oct 28, 2022 · 5 comments · Fixed by #4122
Closed

Better handle error reporting for syntax errors #3325

pditommaso opened this issue Oct 28, 2022 · 5 comments · Fixed by #4122

Comments

@pditommaso
Copy link
Member

Bug report

When there's an in valid syntax the reported is intelligible. for example:

process foo {
  debug true:
  input: path x, 
  """
  echo "foo ${task..index} ${task.workDir}"
  """
}


workflow {
  foo() 
}
@pditommaso
Copy link
Member Author

See also #2082

@adkinsrs
Copy link

I encountered a similar syntax issue when using the "take" and "emit" parameters in the DSL2 syntax

My incorrect code snippet for the workflow was

workflow hisat2_build {
    // Only one input channel per "take" and one output channel per "emit"
    take: ref_fasta_file, hisat2_bin_dir
    main:
        run_hisat2_build(
            ref_fasta_file
            , hisat2_bin_dir
            )
    emit: run_hisat2_build.out.index, run_hisat2_build.out.prefix
}

... and this gave the Unexpected input { error as reported in #2082. This was quite baffling as the brackets did line up and I had no unmatched brackets elsewhere.

When I corrected the workflow by putting each "take" and "emit" parameter on their own lines, it resolved the issue, though the error message did not really indicate that was the underlying problem.

workflow hisat2_build {
    // Only one input channel per "take" and one output channel per "emit"
    take: ref_fasta_file
    take: hisat2_bin_dir
    main:
        run_hisat2_build(
            ref_fasta_file
            , hisat2_bin_dir
            )
    emit: run_hisat2_build.out.index
    emit: run_hisat2_build.out.prefix
}

(Off-topic, but the "Workflow" section of the "DSL2" documentation here does not give any examples of how to use "take" and "emit" for 2+ samples, so I had to do trial and error to figure that out)

@bentsherman
Copy link
Member

Hi @adkinsrs , I think you can specify multiple channels in a single take / emit, you just don't need to separate them with a comma.

@adkinsrs
Copy link

adkinsrs commented Nov 2, 2022

@bentsherman thanks for the heads up on that. I am still stumbling a bit with the syntax... when to use commas, colons, etc. and when not to.

UPDATE: Found out it works as

    take:
        ref_fasta_file
        hisat2_bin_dir

and not take: ref_fasta_file hisat2_bin_dir (which throws a "no such variable: hisat2_bin_dir" error)

@pditommaso pditommaso added this to the 23.04.0 milestone Nov 8, 2022
@ewels
Copy link
Member

ewels commented Mar 3, 2023

Note that using syntax highlighting at least helps a little here:

process foo {
  debug true:
  input: path x, 
  """
  echo "foo ${task..index} ${task.workDir}"
  """
}


workflow {
  foo() 
}

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

Successfully merging a pull request may close this issue.

4 participants