Skip to content

Deterministic DOT output for --dag/--rulegraph #1709

@standage

Description

@standage

When I run snakemake --dag | dot or snakemake --rulegraph | dot multiple times on the same workflow, I get diagrams with identical layout but different colors for the various nodes. I'm investigating how feasible it would be to make the output from snakemake --dag and snakemake --rulegraph deterministic.

Unless I've missed or misunderstood something, the code for coloring nodes in the DAG._dot method is deterministic.

snakemake/snakemake/dag.py

Lines 1976 to 1981 in cc6c998

# color rules
huefactor = 2 / (3 * len(self.rules))
rulecolor = {
rule: "{:.2f} 0.6 0.85".format(i * huefactor)
for i, rule in enumerate(self.rules)
}

Being unfamiliar with Snakemake internals, if I had to guess, I'd assume that the non-deterministic behavior comes when iterating over self.jobs, which happens both for --dag and --rulegraph modes.

dag = {job: self.dependencies[job] for job in self.jobs}

snakemake/snakemake/dag.py

Lines 1937 to 1938 in cc6c998

for job in self.jobs:
graph[job.rule].update(dep.rule for dep in self.dependencies[job])

Am I on the right track here? Would it be possible with a reasonable amount of effort to generate DOT output deterministically for these modes?

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions