Skip to content

Conversation

bentsherman
Copy link
Member

@bentsherman bentsherman commented Aug 2, 2025

This PR adds the check for duplicate process/workflow calls to the strict syntax.

Currently the check is performed at runtime:

if( this instanceof ProcessDef && !invocations.add(fqName) ) {
log.debug "Bindable invocations=$invocations"
final msg = "Process '$name' has been already used -- If you need to reuse the same component, include it with a different name or include it in a different workflow context"
throw new DuplicateProcessInvocation(msg)
}

With the strict syntax, we can now catch this error much earlier at compile-time.

It looks like the runtime check only applies to duplicate process calls. There is no equivalent check for duplicate workflow calls, but I believe there should be, since duplicate workflows would lead to processes with the same fully-qualified name.

@bentsherman bentsherman requested a review from pditommaso August 2, 2025 15:41
@bentsherman bentsherman requested a review from a team as a code owner August 2, 2025 15:41
Copy link

netlify bot commented Aug 2, 2025

Deploy Preview for nextflow-docs-staging canceled.

Name Link
🔨 Latest commit 6f6a4cd
🔍 Latest deploy log https://app.netlify.com/projects/nextflow-docs-staging/deploys/688e31b721414400087b875b

@bentsherman bentsherman added this to the 25.10 milestone Aug 21, 2025
@bentsherman bentsherman requested review from jorgee and removed request for pditommaso September 2, 2025 12:07
@jorgee
Copy link
Contributor

jorgee commented Sep 4, 2025

I have seen it is just checking if the process has been visited before in the workflow. In cases where the process is called inside an if-else statement, it will produce an error and it should be valid.
The following workflow should be valid and it is getting an error (If I correctly tested it)

nextflow.enable.strict=true
params.a = 1
process hello {
                script:
                """
                echo hello
                """
}
workflow {
      if (params.a == 1){
                hello()
      }else{
                hello()
      }
}

When running with the PR:

$ NXF_SYNTAX_PARSER=v2 ./launch.sh run a.nf

 N E X T F L O W   ~  version 25.06.0-edge

Launching `a.nf` [thirsty_lalande] DSL2 - revision: bb1409e71b

Error a.nf:13:3: Process `hello` cannot be called more than once in the same workflow -- use an alias instead
│  13 | 		hello()
╰     |   ^^^^^^^


ERROR ~ Script compilation failed

With the latest edge is working

$ NXF_VER=25.07.0-edge NXF_SYNTAX_PARSER=v2 nextflow run a.nf

 N E X T F L O W   ~  version 25.07.0-edge

Launching `a.nf` [small_hoover] DSL2 - revision: bb1409e71b

executor >  local (1)
[29/7a91f4] hello | 1 of 1 ✔

@bentsherman bentsherman removed this from the 25.10 milestone Sep 4, 2025
@bentsherman
Copy link
Member Author

Good catch. I would need to implement some live-variable analysis to do this properly in static analysis. Not worth doing right now. Thanks for testing

@bentsherman bentsherman closed this Sep 4, 2025
@bentsherman bentsherman deleted the check-duplicate-process-workflow-calls branch September 4, 2025 18:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants