It turned out to be extremely convenient:
- python makes it easy to spot errors/typos (you can use mypy even before running the genrator)
- keyword arguments and dictionaries map naturally to node/edge properties
- you can reuse boilerplate by using functions, variables and control structures
- you can always inject graphviz string directly as a last resort hacking measure
- thanks to python's dynamic features, you can even give the nodes/clusters same names as their corresponding python objects, which results in less boilerplate and makes easy to debug
[0] https://beepb00p.xyz/myinfra.html
[1] https://github.com/karlicoss/myinfra/blob/master/generate.py