Open jbrunetext opened 3 years ago
You can't connect two lists directly because shift/arithmetic operations between lists are not allowed in Python.
If you need a generic solution, see https://github.com/mingrammer/diagrams/issues/493#issuecomment-806158448
for completeness
from diagrams import Diagram, Node
from diagrams.aws.compute import EC2
from diagrams.aws.network import ELB
def list_to_list(l1:list, l2:list) -> None:
for nd in l1:
nd >> l2
with Diagram("", show=False, direction="TB") as diag:
elb = ELB("lb")
list_a = [EC2("worker1"), EC2("worker2"), EC2("worker3"), EC2("worker4"), EC2("worker5")]
list_b = [EC2("Ec1"), EC2("Ec2"), EC2("Ec3")]
elb >> list_a
list_to_list(list_a, list_b)
diag
For a more elegant look:
from diagrams import Diagram, Node, Edge
from diagrams.aws.compute import EC2
from diagrams.aws.network import ELB
graph_attr = {
"layout":"dot",
"concentrate":"true",
"splines":"spline",
}
with Diagram("", show=False, direction="TB", graph_attr=graph_attr,) as diag:
elb = ELB("lb")
list_a = [EC2("worker1"), EC2("worker2"), EC2("worker3"), EC2("worker4"), EC2("worker5")]
list_b = [EC2("Ec1"), EC2("Ec2"), EC2("Ec3")]
blank = Node("", shape="plaintext", height="0.0", width="0.0")
elb >> Edge(headport="n", tailport="s", minlen="1") >> list_a
list_a - Edge(headport="n", tailport="s", minlen="1") - blank
blank >> Edge(headport="n", tailport="s", minlen="1") >> list_b
diag
Try his on my computer
ELB("lb") >> [EC2("worker1"), EC2("worker2"), EC2("worker3"), EC2("worker4"), EC2("worker5")] - [EC2("Ec1"), EC2("Ec2"), EC2("Ec3")]
don' t work for me , do you have any idea ?
File "/Users/JULIEN/github/diagrams/main.py", line 186, in
ELB("lb") >> [EC2("worker1"),
TypeError: unsupported operand type(s) for -: 'list' and 'list'