Update app.py
Browse files
app.py
CHANGED
|
@@ -3,7 +3,7 @@ import streamlit as st
|
|
| 3 |
st.set_page_config(layout="wide")
|
| 4 |
|
| 5 |
# --------------------------------------------------
|
| 6 |
-
#
|
| 7 |
# --------------------------------------------------
|
| 8 |
|
| 9 |
st.markdown("""
|
|
@@ -11,47 +11,36 @@ st.markdown("""
|
|
| 11 |
|
| 12 |
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600&display=swap');
|
| 13 |
|
| 14 |
-
html, body, [class*="css"]
|
| 15 |
font-family: 'Inter', sans-serif;
|
| 16 |
}
|
| 17 |
|
| 18 |
-
/* title */
|
| 19 |
.title {
|
| 20 |
-
font-size:
|
| 21 |
font-weight:600;
|
| 22 |
-
margin-bottom:
|
| 23 |
}
|
| 24 |
|
| 25 |
-
/*
|
| 26 |
-
.
|
|
|
|
| 27 |
padding:10px;
|
| 28 |
-
border-radius:
|
| 29 |
-
|
| 30 |
}
|
| 31 |
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
border:
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
/* selected actions */
|
| 39 |
-
.selected {
|
| 40 |
-
background:#e8f7ee;
|
| 41 |
-
border:1px solid #8bd6a3;
|
| 42 |
-
}
|
| 43 |
-
|
| 44 |
-
/* card text */
|
| 45 |
-
.card-text {
|
| 46 |
-
font-size:16px;
|
| 47 |
-
padding:8px;
|
| 48 |
}
|
| 49 |
|
| 50 |
-
.
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
text-align:center;
|
| 55 |
}
|
| 56 |
|
| 57 |
</style>
|
|
@@ -95,17 +84,17 @@ if "auditor_selected" not in st.session_state:
|
|
| 95 |
# Toggle Functions
|
| 96 |
# --------------------------------------------------
|
| 97 |
|
| 98 |
-
def toggle_owner(
|
| 99 |
-
if
|
| 100 |
-
st.session_state.owner_selected.remove(
|
| 101 |
else:
|
| 102 |
-
st.session_state.owner_selected.append(
|
| 103 |
|
| 104 |
-
def toggle_auditor(
|
| 105 |
-
if
|
| 106 |
-
st.session_state.auditor_selected.remove(
|
| 107 |
else:
|
| 108 |
-
st.session_state.auditor_selected.append(
|
| 109 |
|
| 110 |
# --------------------------------------------------
|
| 111 |
# Layout
|
|
@@ -114,79 +103,91 @@ def toggle_auditor(a):
|
|
| 114 |
left, right = st.columns(2)
|
| 115 |
|
| 116 |
# --------------------------------------------------
|
| 117 |
-
# MODEL OWNER
|
| 118 |
# --------------------------------------------------
|
| 119 |
|
| 120 |
with left:
|
| 121 |
|
| 122 |
st.markdown("### Model Owner")
|
| 123 |
|
| 124 |
-
st.markdown("
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
st.button(
|
| 132 |
-
"toggle",
|
| 133 |
-
key=f"owner_sel_{action}",
|
| 134 |
-
on_click=toggle_owner,
|
| 135 |
-
args=(action,),
|
| 136 |
-
)
|
| 137 |
-
|
| 138 |
-
st.markdown("**Available**")
|
| 139 |
-
|
| 140 |
-
for action in model_owner_actions:
|
| 141 |
-
if action not in st.session_state.owner_selected:
|
| 142 |
-
st.markdown(
|
| 143 |
-
f'<div class="card-box available"><div class="card-text">{action}</div></div>',
|
| 144 |
-
unsafe_allow_html=True,
|
| 145 |
-
)
|
| 146 |
st.button(
|
| 147 |
-
|
| 148 |
-
key=f"
|
| 149 |
on_click=toggle_owner,
|
| 150 |
args=(action,),
|
|
|
|
| 151 |
)
|
| 152 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 153 |
# --------------------------------------------------
|
| 154 |
-
# AUDITOR
|
| 155 |
# --------------------------------------------------
|
| 156 |
|
| 157 |
with right:
|
| 158 |
|
| 159 |
st.markdown("### Auditor")
|
| 160 |
|
| 161 |
-
st.markdown("
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
st.button(
|
| 169 |
-
"toggle",
|
| 170 |
-
key=f"aud_sel_{action}",
|
| 171 |
-
on_click=toggle_auditor,
|
| 172 |
-
args=(action,),
|
| 173 |
-
)
|
| 174 |
-
|
| 175 |
-
st.markdown("**Available**")
|
| 176 |
-
|
| 177 |
-
for action in auditor_actions:
|
| 178 |
-
if action not in st.session_state.auditor_selected:
|
| 179 |
-
st.markdown(
|
| 180 |
-
f'<div class="card-box available"><div class="card-text">{action}</div></div>',
|
| 181 |
-
unsafe_allow_html=True,
|
| 182 |
-
)
|
| 183 |
st.button(
|
| 184 |
-
|
| 185 |
-
key=f"
|
| 186 |
on_click=toggle_auditor,
|
| 187 |
args=(action,),
|
|
|
|
| 188 |
)
|
| 189 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 190 |
# --------------------------------------------------
|
| 191 |
# Score Calculation
|
| 192 |
# --------------------------------------------------
|
|
@@ -195,15 +196,15 @@ cheating = 50
|
|
| 195 |
cost = 0
|
| 196 |
open_req = 0
|
| 197 |
|
| 198 |
-
for
|
| 199 |
-
cheating += model_owner_actions[
|
| 200 |
-
cost += model_owner_actions[
|
| 201 |
-
open_req += model_owner_actions[
|
| 202 |
|
| 203 |
-
for
|
| 204 |
-
cheating += auditor_actions[
|
| 205 |
-
cost += auditor_actions[
|
| 206 |
-
open_req += auditor_actions[
|
| 207 |
|
| 208 |
cheating = max(0, min(100, cheating))
|
| 209 |
open_req = max(0, open_req)
|
|
@@ -216,13 +217,8 @@ st.divider()
|
|
| 216 |
|
| 217 |
c1, c2, c3 = st.columns(3)
|
| 218 |
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
with c2:
|
| 223 |
-
st.metric("Audit Cost", cost)
|
| 224 |
-
|
| 225 |
-
with c3:
|
| 226 |
-
st.metric("Openness Required", open_req)
|
| 227 |
|
| 228 |
st.progress(cheating / 100)
|
|
|
|
| 3 |
st.set_page_config(layout="wide")
|
| 4 |
|
| 5 |
# --------------------------------------------------
|
| 6 |
+
# Styling
|
| 7 |
# --------------------------------------------------
|
| 8 |
|
| 9 |
st.markdown("""
|
|
|
|
| 11 |
|
| 12 |
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600&display=swap');
|
| 13 |
|
| 14 |
+
html, body, [class*="css"] {
|
| 15 |
font-family: 'Inter', sans-serif;
|
| 16 |
}
|
| 17 |
|
| 18 |
+
/* title styling */
|
| 19 |
.title {
|
| 20 |
+
font-size:42px;
|
| 21 |
font-weight:600;
|
| 22 |
+
margin-bottom:20px;
|
| 23 |
}
|
| 24 |
|
| 25 |
+
/* boxes */
|
| 26 |
+
.available-box {
|
| 27 |
+
background:#f6f7fb;
|
| 28 |
padding:10px;
|
| 29 |
+
border-radius:10px;
|
| 30 |
+
border:1px solid #e1e4ef;
|
| 31 |
}
|
| 32 |
|
| 33 |
+
.selected-box {
|
| 34 |
+
background:#e9f7ef;
|
| 35 |
+
padding:10px;
|
| 36 |
+
border-radius:10px;
|
| 37 |
+
border:1px solid #a7e0b8;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
}
|
| 39 |
|
| 40 |
+
.small-label {
|
| 41 |
+
font-size:14px;
|
| 42 |
+
color:#666;
|
| 43 |
+
margin-bottom:4px;
|
|
|
|
| 44 |
}
|
| 45 |
|
| 46 |
</style>
|
|
|
|
| 84 |
# Toggle Functions
|
| 85 |
# --------------------------------------------------
|
| 86 |
|
| 87 |
+
def toggle_owner(action):
|
| 88 |
+
if action in st.session_state.owner_selected:
|
| 89 |
+
st.session_state.owner_selected.remove(action)
|
| 90 |
else:
|
| 91 |
+
st.session_state.owner_selected.append(action)
|
| 92 |
|
| 93 |
+
def toggle_auditor(action):
|
| 94 |
+
if action in st.session_state.auditor_selected:
|
| 95 |
+
st.session_state.auditor_selected.remove(action)
|
| 96 |
else:
|
| 97 |
+
st.session_state.auditor_selected.append(action)
|
| 98 |
|
| 99 |
# --------------------------------------------------
|
| 100 |
# Layout
|
|
|
|
| 103 |
left, right = st.columns(2)
|
| 104 |
|
| 105 |
# --------------------------------------------------
|
| 106 |
+
# MODEL OWNER SIDE
|
| 107 |
# --------------------------------------------------
|
| 108 |
|
| 109 |
with left:
|
| 110 |
|
| 111 |
st.markdown("### Model Owner")
|
| 112 |
|
| 113 |
+
st.markdown('<div class="small-label">Chosen</div>', unsafe_allow_html=True)
|
| 114 |
+
|
| 115 |
+
selected_box = st.container(border=False)
|
| 116 |
+
with selected_box:
|
| 117 |
+
st.markdown('<div class="selected-box">', unsafe_allow_html=True)
|
| 118 |
+
|
| 119 |
+
for action in st.session_state.owner_selected:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 120 |
st.button(
|
| 121 |
+
action,
|
| 122 |
+
key=f"owner_selected_{action}",
|
| 123 |
on_click=toggle_owner,
|
| 124 |
args=(action,),
|
| 125 |
+
use_container_width=True
|
| 126 |
)
|
| 127 |
|
| 128 |
+
st.markdown('</div>', unsafe_allow_html=True)
|
| 129 |
+
|
| 130 |
+
st.markdown('<div class="small-label">Available</div>', unsafe_allow_html=True)
|
| 131 |
+
|
| 132 |
+
available_box = st.container(border=False)
|
| 133 |
+
with available_box:
|
| 134 |
+
st.markdown('<div class="available-box">', unsafe_allow_html=True)
|
| 135 |
+
|
| 136 |
+
for action in model_owner_actions:
|
| 137 |
+
if action not in st.session_state.owner_selected:
|
| 138 |
+
st.button(
|
| 139 |
+
action,
|
| 140 |
+
key=f"owner_available_{action}",
|
| 141 |
+
on_click=toggle_owner,
|
| 142 |
+
args=(action,),
|
| 143 |
+
use_container_width=True
|
| 144 |
+
)
|
| 145 |
+
|
| 146 |
+
st.markdown('</div>', unsafe_allow_html=True)
|
| 147 |
+
|
| 148 |
# --------------------------------------------------
|
| 149 |
+
# AUDITOR SIDE
|
| 150 |
# --------------------------------------------------
|
| 151 |
|
| 152 |
with right:
|
| 153 |
|
| 154 |
st.markdown("### Auditor")
|
| 155 |
|
| 156 |
+
st.markdown('<div class="small-label">Chosen</div>', unsafe_allow_html=True)
|
| 157 |
+
|
| 158 |
+
selected_box = st.container(border=False)
|
| 159 |
+
with selected_box:
|
| 160 |
+
st.markdown('<div class="selected-box">', unsafe_allow_html=True)
|
| 161 |
+
|
| 162 |
+
for action in st.session_state.auditor_selected:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 163 |
st.button(
|
| 164 |
+
action,
|
| 165 |
+
key=f"auditor_selected_{action}",
|
| 166 |
on_click=toggle_auditor,
|
| 167 |
args=(action,),
|
| 168 |
+
use_container_width=True
|
| 169 |
)
|
| 170 |
|
| 171 |
+
st.markdown('</div>', unsafe_allow_html=True)
|
| 172 |
+
|
| 173 |
+
st.markdown('<div class="small-label">Available</div>', unsafe_allow_html=True)
|
| 174 |
+
|
| 175 |
+
available_box = st.container(border=False)
|
| 176 |
+
with available_box:
|
| 177 |
+
st.markdown('<div class="available-box">', unsafe_allow_html=True)
|
| 178 |
+
|
| 179 |
+
for action in auditor_actions:
|
| 180 |
+
if action not in st.session_state.auditor_selected:
|
| 181 |
+
st.button(
|
| 182 |
+
action,
|
| 183 |
+
key=f"auditor_available_{action}",
|
| 184 |
+
on_click=toggle_auditor,
|
| 185 |
+
args=(action,),
|
| 186 |
+
use_container_width=True
|
| 187 |
+
)
|
| 188 |
+
|
| 189 |
+
st.markdown('</div>', unsafe_allow_html=True)
|
| 190 |
+
|
| 191 |
# --------------------------------------------------
|
| 192 |
# Score Calculation
|
| 193 |
# --------------------------------------------------
|
|
|
|
| 196 |
cost = 0
|
| 197 |
open_req = 0
|
| 198 |
|
| 199 |
+
for action in st.session_state.owner_selected:
|
| 200 |
+
cheating += model_owner_actions[action]["cheating"]
|
| 201 |
+
cost += model_owner_actions[action]["cost"]
|
| 202 |
+
open_req += model_owner_actions[action]["open"]
|
| 203 |
|
| 204 |
+
for action in st.session_state.auditor_selected:
|
| 205 |
+
cheating += auditor_actions[action]["cheating"]
|
| 206 |
+
cost += auditor_actions[action]["cost"]
|
| 207 |
+
open_req += auditor_actions[action]["open"]
|
| 208 |
|
| 209 |
cheating = max(0, min(100, cheating))
|
| 210 |
open_req = max(0, open_req)
|
|
|
|
| 217 |
|
| 218 |
c1, c2, c3 = st.columns(3)
|
| 219 |
|
| 220 |
+
c1.metric("Cheating Chance", f"{cheating}%")
|
| 221 |
+
c2.metric("Audit Cost", cost)
|
| 222 |
+
c3.metric("Openness Required", open_req)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 223 |
|
| 224 |
st.progress(cheating / 100)
|