Skip to content

Added intermediate for the takes and emits for the subworkflow nodes - #151

Open
George-Marchment wants to merge 6 commits into
nextflow-io:mainfrom
George-Marchment:main
Open

George-Marchment wants to merge 6 commits into
nextflow-io:mainfrom
George-Marchment:main

Conversation

@George-Marchment

Copy link
Copy Markdown

These are the functionctionnalities i've added

  • Adding intermediate nodes for the takes and emits (where possible) to the subworkflow nodes (called inputs and outputs)
  • Added a Hash map to the DataflowVisitor which stores the values of the conditions when they are visited
  • Added a globalNodes attribute to DataflowVisitor to store all the nodes added (this needs to be done to add the intermediate nodes before and after the subworkflows).

George-Marchment and others added 6 commits December 3, 2025 15:51
Add/remove methods in shim types
Add an opt-in expandWorkflowCalls flag to DataflowVisitor, which
expands each subworkflow call into a take node per argument, the call
node, and an emit node per emit. Emit nodes are tracked per call, so
FOO.out.x resolves to the emit of the call currently bound to FOO.

Label control nodes with the source text of their condition, read from
the compiled source unit.

Based on the work of George Marchment in nextflow-io#151.
Supersede the original implementation with the rewrite on current main.
@bentsherman

bentsherman commented Oct 27, 2026 •

Copy link
Copy Markdown
Member

Thanks George! The language server core was rewritten since this PR was opened (ScriptAstCache no longer exists and DataflowVisitor now works on a ScriptView), so I've reimplemented the idea on top of current main and pushed it here. I merged your branch with the ours strategy rather than force-pushing, so your commits are kept in the history, but the diff is now just the rewrite.

What changed

Expanding subworkflow calls into take and emit nodes

  • DataflowVisitor has an opt-in expandWorkflowCalls constructor flag. When it's off, the output is unchanged; the existing constructor and the previewDag command still use false.
  • When it's on, each subworkflow call (FOO(a, b) or a | FOO) becomes:
    • one take:<name> node (INPUT) per argument;
    • the FOO call node;
    • one emit:<name> node (OUTPUT) per emit.
  • Emit nodes are tracked per call node instead of through a global label map. FOO.out.x therefore resolves to the emit of the call currently bound to FOO, so two subworkflows emitting the same name, or two calls to the same subworkflow, no longer collide.
  • Emit names are no longer bound as variables.
  • Arguments beyond the take count are connected to the call node instead of being dropped.
  • A bare FOO.out connects to the emit node when there is exactly one emit.
  • If no emit node is found, it falls back to the previous behavior rather than adding a null predecessor.
  • Process calls are never expanded.
  • In Mermaid, INPUT and OUTPUT nodes are drawn as v<id>("<label>").

Condition text

  • Control nodes from if/else and ternary expressions now carry the condition's source text as their label. For an if, the outer parentheses are removed.
  • The text is read from the compiled SourceUnit, not from disk, so it reflects unsaved editor text and doesn't depend on a file URI.
  • This replaces the separate controlConditions map and the cache plumbing. Mermaid still draws control nodes as { }.

Tests

  • DataflowVisitorTest adds 17 tests. They cover the take/emit wiring, emits staying separate across subworkflows and across repeated calls, the pipe form, bare .out, process calls, the flag-off case, Mermaid rendering, and condition labels, including one test that the label comes from the open document rather than the file on disk.
  • The full suite passes.

@bentsherman
bentsherman changed the base branch from main to STABLE-26.04.x October 27, 2026 17:29
@bentsherman
bentsherman changed the base branch from STABLE-26.04.x to main October 27, 2026 17:29
@bentsherman

Copy link
Copy Markdown
Member

Parking until we can test a full vs code <-> metromap integration, so that I can better understand what is required in the DAG

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