generated from streamlit/blank-app-template
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Create_Analysis.py
187 lines (145 loc) · 7.45 KB
/
Create_Analysis.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
import streamlit as st
import pandas as pd
import numpy as np
import altair as alt
from st_aggrid import AgGrid, GridOptionsBuilder
import random
st.set_page_config('QueryShield')
st.sidebar.title("QueryShield")
login= st.sidebar.button("Login")
@st.experimental_dialog("Login")
def email_form():
with st.form('Login', border=False, clear_on_submit=True):
name= st.text_input('Name', key= "key1")
email= st.text_input('Email', key= "key2")
if st.form_submit_button("Submit"):
st.rerun()
if login:
email_form()
if "disabled" not in st.session_state:
st.session_state["disabled"]= False
def disable():
st.session_state["disabled"] =True
st.title('Create New Analysis')
st.subheader('Data Schema')
#with st.form("Submit", border=False, clear_on_submit=False):
col1, col2, col3= st.columns([0.7, 0.06, 0.24])
df= pd.DataFrame(columns=["Column Name",'Units (e.g.lbs, kg, MM/dd/yyyy)','Type'])
numbers=["Integer", "Varchar", "String", "Catgeory"]
st.session_state.user_input= col1.data_editor(df, column_config= {"Type": st.column_config.SelectboxColumn("Type",
options= ["Integer", "Varchar", "String", "Category"], default="Integer"),
"Column Name": st.column_config.TextColumn(),
"Units (e.g.lbs, kg, MM/dd/yyyy)": st.column_config.TextColumn()},
num_rows="dynamic", hide_index=True, use_container_width=True)
for index, entry in enumerate(st.session_state.user_input['Type']):
if entry== "Category":
column_name= st.session_state.user_input["Column Name"]
#with col2.expander(label= f" Define Categories for {str(column_name.iloc[index])}"):
if "num_rows" not in st.session_state:
st.session_state.num_rows=1
def del_row():
if st.session_state.num_rows>=1:
st.session_state.num_rows-=1
def add_row():
st.session_state.num_rows+=1
for i in range(st.session_state.num_rows):
st.session_state.category_schema= col3.text_input("", label_visibility="collapsed",
value= st.session_state.category_schema,
key=f"Category Input Box_{index}_{i}")
col2.button("X", on_click=del_row, key=f"del_row_{index}")
col3.button('Add Row', on_click=add_row, key=f'add_row_{index}')
st.write(st.session_state.category_schema )
if "num_rows" not in st.session_state:
st.session_state.num_rows=1
if "category schema" not in st.session_state:
st.session_state.category_schema= ""
#if any(st.session_state.user_input["Type"] == "Category"):
#df= pd.DataFrame(columns=[st.session_state.user_input["Column Name"]])
#st.data_editor(df, num_rows="dynamic", use_container_width=True )
#col1, col2= st.columns(2)
#col1.text_input(f'Enter Category Name for {st.session_state.user_input['Column Name']}')
#@st.experimental_dialog(f'Enter Categories')
#def specify():
#if st.session_state.user_input['Column Name'] not in st.session_state:
#st.session_state.user_input['Column Name']=''
#df=pd.DataFrame(columns=[st.session_state.user_input["Column Name"]])
#st.data_editor(df, num_rows="dynamic", use_container_width=True )
#confirm= st.button("Confirm", help=None)
#if confirm:
#st.button('Test')
#specify()
column_name= st.session_state.user_input["Column Name"]
if "column name" not in st.session_state:
st.session_state["column name"]=""
if 'user input' not in st.session_state:
st.session_state["user input"]=""
st.divider()
st.subheader('Threat Model')
if "cloud provider" not in st.session_state:
st.session_state["cloud provider"]=""
col1, col2 =st.columns(2)
st.session_state.threat_model= col1.radio("Threat Model", options=["Semi-Honest", "Malicious"],label_visibility= "collapsed", key= "t1")
#st.session_state.cloud_provider = col2.multiselect("Cloud Provider", options= ["AWS", "Microsoft Azure", "Google Cloud", "Chameleon Open Cloud"])
#st.session_state.cloud_provider= col2.toggle("Cloud Provider",)
col2.markdown("Cloud Provider")
#if st.session_state.threat_model=="Semi-Honest":
#elif st.session_state.threat_model=='Malicious':
st.session_state.AWS= col2.toggle("AWS", key="toggle1", value=True)
st.session_state.Microsoft= col2.toggle("Microsoft Azure", key='toggle 2', value= True)
st.session_state.Google= col2.toggle("Google Cloud",key='toggle 3', value=True)
st.session_state.Chameleon= col2.toggle("Chameleon Open Cloud", key="toggle4", value=True)
if "threat_model" not in st.session_state:
st.session_state['threat model']=""
if "AWS" not in st.session_state:
st.session_state["AWS"]=False
if "Microsoft" not in st.session_state:
st.session_state["Microsoft"]=False
if "Google Cloud" not in st.session_state:
st.session_state["Google Cloud"]=False
if "Chameleon" not in st.session_state:
st.session_state["Chameleon"]=False
st.divider()
st.subheader('Analysis Details')
st.session_state.query_name= st.text_input("Query Name")
if 'query_name' not in st.session_state:
st.session_state["query_name"]= ""
st.session_state.query= st.text_area("Input Query Here")
if "query" not in st.session_state:
st.session_state['query']= ""
st.session_state.description = st.text_area("Description")
if "description" not in st.session_state:
st.session_state['description']= ""
st.divider()
if 'Sumbit' not in st.session_state:
st.session_state["Submit"]=False
st.subheader("Complete Registration")
st.session_state.submitted= st.button("Submit")
#if submitted:
if st.session_state.submitted:
if "disabled" not in st.session_state:
st.session_state["disabled"]= False
def disable():
st.session_state["disabled"] =True
disable()
st.session_state['query_name'] = st.session_state.query_name
st.session_state['description'] = st.session_state.description
st.session_state['query']= st.session_state.query
st.session_state['threat model']= st.session_state.threat_model
#st.session_state['cloud provider']= st.session_state.cloud_provider
st.session_state['category schema']= st.session_state.category_schema
st.session_state["user input"]= st.session_state.user_input
st.session_state['AWS']= st.session_state.AWS
st.session_state['Microsoft']= st.session_state.Microsoft
st.session_state['Google Cloud']= st.session_state.Google
st.session_state["Chameleon"]= st.session_state.Chameleon
st.session_state['Submit']= st.session_state.submitted
#if st.session_state.threat_model== "Semi-Honest":
#if len(st.session_state.cloud_provider)>=3:
#st.success("Success")
#elif len(st.session_state.cloud_provider) <3:
#st.error("Error")
#if st.session_state.threat_model=="Malicious":
#if len(st.session_state.cloud_provider)>=4:
#st.success("Success")
#elif len(st.session_state.cloud_provider) <4:
#st.error("Error")