Skip to content

Commit ed06a3c

Browse files
TSZ201TSZ201
TSZ201
authored and
TSZ201
committed
pep8 style
1 parent 5619684 commit ed06a3c

File tree

9 files changed

+94
-85
lines changed

9 files changed

+94
-85
lines changed

Pipfile

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ name = "pypi"
55

66
[packages]
77
diagrams = "*"
8+
autopep8 = "*"
9+
flake8 = "*"
810

911
[dev-packages]
1012

aws/ecs.py

+23-9
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class ALBExample:
1010
def __init__(self):
1111
self.graph_attr = {
1212
"layout": "dot",
13-
"compound": "true", # make edge can link cluster border
13+
"compound": "true", # make edge can link cluster border
1414
"center": "true"
1515
}
1616
self.path = Path(__file__).parent.parent.joinpath("assets")
@@ -31,13 +31,19 @@ def example1(self):
3131
dynamo = Dynamodb('Database')
3232

3333
with Cluster("Private Subnet1"):
34-
ecs1 = [ECS("Instance1"),ECS("Instance2"),ECS("Instance3")]
34+
ecs1 = [
35+
ECS("Instance1"),
36+
ECS("Instance2"),
37+
ECS("Instance3")]
3538

3639
with Cluster("Private Subnet2"):
37-
ecs2 = [ECS("Instance1"), ECS("Instance2"), ECS("Instance3")]
40+
ecs2 = [
41+
ECS("Instance1"),
42+
ECS("Instance2"),
43+
ECS("Instance3")]
3844

39-
alb1 >> Edge(lhead="cluster_Private Subnet1")>>ecs1
40-
alb1 >> Edge(lhead="cluster_Private Subnet2")>>ecs2
45+
alb1 >> Edge(lhead="cluster_Private Subnet1") >> ecs1
46+
alb1 >> Edge(lhead="cluster_Private Subnet2") >> ecs2
4147

4248
ecs1 >> Edge(label="store data", color="darkblue") >> dynamo
4349
ecs2 >> Edge(label="store data", color="darkblue") >> dynamo
@@ -47,21 +53,29 @@ def example1(self):
4753
dynamo = Dynamodb('Database')
4854

4955
with Cluster("Private Subnet1"):
50-
ecs1 = [ECS("Instance1"), ECS("Instance2"), ECS("Instance3")]
56+
ecs1 = [
57+
ECS("Instance1"),
58+
ECS("Instance2"),
59+
ECS("Instance3")]
5160

5261
with Cluster("Private Subnet2"):
53-
ecs2 = [ECS("Instance1"), ECS("Instance2"), ECS("Instance3")]
62+
ecs2 = [
63+
ECS("Instance1"),
64+
ECS("Instance2"),
65+
ECS("Instance3")]
5466

5567
alb2 >> Edge(lhead="cluster_Private Subnet1") >> ecs1
5668
alb2 >> Edge(lhead="cluster_Private Subnet2") >> ecs2
5769

5870
ecs1 >> Edge(label="store data", color="darkblue") >> dynamo
5971
ecs2 >> Edge(label="store data", color="darkblue") >> dynamo
6072

61-
dns >> Edge(label="Active(health check)", color="darkgreen") >> alb1
73+
dns >> Edge(
74+
label="Active(health check)",
75+
color="darkgreen") >> alb1
6276
dns >> Edge(label="Active(health check)", color="darkred") >> alb2
6377

6478

6579
if __name__ == '__main__':
6680
demo = ALBExample()
67-
demo.example1()
81+
demo.example1()

aws/eks.py

+9-19
Original file line numberDiff line numberDiff line change
@@ -34,47 +34,37 @@ def example1(self):
3434
node1 = Node("Data Resource")
3535
node2 = Node("Use Case")
3636

37-
with Cluster('Security', direction="TB"):
37+
with Cluster('Security', direction="TB"):
3838
ss = [
3939
ECR("ECR"), IAM("IAM"),
4040
SecretsManager("Secrets Manager"),
4141
Cloudwatch("Cloudwatch")
4242
]
4343

44+
with Cluster('Workload on EKS', direction="TB"):
45+
eks = [EKS("EKS Jupyter notebook"), EKS("EKS job")]
4446

45-
with Cluster('Workload on EKS', direction="TB"):
46-
eks = [EKS("EKS Jupyter notebook"),EKS("EKS job")]
47-
48-
github=Github("Git Script")
47+
github = Github("Git Script")
4948
s3 = S3("AWS S3")
5049

5150
with Cluster('Orchestration on EKS', direction="TB"):
5251
argo = Argocd("argo")
5352
argo >> Node("ThirdParty Plugin")
5453

55-
with Cluster('Data Lake', direction="TB"):
54+
with Cluster('Data Lake', direction="TB"):
5655
s3_in = S3("AWS S3")
5756
glue = Glue("AWS Glue")
5857
athena = Athena("AWS Athena")
59-
athena>>s3_in
60-
athena >> Edge(label="create") >> glue>>node2
58+
athena >> s3_in
59+
athena >> Edge(label="create") >> glue >> node2
6160

6261
for s in ss:
6362
for e in eks:
64-
s>>e
63+
s >> e
6564

66-
node1>>eks[0]>>github>>s3>>argo>>eks[1]>>s3_in
65+
node1 >> eks[0] >> github >> s3 >> argo >> eks[1] >> s3_in
6766

6867

6968
if __name__ == '__main__':
7069
eks = EKSExample()
7170
eks.example1()
72-
73-
74-
75-
76-
77-
78-
79-
80-

aws/iot.py

+14-17
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ class IOTExample:
1414
example1: Smart Metering for Water Utilities
1515
"""
1616

17-
1817
def __init__(self):
1918
self.path = Path(__file__).parent.parent.joinpath("assets")
2019

@@ -25,18 +24,18 @@ def example1(self):
2524
show=False,
2625
direction="LR"
2726
):
28-
with Cluster('Devices',direction="LR"):
27+
with Cluster('Devices', direction="LR"):
2928
c1 = Client("BLE")
3029
c2 = Client("BLE")
3130

32-
with Cluster('Meter Box1',direction="LR"):
33-
f1=FreeRTOS("FreeRTOS")
31+
with Cluster('Meter Box1', direction="LR"):
32+
f1 = FreeRTOS("FreeRTOS")
3433

35-
with Cluster('Meter Box2',direction="LR"):
36-
f2=FreeRTOS("FreeRTOS")
34+
with Cluster('Meter Box2', direction="LR"):
35+
f2 = FreeRTOS("FreeRTOS")
3736

3837
gateway = IotDeviceGateway("IotDeviceGateway")
39-
with Cluster('AWS CLoud',direction="LR"):
38+
with Cluster('AWS CLoud', direction="LR"):
4039
iot_core = IotCore("IotCore")
4140
iot_rule = IotRule("IotRule")
4241

@@ -61,18 +60,16 @@ def example1(self):
6160
api_gateway = APIGateway("APIGateway")
6261
amplify = Amplify("Amplify")
6362

64-
c1>>f1>>gateway
65-
c2>>f2>>gateway
66-
gateway>>iot_core
67-
l1>>iot_core
68-
iot_core>>iot_rule
63+
c1 >> f1 >> gateway
64+
c2 >> f2 >> gateway
65+
gateway >> iot_core
66+
l1 >> iot_core
67+
iot_core >> iot_rule
6968
iot_rule >> time_stream
70-
iot_rule >> s3<< ec2_2<<l2<<api_gateway
71-
iot_core>>iot_event>>ec2_1
69+
iot_rule >> s3 << ec2_2 << l2 << api_gateway
70+
iot_core >> iot_event >> ec2_1
71+
7272

7373
if __name__ == '__main__':
7474
iot = IOTExample()
7575
iot.example1()
76-
77-
78-

aws/ml.py

+10-10
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ def __init__(self):
2020
}
2121
self.path = Path(__file__).parent.parent.joinpath("assets")
2222

23-
2423
def example1(self):
2524
with Diagram(
2625
name="ML Example",
@@ -29,7 +28,7 @@ def example1(self):
2928
graph_attr=self.graph_attr
3029
):
3130

32-
with Cluster('Society Media',direction="TB"):
31+
with Cluster('Society Media', direction="TB"):
3332
lambda1 = Lambda(
3433
"Identity data to be processed"
3534
)
@@ -38,21 +37,21 @@ def example1(self):
3837
)
3938
cw = CloudwatchEventEventBased("Schedule data pull")
4039
eb = Eventbridge("AWS EventBridge")
41-
s3=S3("Bucket(Ingestion for JSON files)")
40+
s3 = S3("Bucket(Ingestion for JSON files)")
4241
dynamo = Dynamodb("DynamoDB")
4342

4443
ks = KinesisDataStreams("Kinesis Data Stream")
4544
lambda01 = Lambda("Ingestion consumer")
4645

47-
with Cluster('Step Function workflow',direction="TB"):
48-
sf1 = SF("Topic modeling")
49-
sf2 = SF("Text interface")
46+
with Cluster('Step Function workflow', direction="TB"):
47+
sf1 = SF("Topic modeling")
48+
sf2 = SF("Text interface")
5049

5150
s3_outer1 = S3("Bucket(Raw text for topic modeling)")
5251
cw_outer = CloudwatchEventEventBased("Event Scheduler")
5352

54-
reko=Rekognition("Rekognition")
55-
comp1 =Comprehend("Comprehend")
53+
reko = Rekognition("Rekognition")
54+
comp1 = Comprehend("Comprehend")
5655
trans = Translate("Translate")
5756
comp2 = Comprehend("Comprehend")
5857
eb_outer = Eventbridge("EventBridge(publish interface events)")
@@ -76,9 +75,10 @@ def example1(self):
7675
sf2 >> Edge(lhead="cluster_Step Function workflow") >> trans
7776
sf2 >> Edge(lhead="cluster_Step Function workflow") >> comp2
7877
sf2 >> Edge(lhead="cluster_Step Function workflow") >> eb_outer
79-
eb_outer>>lambda02>>kdf>>s3_outer2<<glue<<a<<q<<User("User")
78+
eb_outer >> lambda02 >> kdf >> s3_outer2 << glue << a << q << User(
79+
"User")
8080

8181

8282
if __name__ == '__main__':
8383
ml = MLExample()
84-
ml.example1()
84+
ml.example1()

aws/serverless.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
class ALBExample:
1111

12-
1312
def __init__(self):
1413
self.graph_attr = {
1514
"fontcolor": "black",
@@ -32,7 +31,7 @@ def example1(self):
3231
api = APIGateway("api")
3332
with Cluster("Product Service"):
3433
lambda1 = Lambda("Lambda")
35-
lambda1>>Dynamodb("Product DB")
34+
lambda1 >> Dynamodb("Product DB")
3635

3736
with Cluster("Order Service"):
3837
lambda2 = Lambda("Lambda")
@@ -42,9 +41,8 @@ def example1(self):
4241
lambda3 = Lambda("Lambda")
4342
lambda3 >> RDS("Invoice DB")
4443

45-
4644
with Cluster("Analysis Service"):
47-
lambda4= Lambda("Lambda")
45+
lambda4 = Lambda("Lambda")
4846
lambda4 >> Redshift("Analysis")
4947

5048
sqs = SQS('message queue')
@@ -59,6 +57,7 @@ def example1(self):
5957
sqs >> Edge(color="darkgreen") >> lambda3
6058
sqs >> Edge(color="darkgreen") >> lambda4
6159

60+
6261
if __name__ == '__main__':
6362
demo = ALBExample()
64-
demo.example1()
63+
demo.example1()

elkb/elasticstack.py

+11-7
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,18 @@ def example1(self):
3030

3131
kibana = Kibana("Kibana")
3232

33-
Apache("Apache")>>Beats("Beats")>>Edge(color="darkblue",label="Logs")>>logstash
34-
Nginx("Nginx")>>Beats("Beats")>>Edge(color="darkblue",label="Logs")>>logstash
35-
Python("Python")>>Beats("Beats")>>Edge(color="darkblue",label="Logs")>>logstash
36-
Go("Go")>>Beats("Beats")>>Edge(color="darkblue",label="Logs")>>logstash
37-
logstash>>Edge(color="darkblue",label="Ingested Logs")>>e1
38-
e1<<Edge(color="darkblue",label="Search")<<kibana
33+
Apache("Apache") >> Beats("Beats") >> Edge(
34+
color="darkblue", label="Logs") >> logstash
35+
Nginx("Nginx") >> Beats("Beats") >> Edge(
36+
color="darkblue", label="Logs") >> logstash
37+
Python("Python") >> Beats("Beats") >> Edge(
38+
color="darkblue", label="Logs") >> logstash
39+
Go("Go") >> Beats("Beats") >> Edge(
40+
color="darkblue", label="Logs") >> logstash
41+
logstash >> Edge(color="darkblue", label="Ingested Logs") >> e1
42+
e1 << Edge(color="darkblue", label="Search") << kibana
43+
3944

4045
if __name__ == '__main__':
4146
elkb = ELKBExample()
4247
elkb.example1()
43-

kubernetes/karch.py

+12-15
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
from pathlib import Path
22

33
from diagrams import Diagram, Cluster, Edge, Node
4-
from diagrams.aws.compute import Compute
5-
from diagrams.aws.iot import InternetOfThings
64
from diagrams.digitalocean.storage import Volume
7-
from diagrams.generic.os import Android
85
from diagrams.k8s.compute import Pod, Job, ReplicaSet, StatefulSet
96
from diagrams.k8s.controlplane import ControllerManager, Scheduler, APIServer, Kubelet, KubeProxy
107
from diagrams.k8s.infra import ETCD
@@ -17,7 +14,7 @@ class K8sExample:
1714
def __init__(self):
1815
self.graph_attr = {
1916
"layout": "neato",
20-
"compound": "true", # make edge can link cluster border
17+
"compound": "true", # make edge can link cluster border
2118
"center": "true"
2219
}
2320
self.path = Path(__file__).parent.parent.joinpath("assets")
@@ -40,9 +37,9 @@ def example1(self):
4037
api_server = APIServer("APIServer")
4138

4239
api_server >> etcd
43-
api_server >>Edge(style="dashed")>> cm1
44-
api_server >>Edge(reverse=True)>> scheduler
45-
api_server >>Edge(reverse=True)>> cm2
40+
api_server >> Edge(style="dashed") >> cm1
41+
api_server >> Edge(reverse=True) >> scheduler
42+
api_server >> Edge(reverse=True) >> cm2
4643

4744
with Cluster('Data Plane'):
4845

@@ -51,7 +48,7 @@ def example1(self):
5148
kubeproxy1 = KubeProxy("KubeProxy ")
5249

5350
with Cluster("Container Runtime",):
54-
pods1 = [Pod("pod"),Pod("pod"),Pod("pod")]
51+
pods1 = [Pod("pod"), Pod("pod"), Pod("pod")]
5552

5653
with Cluster("K8s Objects",):
5754
objects1 = [
@@ -68,7 +65,7 @@ def example1(self):
6865
kubeproxy2 = KubeProxy("KubeProxy ")
6966

7067
with Cluster("Container Runtime",):
71-
pods2 = [Pod("pod"),Pod("pod"),Pod("pod")]
68+
pods2 = [Pod("pod"), Pod("pod"), Pod("pod")]
7269

7370
with Cluster("K8s Objects",):
7471
objects2 = [
@@ -80,18 +77,18 @@ def example1(self):
8077
StorageClass("StorageClass ")
8178
]
8279

83-
api_server >> kubelet1 >> Edge(htail="cluster_Container Runtime") >> pods1[0]
80+
api_server >> kubelet1 >> Edge(
81+
htail="cluster_Container Runtime") >> pods1[0]
8482
api_server >> kubeproxy1
8583

86-
api_server >> kubelet2 >> Edge(htail="cluster_Container Runtime") >> pods2[0]
84+
api_server >> kubelet2 >> Edge(
85+
htail="cluster_Container Runtime") >> pods2[0]
8786
api_server >> kubeproxy2
8887

89-
kubeproxy1>>Edge(style="dashed",reverse=True)>>kubeproxy2
90-
Node("User")>>api_server
88+
kubeproxy1 >> Edge(style="dashed", reverse=True) >> kubeproxy2
89+
Node("User") >> api_server
9190

9291

9392
if __name__ == '__main__':
9493
k8s = K8sExample()
9594
k8s.example1()
96-
97-

0 commit comments

Comments
 (0)