Skip to content

refactor: draw a compiled workflow after compiling, and draw the wic: graphviz: keys again - #516

Merged
vjaganat90 merged 5 commits into
PolusAI:masterfrom
vjaganat90:refactor/drawing-is-a-projection
Oct 13, 2026
Merged

vjaganat90 merged 5 commits into
PolusAI:masterfrom
vjaganat90:refactor/drawing-is-a-projection

Conversation

@vjaganat90

@vjaganat90 vjaganat90 commented Oct 6, 2026 •

Copy link
Copy Markdown
Member

What

  • Drawing is a projection that runs after compiling: sophios.drawing.draw(compiled, bundle, settings, name) builds the DOT, and compile_source no longer takes graph settings or a drawing target. GraphReps, GraphData, graph_view, utils_graphs.py and _project_graph are gone, and networkx is a test dependency only.
  • The wic: graphviz: keys are drawn again.
    • label: replaces a step's label and titles a subworkflow's cluster; a cluster with no label is titled with the call's name.
    • style: appended to a step's style and applied to a cluster; invis on a subworkflow also hides its call box.
    • ranksame: groups the named steps, at any depth.
    • An entry that names no step is reported like a stale wic: steps: key.
    • --graph_label_stepname wins over a sidecar label.
  • The --graph_label_stepname help and the --graph_inline_depth description say what the code does.

Why
Drawing was threaded through compilation, and the refactors that removed its helpers silently stopped drawing the sidecar keys that mm-workflows uses in about 50 files. Emitted CWL is unchanged.

Stacked on #515.

@vjaganat90
vjaganat90 force-pushed the refactor/drawing-is-a-projection branch 7 times, most recently from 30bc959 to 76a82ba Compare October 8, 2026 06:47
@vjaganat90
vjaganat90 force-pushed the refactor/drawing-is-a-projection branch 6 times, most recently from 9d3587d to 1dd9108 Compare October 13, 2026 15:50

@darkclad darkclad left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The projection reads well: compiling no longer carries drawing state, and the sidecar keys follow Resolve's addressing, so a (index, name) key and a bare id behave the same as under wic: steps:. One finding is inline: two calls to the same subworkflow share a cluster name, which lets one call's graphviz: label and style overwrite the other's.

I ran tests/core at cb12fb1 and at its base, 8317619. The same 77 tests fail on both, all environmental (Docker or cwltool runs on Windows), and the head passes 15 more.

Nit: the description ends with "Stacked on #515.", but #515 is merged; this PR is stacked on #531 only.

Comment thread src/sophios/drawing.py Outdated
workflow it calls as a cluster of its own, down to `--graph_inline_depth`."""
sidecar = sidecars[graph.namespace]
look = graphviz_entry(sidecar)
cluster = graphviz.Digraph(name=f'cluster_{graph.name}')

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two calls to the same subworkflow draw two clusters with the same DOT name. With - id: sub.wic twice, both are subgraph cluster_sub_f2e0504b. Graphviz treats a repeated subgraph name as the same subgraph, so both calls' steps land in one cluster and the last call's label and style win. If the wic: steps: entry for (2, sub.wic) sets graphviz: {style: invis}, the first call's steps are hidden too, and the label on (1, sub.wic) is lost.

The shared name predates this PR, but it did no harm until clusters carried a label and style for each call. Naming a child cluster after the step that calls it, the way nodes are named (docs/dev/algorithms.md), would keep them apart. For example, cluster_{names.qualified(<calling step id>)}. The _cluster(drawn, f'cluster_{_SUB}') assertions in test_graph_features.py would need to follow. A test that calls sub.wic twice with different labels would pin the fix.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right. Two calls to one subworkflow shared a DOT cluster name, so Graphviz merged them and the last call's label and style won. Each called workflow's cluster is now named after the step that calls it, using the same qualified id as the nodes (cluster_w__step__2__sub.wic). Two calls therefore stay two clusters. I added a test that calls sub.wic twice with different labels and an invis style on one call. It checks that each cluster keeps its own look and that the other call's steps stay visible. The cluster assertions in test_graph_features.py follow the new names.

Fixed in 325d80c.

@vjaganat90

Copy link
Copy Markdown
Member Author

Thanks for running tests/core at both commits. The shared cluster name is fixed: a called subworkflow's cluster is now named after the step that calls it, so one call's graphviz label and style can no longer overwrite another's. I covered it with a two-call test. On the nit: I'll correct the "Stacked on #515" line in the description, since #515 is merged and this PR sits on #531 only.

Fixed in 325d80c.

@darkclad darkclad left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

The compiler built a graphviz drawing, a networkx graph and a GraphData
tree on every compile, threaded graph settings and a graph_target
through compile_source, and kept the result on every artifact, though
only --graphviz ever read it.

Drawing is now sophios.drawing.draw(result, bundle, settings, name), a
projection of the compiled graph that main calls only with --graphviz.
compile_source takes the bundle and the compiler options, and
default_compilation_settings() returns those options alone.
CompilationArtifact.graph_view, GraphReps, GraphData and utils_graphs
are gone. The DOT --graphviz writes and the emitted CWL are unchanged.
… again

Since the compiler was rewritten, --graphviz ignored every
wic: graphviz: key but the root's label: a step's label and style, a
subworkflow's title and style, and ranksame were parsed and dropped.

The drawing reads each document's wic: block as Resolve reads it, with
the calling step's entry merged into the subworkflow's. A step's label
replaces its id, unless --graph_label_stepname asks for the generated
names. A step's style is appended to rounded, filled. A subworkflow's
label titles its cluster, which is otherwise titled with the id it is
called by, and its style styles the cluster; invis hides the call's
box too. A workflow's ranksame steps share one rank=same group in its
own cluster, the root's included. A ranksame entry that addresses no
step is named on stderr, like a stale wic: steps: key.

The --graph_label_stepname help said it prepends the step name, and
docs/dev/algorithms.md that --graph_inline_depth collapses a deeper
subworkflow to one node; both now say what they do.
Drawing no longer builds a networkx graph, so nothing under src imports it.
The parser has already checked the entry's shape, so the reader does not
check it again, and a call box is found from the step's own child graph.
Two calls to one subworkflow drew two clusters with the same DOT name, and
Graphviz merges subgraphs of one name: both calls' steps landed in one
cluster and the last call's label and style won. Since a call's
`wic: steps:` entry can now set a cluster's label and style, that was
visible. I name each child cluster with the qualified id of its calling
step, the way nodes are named.
@vjaganat90
vjaganat90 force-pushed the refactor/drawing-is-a-projection branch from 325d80c to a24468e Compare October 13, 2026 17:34
@vjaganat90
vjaganat90 merged commit 5bfca45 into PolusAI:master Oct 13, 2026
2 checks passed
@vjaganat90
vjaganat90 deleted the refactor/drawing-is-a-projection branch October 13, 2026 17:42
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