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

Invalid Mermaid DAG with nested workflows #5843

Open
kdesnos opened this issue Mar 4, 2025 · 3 comments
Open

Invalid Mermaid DAG with nested workflows #5843

kdesnos opened this issue Mar 4, 2025 · 3 comments

Comments

@kdesnos
Copy link

kdesnos commented Mar 4, 2025

Bug report

Expected behavior and actual behavior

When using nested hierarchical workflow with more than 2 levels of hierarchy, in case where a workflow is instantiated several times below the first level of hierarchy, without any aliasing of the workflow name, the exported DAG with mermaid does not reflect the nextflow dag.

Steps to reproduce the problem

Consider the following MWE, where the sub_sub workflow is instantiated twice by two different sub_x workflows in the top level workflow.

process a {

    output:
        stdout

    script: 
    """
        echo "I'm a process"
    """
}

workflow sub_sub {
    a()
}

workflow sub_2 {
    sub_sub()
}

workflow sub_1 {
    sub_sub()
}

workflow {
    sub_1()
    sub_2()
}

Program output

The exported mermaid graph has the following code:

flowchart TB
    subgraph sub_1
    subgraph sub_sub
    v0([a])
    end
    end
    subgraph " "
    v1["-"]
    v3["-"]
    end
    subgraph sub_2
    subgraph sub_sub
    v2([a])
    end
    end
    v0 --> v1
    v2 --> v3

Which seems fine on paper. Unfortunately, mermaid can have a unique subgraph with name sub_sub, and as a result, when displaying the graph, two instances of a are displayed within sub_1::sub_sub, while the subgraph of sub_2 remains empty.

Image

Environment

  • Nextflow version: 24.10.4
  • Java version: openjdk 11.0.20 2023-07-18
  • Operating system: Linux
    • Bash version: GNU bash, version 5.1.8(1)-release (x86_64-redhat-linux-gnu)
@kdesnos kdesnos changed the title Invalid Mermaid DAG with nested workflow Invalid Mermaid DAG with nested workflows Mar 4, 2025
@bentsherman
Copy link
Member

Good catch. From the Mermaid docs it looks like subgraphs can have a separate id and title:

flowchart TB
    c1-->a2
    subgraph ide1 [one]
    a1-->a2
    end

@kdesnos
Copy link
Author

kdesnos commented Mar 5, 2025

Thanks.
As a side note, the issue might have some weird additional side effect on the generated DAG, creating cycles in the exported graph.
I can't (yet) get at the exact cause with a MWE, though. For some reason the vertex of a channel operator within the sub-sub-workflow is not duplicated when exporting the mermaid graph. As a result, a weird cyclic data dependency appears in the exported MERMAID graph, but seems absent from the dot export.

@kdesnos
Copy link
Author

kdesnos commented Mar 5, 2025

I was finally able to create a MWE for the second issue in #5855

kdesnos added a commit to kdesnos/nextflow that referenced this issue Mar 7, 2025
kdesnos added a commit to kdesnos/nextflow that referenced this issue Mar 7, 2025
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