add leaderboard and spinners
Browse files- app.py +96 -12
- dashboard_utils/bubbles.py +37 -0
- requirements.txt +2 -1
app.py
CHANGED
@@ -2,23 +2,93 @@ import pandas as pd
|
|
2 |
import streamlit as st
|
3 |
import wandb
|
4 |
|
5 |
-
from dashboard_utils.bubbles import get_new_bubble_data
|
6 |
from dashboard_utils.main_metrics import get_main_metrics
|
7 |
from streamlit_observable import observable
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
# Only need to set these here as we are add controls outside of Hydralit, to customise a run Hydralit!
|
10 |
-
st.set_page_config(page_title="Dashboard", layout="
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
wandb.login(anonymous="must")
|
13 |
|
14 |
-
st.markdown("<h1 style='text-align: center;'>Dashboard</h1>", unsafe_allow_html=True)
|
15 |
-
st.caption("Training Loss")
|
16 |
|
17 |
steps, dates, losses, alive_peers = get_main_metrics()
|
18 |
source = pd.DataFrame({"steps": steps, "loss": losses, "alive participants": alive_peers, "date": dates})
|
19 |
|
20 |
|
21 |
-
|
22 |
source,
|
23 |
{
|
24 |
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
|
@@ -30,8 +100,7 @@ st.vega_lite_chart(
|
|
30 |
use_container_width=True,
|
31 |
)
|
32 |
|
33 |
-
|
34 |
-
st.vega_lite_chart(
|
35 |
source,
|
36 |
{
|
37 |
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
|
@@ -45,8 +114,7 @@ st.vega_lite_chart(
|
|
45 |
},
|
46 |
use_container_width=True,
|
47 |
)
|
48 |
-
|
49 |
-
st.vega_lite_chart(
|
50 |
source,
|
51 |
{
|
52 |
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
|
@@ -58,11 +126,27 @@ st.vega_lite_chart(
|
|
58 |
use_container_width=True,
|
59 |
)
|
60 |
|
61 |
-
st.header("Collaborative training participants")
|
62 |
serialized_data, profiles = get_new_bubble_data()
|
|
|
63 |
observable(
|
64 |
-
"
|
65 |
notebook="d/9ae236a507f54046", # "@huggingface/participants-bubbles-chart",
|
66 |
targets=["c_noaws"],
|
67 |
-
redefine={"serializedData": serialized_data, "profileSimple": profiles},
|
68 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
import streamlit as st
|
3 |
import wandb
|
4 |
|
5 |
+
from dashboard_utils.bubbles import get_global_metrics, get_new_bubble_data, get_leaderboard
|
6 |
from dashboard_utils.main_metrics import get_main_metrics
|
7 |
from streamlit_observable import observable
|
8 |
+
import time
|
9 |
+
import requests
|
10 |
+
|
11 |
+
import streamlit as st
|
12 |
+
from streamlit_lottie import st_lottie
|
13 |
+
|
14 |
+
|
15 |
+
def load_lottieurl(url: str):
|
16 |
+
r = requests.get(url)
|
17 |
+
if r.status_code != 200:
|
18 |
+
return None
|
19 |
+
return r.json()
|
20 |
+
|
21 |
|
22 |
# Only need to set these here as we are add controls outside of Hydralit, to customise a run Hydralit!
|
23 |
+
st.set_page_config(page_title="Dashboard", layout="wide")
|
24 |
+
|
25 |
+
st.markdown("<h1 style='text-align: center;'>Dashboard</h1>", unsafe_allow_html=True)
|
26 |
+
|
27 |
+
key_figures_margin_left, key_figures_c1, key_figures_c2, key_figures_c3, key_figures_margin_right = st.columns(
|
28 |
+
(2, 1, 1, 1, 2)
|
29 |
+
)
|
30 |
+
chart_c1, chart_c2 = st.columns((3, 2))
|
31 |
+
|
32 |
+
lottie_url_loading = "https://assets5.lottiefiles.com/packages/lf20_OdNgAj.json"
|
33 |
+
lottie_loading = load_lottieurl(lottie_url_loading)
|
34 |
+
|
35 |
+
|
36 |
+
with key_figures_c1:
|
37 |
+
st.caption("\# of contributing users")
|
38 |
+
placeholder_key_figures_c1 = st.empty()
|
39 |
+
with placeholder_key_figures_c1:
|
40 |
+
st_lottie(lottie_loading, height=100, key="loading_key_figure_c1")
|
41 |
+
|
42 |
+
with key_figures_c2:
|
43 |
+
st.caption("\# active users")
|
44 |
+
placeholder_key_figures_c2 = st.empty()
|
45 |
+
with placeholder_key_figures_c2:
|
46 |
+
st_lottie(lottie_loading, height=100, key="loading_key_figure_c2")
|
47 |
+
|
48 |
+
with key_figures_c3:
|
49 |
+
st.caption("Total runtime")
|
50 |
+
placeholder_key_figures_c3 = st.empty()
|
51 |
+
with placeholder_key_figures_c3:
|
52 |
+
st_lottie(lottie_loading, height=100, key="loading_key_figure_c3")
|
53 |
+
|
54 |
+
with chart_c1:
|
55 |
+
st.subheader("Metrics over time")
|
56 |
+
st.caption("Training Loss")
|
57 |
+
placeholder_chart_c1_1 = st.empty()
|
58 |
+
with placeholder_chart_c1_1:
|
59 |
+
st_lottie(lottie_loading, height=100, key="loading_c1_1")
|
60 |
+
|
61 |
+
st.caption("Number of alive runs over time")
|
62 |
+
placeholder_chart_c1_2 = st.empty()
|
63 |
+
with placeholder_chart_c1_2:
|
64 |
+
st_lottie(lottie_loading, height=100, key="loading_c1_2")
|
65 |
+
|
66 |
+
st.caption("Number of steps")
|
67 |
+
placeholder_chart_c1_3 = st.empty()
|
68 |
+
with placeholder_chart_c1_3:
|
69 |
+
st_lottie(lottie_loading, height=100, key="loading_c1_3")
|
70 |
+
|
71 |
+
with chart_c2:
|
72 |
+
st.subheader("Global metrics")
|
73 |
+
st.caption("Collaborative training participants")
|
74 |
+
placeholder_chart_c2_1 = st.empty()
|
75 |
+
with placeholder_chart_c2_1:
|
76 |
+
st_lottie(lottie_loading, height=100, key="loading_c2_1")
|
77 |
+
|
78 |
+
st.caption("Leaderboard")
|
79 |
+
placeholder_chart_c2_2 = st.empty()
|
80 |
+
with placeholder_chart_c2_2:
|
81 |
+
st_lottie(lottie_loading, height=100, key="loading_c2_2")
|
82 |
+
|
83 |
|
84 |
wandb.login(anonymous="must")
|
85 |
|
|
|
|
|
86 |
|
87 |
steps, dates, losses, alive_peers = get_main_metrics()
|
88 |
source = pd.DataFrame({"steps": steps, "loss": losses, "alive participants": alive_peers, "date": dates})
|
89 |
|
90 |
|
91 |
+
placeholder_chart_c1_1.vega_lite_chart(
|
92 |
source,
|
93 |
{
|
94 |
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
|
|
|
100 |
use_container_width=True,
|
101 |
)
|
102 |
|
103 |
+
placeholder_chart_c1_2.vega_lite_chart(
|
|
|
104 |
source,
|
105 |
{
|
106 |
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
|
|
|
114 |
},
|
115 |
use_container_width=True,
|
116 |
)
|
117 |
+
placeholder_chart_c1_3.vega_lite_chart(
|
|
|
118 |
source,
|
119 |
{
|
120 |
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
|
|
|
126 |
use_container_width=True,
|
127 |
)
|
128 |
|
|
|
129 |
serialized_data, profiles = get_new_bubble_data()
|
130 |
+
df_leaderboard = get_leaderboard(serialized_data)
|
131 |
observable(
|
132 |
+
"_",
|
133 |
notebook="d/9ae236a507f54046", # "@huggingface/participants-bubbles-chart",
|
134 |
targets=["c_noaws"],
|
135 |
+
redefine={"serializedData": serialized_data, "profileSimple": profiles, "width": 0},
|
136 |
)
|
137 |
+
placeholder_chart_c2_2.dataframe(df_leaderboard[["User", "Total time contributed"]])
|
138 |
+
|
139 |
+
global_metrics = get_global_metrics(serialized_data)
|
140 |
+
|
141 |
+
placeholder_key_figures_c1.write(f"<b>{global_metrics['num_contributing_users']}</b>", unsafe_allow_html=True)
|
142 |
+
placeholder_key_figures_c2.write(f"<b>{global_metrics['num_active_users']}</b>", unsafe_allow_html=True)
|
143 |
+
placeholder_key_figures_c3.write(f"<b>{global_metrics['total_runtime']}</b>", unsafe_allow_html=True)
|
144 |
+
|
145 |
+
|
146 |
+
with placeholder_chart_c2_1:
|
147 |
+
observable(
|
148 |
+
"Participants",
|
149 |
+
notebook="d/9ae236a507f54046", # "@huggingface/participants-bubbles-chart",
|
150 |
+
targets=["c_noaws"],
|
151 |
+
redefine={"serializedData": serialized_data, "profileSimple": profiles},
|
152 |
+
)
|
dashboard_utils/bubbles.py
CHANGED
@@ -2,6 +2,8 @@ import datetime
|
|
2 |
from concurrent.futures import as_completed
|
3 |
from urllib import parse
|
4 |
|
|
|
|
|
5 |
import streamlit as st
|
6 |
import wandb
|
7 |
from requests_futures.sessions import FuturesSession
|
@@ -138,3 +140,38 @@ def get_serialized_data(serialized_data_points, latest_timestamp):
|
|
138 |
serialized_data_points_v2.append(new_item)
|
139 |
serialized_data = {"points": [serialized_data_points_v2], "maxVelocity": max_velocity}
|
140 |
return serialized_data
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
from concurrent.futures import as_completed
|
3 |
from urllib import parse
|
4 |
|
5 |
+
import pandas as pd
|
6 |
+
|
7 |
import streamlit as st
|
8 |
import wandb
|
9 |
from requests_futures.sessions import FuturesSession
|
|
|
140 |
serialized_data_points_v2.append(new_item)
|
141 |
serialized_data = {"points": [serialized_data_points_v2], "maxVelocity": max_velocity}
|
142 |
return serialized_data
|
143 |
+
|
144 |
+
def get_leaderboard(serialized_data):
|
145 |
+
data_leaderboard = {
|
146 |
+
"user": [],
|
147 |
+
"runtime": []
|
148 |
+
}
|
149 |
+
|
150 |
+
for user_item in serialized_data["points"][0]:
|
151 |
+
data_leaderboard["user"].append(user_item["profileId"])
|
152 |
+
data_leaderboard["runtime"].append(user_item["runtime"])
|
153 |
+
|
154 |
+
df = pd.DataFrame(data_leaderboard)
|
155 |
+
df = df.sort_values("runtime", ascending=False)
|
156 |
+
df["runtime"] = df["runtime"].apply(lambda x: datetime.timedelta(seconds=x))
|
157 |
+
df["runtime"] = df["runtime"].apply(lambda x: str(x))
|
158 |
+
|
159 |
+
df.reset_index(drop=True, inplace=True)
|
160 |
+
df.rename(columns={"user": "User", "runtime": "Total time contributed"}, inplace=True)
|
161 |
+
df["Rank"] = df.index + 1
|
162 |
+
df = df.set_index('Rank')
|
163 |
+
return df
|
164 |
+
|
165 |
+
def get_global_metrics(serialized_data):
|
166 |
+
num_contributing_users = len(serialized_data["points"][0])
|
167 |
+
num_active_users = 0
|
168 |
+
total_runtime = 0
|
169 |
+
|
170 |
+
for user_item in serialized_data["points"][0]:
|
171 |
+
if user_item["activeRuns"] != []:
|
172 |
+
num_active_users += 1
|
173 |
+
total_runtime += user_item["runtime"]
|
174 |
+
|
175 |
+
total_runtime = datetime.timedelta(seconds=total_runtime)
|
176 |
+
return {"num_contributing_users": num_contributing_users, "num_active_users": num_active_users, "total_runtime": total_runtime}
|
177 |
+
|
requirements.txt
CHANGED
@@ -1,3 +1,4 @@
|
|
1 |
streamlit
|
2 |
wandb
|
3 |
-
requests_futures
|
|
|
|
1 |
streamlit
|
2 |
wandb
|
3 |
+
requests_futures
|
4 |
+
streamlit-lottie
|