awacke1 commited on
Commit
97d5bfa
·
1 Parent(s): 3767180

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +85 -0
app.py CHANGED
@@ -1,6 +1,91 @@
1
  import streamlit as st
2
  from graphviz import Digraph
3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  # Initialize the graph
5
  graph = Digraph(comment='Architectural Model')
6
 
 
1
  import streamlit as st
2
  from graphviz import Digraph
3
 
4
+
5
+ st.markdown("""
6
+ Prompt:
7
+ Create an interactive streamlit graph builder using the graphviz diagram model language and the streamlit feature: st.graphviz_chart(figure_or_dot, use_container_width=False) to show an azure cloud architecture model including the top ten architecture components for python full stack development for web, api, ml, models, datasets torch, transformers, streamlit, azure docker and kubernetes pods for scaling
8
+
9
+ """)
10
+
11
+ # Dot demo:
12
+ import streamlit as st
13
+
14
+ # Define the default graphviz DOT string
15
+ default_dot = """
16
+ digraph G {
17
+ rankdir=LR
18
+ node [shape=box]
19
+ WebApp -> API
20
+ API -> Models
21
+ API -> Datasets
22
+ Models -> Torch
23
+ Models -> Transformers
24
+ WebApp -> Streamlit
25
+ Streamlit -> Azure
26
+ Azure -> Docker
27
+ Azure -> Kubernetes
28
+ }
29
+ """
30
+
31
+ # Define the list of top 10 components
32
+ components = [
33
+ "WebApp",
34
+ "API",
35
+ "Models",
36
+ "Datasets",
37
+ "Torch",
38
+ "Transformers",
39
+ "Streamlit",
40
+ "Azure",
41
+ "Docker",
42
+ "Kubernetes",
43
+ ]
44
+
45
+ # Define a dictionary to map component names to DOT node IDs
46
+ node_ids = {
47
+ component: component.lower()
48
+ for component in components
49
+ }
50
+
51
+ def build_dot_string(selected_components):
52
+ """Builds a DOT string representing the selected components"""
53
+ selected_nodes = [node_ids[component] for component in selected_components]
54
+ dot = """
55
+ digraph G {
56
+ rankdir=LR
57
+ node [shape=box]
58
+ """
59
+ for node in selected_nodes:
60
+ dot += f"{node} [color=blue]\n"
61
+ for i in range(len(selected_nodes)):
62
+ for j in range(i+1, len(selected_nodes)):
63
+ dot += f"{selected_nodes[i]} -> {selected_nodes[j]}\n"
64
+ dot += "}"
65
+ return dot
66
+
67
+ def main():
68
+ st.title("Azure Cloud Architecture Builder")
69
+
70
+ # Select the components
71
+ st.sidebar.title("Select components")
72
+ selected_components = st.sidebar.multiselect(
73
+ "Select the top 10 components",
74
+ components,
75
+ default=components[:3]
76
+ )
77
+
78
+ # Build the DOT string
79
+ dot = build_dot_string(selected_components)
80
+
81
+ # Render the graphviz chart
82
+ st.graphviz_chart(dot, use_container_width=True)
83
+
84
+ if __name__ == "__main__":
85
+ main()
86
+
87
+
88
+
89
  # Initialize the graph
90
  graph = Digraph(comment='Architectural Model')
91