ABC-101 awacke1 commited on
Commit
0e7f30e
0 Parent(s):

Duplicate from AI-ZTH-03-23/2.Streamlit.GraphViz.Dynamic.Architecture.Diagram

Browse files
Files changed (4) hide show
  1. .gitattributes +34 -0
  2. README.md +14 -0
  3. app.py +146 -0
  4. requirements.txt +1 -0
.gitattributes ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tflite filter=lfs diff=lfs merge=lfs -text
29
+ *.tgz filter=lfs diff=lfs merge=lfs -text
30
+ *.wasm filter=lfs diff=lfs merge=lfs -text
31
+ *.xz filter=lfs diff=lfs merge=lfs -text
32
+ *.zip filter=lfs diff=lfs merge=lfs -text
33
+ *.zst filter=lfs diff=lfs merge=lfs -text
34
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: 2.Streamlit.GraphViz.Dynamic.Architecture.Diagram
3
+ emoji: 😻😻😻
4
+ colorFrom: green
5
+ colorTo: indigo
6
+ sdk: streamlit
7
+ sdk_version: 1.17.0
8
+ app_file: app.py
9
+ pinned: false
10
+ license: mit
11
+ duplicated_from: AI-ZTH-03-23/2.Streamlit.GraphViz.Dynamic.Architecture.Diagram
12
+ ---
13
+
14
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py ADDED
@@ -0,0 +1,146 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
92
+ # Add nodes to the graph
93
+ graph.node('data_layer', 'Data Layer')
94
+ graph.node('acr', 'Azure Container Registry')
95
+ graph.node('aks', 'Azure Kubernetes\n& Docker Container Pod\nwith Scalability')
96
+ graph.node('snowflake', 'Snowflake Instance')
97
+ graph.node('cosmos', 'Azure Cosmos\nDatabase')
98
+ graph.node('api', 'API Standard\n(using Uvicorn)')
99
+ graph.node('soar', 'SOAR Component\n(on Linux Python\nSlimbuster Docker)')
100
+
101
+ # Add edges to the graph
102
+ graph.edge('data_layer', 'acr')
103
+ graph.edge('acr', 'aks')
104
+ graph.edge('aks', 'snowflake')
105
+ graph.edge('aks', 'cosmos')
106
+ graph.edge('aks', 'api')
107
+ graph.edge('aks', 'soar')
108
+
109
+ # Define the Streamlit app
110
+ def app():
111
+ st.title('Architectural Model')
112
+
113
+ # Draw the graph
114
+ st.graphviz_chart(graph.source)
115
+
116
+ # Add buttons to customize the graph
117
+ if st.button('Hide Data Layer'):
118
+ graph.node('data_layer', style='invisible')
119
+
120
+ if st.button('Hide Snowflake Instance'):
121
+ graph.node('snowflake', style='invisible')
122
+
123
+ if st.button('Hide SOAR Component'):
124
+ graph.node('soar', style='invisible')
125
+
126
+
127
+
128
+ st.markdown("""
129
+ # QA Model Spaces:
130
+ QA use cases include QA, Semantic Document and FAQ Search.
131
+ 1. Streamlit Question Answering w Hugging Face: https://huggingface.co/spaces/awacke1/Question-answering
132
+ 2. Seq2Seq:
133
+ - https://huggingface.co/spaces/awacke1/4-Seq2SeqQAT5
134
+ - https://huggingface.co/spaces/awacke1/AW-04-GR-Seq-2-Seq-QA-Auto-Gen
135
+ 3. BioGPT: https://huggingface.co/spaces/awacke1/microsoft-BioGPT-Large-PubMedQA
136
+ 4. NLP QA Context: https://huggingface.co/spaces/awacke1/NLPContextQATransformersRobertaBaseSquad2
137
+ - https://huggingface.co/spaces/awacke1/SOTA-Plan
138
+ 5. https://huggingface.co/spaces/awacke1/Question-answering
139
+ 6. QA MLM: https://huggingface.co/spaces/awacke1/SOTA-MedEntity
140
+ """)
141
+
142
+
143
+
144
+ # Run the Streamlit app
145
+ if __name__ == '__main__':
146
+ app()
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ graphviz