Spaces:
Sleeping
Sleeping
Commit
·
65d3550
1
Parent(s):
fd9b0ed
Test 3
Browse files
app.py
CHANGED
|
@@ -71,53 +71,40 @@ def update_leader_info(leader_info, competition, best_model):
|
|
| 71 |
leader_info[competition]["UID"] = best_model["ID"]
|
| 72 |
leader_info[competition]["Days on Top"] = 1
|
| 73 |
return leader_info[competition]
|
| 74 |
-
@st.cache_data()
|
| 75 |
-
def load_competition_data(
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
|
|
|
|
|
|
| 84 |
|
| 85 |
# Streamlit app main function
|
| 86 |
def main():
|
| 87 |
st.title("LaUltimate Dashboard")
|
| 88 |
-
st.title("JEDZIESZMALINA")
|
| 89 |
st.subheader("Welcome to the Competition Dashboard!")
|
| 90 |
-
st.write("Explore the various AI competitions and their respective rankings. Select a competition to view more details and rankings.")
|
| 91 |
|
| 92 |
-
|
|
|
|
| 93 |
|
| 94 |
-
|
| 95 |
-
st.session_state.last_update_time = None
|
| 96 |
if "leader_info" not in st.session_state:
|
| 97 |
st.session_state.leader_info = {}
|
| 98 |
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
best_model = model_evaluations[competition].iloc[0]
|
| 105 |
-
st.session_state.leader_info[competition] = update_leader_info(st.session_state.leader_info, competition, best_model)
|
| 106 |
-
else:
|
| 107 |
-
st.session_state.leader_info[competition] = {
|
| 108 |
-
"Username": "N/A", "Model Name": "N/A", "Hotkey": "N/A",
|
| 109 |
-
"Date": "N/A", "UID": "N/A", "Days on Top": "N/A"
|
| 110 |
-
}
|
| 111 |
-
else:
|
| 112 |
-
competition_summaries, model_evaluations, _ = load_competition_data(st.session_state.last_update_time)
|
| 113 |
-
|
| 114 |
-
st.write(f"Last updated: {time.ctime(st.session_state.last_update_time)}")
|
| 115 |
|
| 116 |
st.markdown("### Competitions")
|
| 117 |
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
# Create a header for the table
|
| 121 |
cols = st.columns([1, 3, 2, 2, 2, 2, 1, 2])
|
| 122 |
cols[0].write("Index")
|
| 123 |
cols[1].write("Competition Name")
|
|
@@ -128,13 +115,14 @@ def main():
|
|
| 128 |
cols[6].write("Hotkey")
|
| 129 |
cols[7].write("Days on Top")
|
| 130 |
|
|
|
|
| 131 |
for index, (competition, details) in enumerate(projects.items(), start=1):
|
| 132 |
-
leader_info = st.session_state.
|
| 133 |
-
|
| 134 |
cols = st.columns([1, 3, 2, 2, 2, 2, 1, 2])
|
| 135 |
cols[0].write(index)
|
| 136 |
-
if cols[1].button(competition):
|
| 137 |
-
st.
|
| 138 |
cols[2].write(leader_info.get("Username", "N/A"))
|
| 139 |
cols[3].write(leader_info.get("Model Name", "N/A"))
|
| 140 |
cols[4].write(leader_info.get("Date", "N/A"))
|
|
@@ -142,38 +130,46 @@ def main():
|
|
| 142 |
cols[6].write(leader_info.get("Hotkey", "N/A"))
|
| 143 |
cols[7].write(leader_info.get("Days on Top", "N/A"))
|
| 144 |
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
competition_name =
|
| 148 |
-
else:
|
| 149 |
-
# Fallback for older Streamlit versions
|
| 150 |
-
competition_name = st.selectbox("Select a competition", list(projects.keys()))
|
| 151 |
-
|
| 152 |
-
if competition_name:
|
| 153 |
st.write(f"Selected competition: {competition_name}")
|
| 154 |
-
competition_details = projects.get(competition_name, {})
|
| 155 |
-
description = competition_details.get("description", "No description available.")
|
| 156 |
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 173 |
else:
|
| 174 |
st.write("Please select a competition to view details.")
|
| 175 |
|
| 176 |
-
|
| 177 |
# Run the app
|
| 178 |
if __name__ == "__main__":
|
| 179 |
main()
|
|
|
|
| 71 |
leader_info[competition]["UID"] = best_model["ID"]
|
| 72 |
leader_info[competition]["Days on Top"] = 1
|
| 73 |
return leader_info[competition]
|
| 74 |
+
@st.cache_data(ttl=60)
|
| 75 |
+
def load_competition_data():
|
| 76 |
+
ranking_dfs = {}
|
| 77 |
+
for competition, details in projects.items():
|
| 78 |
+
df = fetch_runs_to_df(api, projects, competition)
|
| 79 |
+
if not df.empty:
|
| 80 |
+
ranking_df = fetch_models_to_df(api, projects, competition, df)
|
| 81 |
+
rank_by = ["Recall", "Accuracy", "ROC AUC"]
|
| 82 |
+
ascending = [False, False, False]
|
| 83 |
+
ranking_df = ranking_df.sort_values(by=rank_by, ascending=ascending)
|
| 84 |
+
ranking_dfs[competition] = ranking_df
|
| 85 |
+
return ranking_dfs
|
| 86 |
|
| 87 |
# Streamlit app main function
|
| 88 |
def main():
|
| 89 |
st.title("LaUltimate Dashboard")
|
|
|
|
| 90 |
st.subheader("Welcome to the Competition Dashboard!")
|
|
|
|
| 91 |
|
| 92 |
+
# Load competition data
|
| 93 |
+
ranking_dfs = load_competition_data()
|
| 94 |
|
| 95 |
+
# Initialize or update leader_info
|
|
|
|
| 96 |
if "leader_info" not in st.session_state:
|
| 97 |
st.session_state.leader_info = {}
|
| 98 |
|
| 99 |
+
# Update leader info for each competition
|
| 100 |
+
for competition in ranking_dfs:
|
| 101 |
+
if not ranking_dfs[competition].empty:
|
| 102 |
+
best_model = ranking_dfs[competition].iloc[0]
|
| 103 |
+
st.session_state.leader_info[competition] = update_leader_info(st.session_state.leader_info, competition, best_model)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 104 |
|
| 105 |
st.markdown("### Competitions")
|
| 106 |
|
| 107 |
+
# Create a header for the table with additional columns
|
|
|
|
|
|
|
| 108 |
cols = st.columns([1, 3, 2, 2, 2, 2, 1, 2])
|
| 109 |
cols[0].write("Index")
|
| 110 |
cols[1].write("Competition Name")
|
|
|
|
| 115 |
cols[6].write("Hotkey")
|
| 116 |
cols[7].write("Days on Top")
|
| 117 |
|
| 118 |
+
# Display the project names in a table-like structure with buttons and placeholders for additional data
|
| 119 |
for index, (competition, details) in enumerate(projects.items(), start=1):
|
| 120 |
+
leader_info = st.session_state.leader_info.get(competition, {})
|
| 121 |
+
|
| 122 |
cols = st.columns([1, 3, 2, 2, 2, 2, 1, 2])
|
| 123 |
cols[0].write(index)
|
| 124 |
+
if cols[1].button(competition, key=f"btn_{competition}"):
|
| 125 |
+
st.session_state.selected_competition = competition
|
| 126 |
cols[2].write(leader_info.get("Username", "N/A"))
|
| 127 |
cols[3].write(leader_info.get("Model Name", "N/A"))
|
| 128 |
cols[4].write(leader_info.get("Date", "N/A"))
|
|
|
|
| 130 |
cols[6].write(leader_info.get("Hotkey", "N/A"))
|
| 131 |
cols[7].write(leader_info.get("Days on Top", "N/A"))
|
| 132 |
|
| 133 |
+
# Display selected competition details
|
| 134 |
+
if "selected_competition" in st.session_state:
|
| 135 |
+
competition_name = st.session_state.selected_competition
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 136 |
st.write(f"Selected competition: {competition_name}")
|
|
|
|
|
|
|
| 137 |
|
| 138 |
+
try:
|
| 139 |
+
competition_details = projects.get(competition_name, {})
|
| 140 |
+
description = competition_details.get("description", "No description available.")
|
| 141 |
+
|
| 142 |
+
st.header(f"Competition: {competition_name}")
|
| 143 |
+
st.write(description)
|
| 144 |
+
|
| 145 |
+
df = ranking_dfs.get(competition_name, pd.DataFrame())
|
| 146 |
+
if not df.empty:
|
| 147 |
+
st.subheader("Competition Summary")
|
| 148 |
+
try:
|
| 149 |
+
competition_summary_df = fetch_competition_summary(api, projects, competition_name, df)
|
| 150 |
+
if not competition_summary_df.empty:
|
| 151 |
+
st.dataframe(competition_summary_df)
|
| 152 |
+
else:
|
| 153 |
+
st.warning("No competition summary data available.")
|
| 154 |
+
except Exception as e:
|
| 155 |
+
st.error(f"Error fetching competition summary: {str(e)}")
|
| 156 |
+
|
| 157 |
+
st.subheader("Models Evaluation")
|
| 158 |
+
try:
|
| 159 |
+
models_evaluation_df = fetch_models_to_df(api, projects, competition_name, df)
|
| 160 |
+
if not models_evaluation_df.empty:
|
| 161 |
+
st.dataframe(models_evaluation_df)
|
| 162 |
+
else:
|
| 163 |
+
st.warning("No models evaluation data available.")
|
| 164 |
+
except Exception as e:
|
| 165 |
+
st.error(f"Error fetching models evaluation: {str(e)}")
|
| 166 |
+
else:
|
| 167 |
+
st.warning("No runs available for ranking.")
|
| 168 |
+
except Exception as e:
|
| 169 |
+
st.error(f"An error occurred while processing the competition data: {str(e)}")
|
| 170 |
else:
|
| 171 |
st.write("Please select a competition to view details.")
|
| 172 |
|
|
|
|
| 173 |
# Run the app
|
| 174 |
if __name__ == "__main__":
|
| 175 |
main()
|