seamia / protodot

transforming your .proto files into .dot files (and .svg, .png if you happen to have graphviz installed)
BSD 3-Clause "New" or "Revised" License
410 stars 39 forks source link

consistent output #17

Open deitch opened 1 year ago

deitch commented 1 year ago

Is there a way to get consistent (or nearly consistent) comparable output?

My specific use case is that we have protobufs, and expect to have the graph files checked into the repo as part of the commit. The simplest way to do this (we do it for generated language bindings) is to run protodot, and check if the file is different from what is checked in.

Except the output isn't consistent.

From my checks, I found several things:

I don't know the internals of protodot well enough, but it looks like consistent sorting of the subgraphs and nodes within subgraph might go a long way?

deitch commented 1 year ago

I delved into it quite a bit. It looks like it is because many of the elements (clusters in their parents, elements in their clusters, etc.) are all kept in maps, and then it ranges over the maps. It should be possible to range over the maps to get keys, then sort, then range over that. I tried, but I could not quite figure out where the right place to do it, as I don't understand the templating structure.