mingrammer / diagrams

:art: Diagram as Code for prototyping cloud system architectures
https://diagrams.mingrammer.com
MIT License
37.03k stars 2.41k forks source link

Diagrams not reproducible #885

Open dbast opened 1 year ago

dbast commented 1 year ago

While storing diagrams as .py files and their rendered .png representations in version control and using CI workflow to check that the png version is up to date, I noticed some diagrams don't produce the same png image on consecutive renderings.

To reproduce, example.py:

#!/usr/bin/env python

from diagrams import Cluster, Diagram
from diagrams.aws.compute import ECS
from diagrams.aws.database import RDS, ElastiCache
from diagrams.aws.network import ELB, Route53

with Diagram("Example", show=False):
    dns = Route53("dns")
    lb = ELB("lb")

    with Cluster("Services"):
        svc_group = [ECS("web1"), ECS("web2"), ECS("web3")]

    with Cluster("DB Cluster"):
        db_primary = RDS("userdb")
        db_primary - [RDS("userdb ro")]

    memcached = ElastiCache("memcached")

    dns >> lb >> svc_group
    svc_group >> db_primary
    svc_group >> memcached

If I now render this via

then the results are 1. different on macOS compared to Linux in Docker... and 2. also change if I redo the macOS/Linux rendering after some time and compare to the previous rendering.

Why is that? Is 1. due to some dependencies different on macOS vs Linux and 2. due to some transitive dependencies changing over time?

How can I make the rendering 100% bit-identical reproducible on different operating systems and also stable over time? What transitive dependencies require version pinnings?

Here one diff as example to what changes between renderings: diff

Thanks!

danielloader commented 1 year ago

Typeface rendering is a pain. What does SVG do in this scenario in terms of bit level replication?

davidboweninrupt commented 10 months ago

When I was very careful with my ordering adding Nodes to the Diagram I was able to get stable output in SVG.