Spaces:
Sleeping
Sleeping
config changes
Browse files
app.py
CHANGED
@@ -5,7 +5,7 @@ import os
|
|
5 |
import time
|
6 |
import datetime
|
7 |
from typing import Dict, Any
|
8 |
-
from utils import fetch_competition_summary, fetch_models_evaluation, highlight_score_column,
|
9 |
# from dotenv import load_dotenv
|
10 |
from cfg import *
|
11 |
# load_dotenv()
|
@@ -58,11 +58,10 @@ def update_leader_info(
|
|
58 |
def load_competition_data(last_update_time=None):
|
59 |
competition_summaries = {}
|
60 |
model_evaluations = {}
|
61 |
-
|
62 |
-
for competition in
|
63 |
-
|
64 |
-
|
65 |
-
model_evaluations[competition] = fetch_models_evaluation(wandb_api, COMPETITIONS, competition)
|
66 |
|
67 |
last_update_time = time.time()
|
68 |
return competition_summaries, model_evaluations, last_update_time
|
@@ -71,7 +70,7 @@ def load_competition_data(last_update_time=None):
|
|
71 |
def main():
|
72 |
st.markdown(HEADER, unsafe_allow_html=True)
|
73 |
|
74 |
-
|
75 |
|
76 |
if 'last_update_time' not in st.session_state:
|
77 |
st.session_state.last_update_time = None
|
@@ -83,9 +82,7 @@ def main():
|
|
83 |
if st.session_state.last_update_time is None or (time.time() - st.session_state.last_update_time > UPDATE_INTERVAL):
|
84 |
competition_summaries, model_evaluations, st.session_state.last_update_time = load_competition_data(st.session_state.last_update_time)
|
85 |
|
86 |
-
for competition in
|
87 |
-
if COMPETITIONS[competition]["project"] not in competitions_id:
|
88 |
-
continue
|
89 |
if not competition_summaries[competition].empty:
|
90 |
# get all winning hotkeys and number of wins
|
91 |
winning_hotkeys = competition_summaries[competition]["Winning Hotkey"].value_counts()
|
@@ -124,9 +121,7 @@ def main():
|
|
124 |
col.write(header)
|
125 |
|
126 |
|
127 |
-
for index,
|
128 |
-
if COMPETITIONS[competition]["project"] not in competitions_id:
|
129 |
-
continue
|
130 |
|
131 |
leader_info = st.session_state.get("leader_info", {}).get(competition, {})
|
132 |
|
@@ -140,17 +135,12 @@ def main():
|
|
140 |
cols[4].write(leader_info.get("Days on Top", "N/A"))
|
141 |
if st.session_state.selected_competition:
|
142 |
competition_name = st.session_state.selected_competition
|
143 |
-
competition_details = COMPETITIONS.get(competition_name, {})
|
144 |
-
description = competition_details.get("description", "No description available.")
|
145 |
|
146 |
st.subheader(f"Competition: {competition_name}")
|
147 |
-
st.write(description)
|
148 |
|
149 |
# Add search bar for miner hotkey
|
150 |
miner_hotkey_search = st.text_input("Search for Miner Hotkey", "")
|
151 |
|
152 |
-
st.write(description)
|
153 |
-
|
154 |
st.subheader("Competition Summary")
|
155 |
competition_summary_df = competition_summaries.get(competition_name, pd.DataFrame())
|
156 |
|
|
|
5 |
import time
|
6 |
import datetime
|
7 |
from typing import Dict, Any
|
8 |
+
from utils import fetch_competition_summary, fetch_models_evaluation, highlight_score_column, get_competitions
|
9 |
# from dotenv import load_dotenv
|
10 |
from cfg import *
|
11 |
# load_dotenv()
|
|
|
58 |
def load_competition_data(last_update_time=None):
|
59 |
competition_summaries = {}
|
60 |
model_evaluations = {}
|
61 |
+
competitions = get_competitions(CONFIG_URL)
|
62 |
+
for competition in competitions:
|
63 |
+
competition_summaries[competition] = fetch_competition_summary(wandb_api, ENTITY, competition)
|
64 |
+
model_evaluations[competition] = fetch_models_evaluation(wandb_api, ENTITY, competition)
|
|
|
65 |
|
66 |
last_update_time = time.time()
|
67 |
return competition_summaries, model_evaluations, last_update_time
|
|
|
70 |
def main():
|
71 |
st.markdown(HEADER, unsafe_allow_html=True)
|
72 |
|
73 |
+
competitions = get_competitions(CONFIG_URL)
|
74 |
|
75 |
if 'last_update_time' not in st.session_state:
|
76 |
st.session_state.last_update_time = None
|
|
|
82 |
if st.session_state.last_update_time is None or (time.time() - st.session_state.last_update_time > UPDATE_INTERVAL):
|
83 |
competition_summaries, model_evaluations, st.session_state.last_update_time = load_competition_data(st.session_state.last_update_time)
|
84 |
|
85 |
+
for competition in competitions:
|
|
|
|
|
86 |
if not competition_summaries[competition].empty:
|
87 |
# get all winning hotkeys and number of wins
|
88 |
winning_hotkeys = competition_summaries[competition]["Winning Hotkey"].value_counts()
|
|
|
121 |
col.write(header)
|
122 |
|
123 |
|
124 |
+
for index, competition in enumerate(competitions, start=1):
|
|
|
|
|
125 |
|
126 |
leader_info = st.session_state.get("leader_info", {}).get(competition, {})
|
127 |
|
|
|
135 |
cols[4].write(leader_info.get("Days on Top", "N/A"))
|
136 |
if st.session_state.selected_competition:
|
137 |
competition_name = st.session_state.selected_competition
|
|
|
|
|
138 |
|
139 |
st.subheader(f"Competition: {competition_name}")
|
|
|
140 |
|
141 |
# Add search bar for miner hotkey
|
142 |
miner_hotkey_search = st.text_input("Search for Miner Hotkey", "")
|
143 |
|
|
|
|
|
144 |
st.subheader("Competition Summary")
|
145 |
competition_summary_df = competition_summaries.get(competition_name, pd.DataFrame())
|
146 |
|
cfg.py
CHANGED
@@ -2,21 +2,7 @@ UPDATE_INTERVAL = 2 * 60 # 20 minutes in seconds
|
|
2 |
|
3 |
CONFIG_URL = "https://raw.githubusercontent.com/safe-scan-ai/cancer-ai/main/config/competition_config.json"
|
4 |
|
5 |
-
|
6 |
-
"Melanoma-1": {
|
7 |
-
"entity": "safe-scan-ai",
|
8 |
-
"project": "melanoma-1",
|
9 |
-
"description": "This is a testnet competition for melanoma detection."
|
10 |
-
},
|
11 |
-
"Melanoma-testnet": {
|
12 |
-
"entity": "safe-scan-ai",
|
13 |
-
"project": "melanoma-testnet",
|
14 |
-
"description": "This is a testnet competition for melanoma detection."
|
15 |
-
},
|
16 |
-
|
17 |
-
# Add more projects as needed
|
18 |
-
}
|
19 |
-
|
20 |
|
21 |
|
22 |
HEADER = """
|
|
|
2 |
|
3 |
CONFIG_URL = "https://raw.githubusercontent.com/safe-scan-ai/cancer-ai/main/config/competition_config.json"
|
4 |
|
5 |
+
ENTITY = "safe-scan-ai"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
|
8 |
HEADER = """
|
utils.py
CHANGED
@@ -6,7 +6,7 @@ from datetime import datetime
|
|
6 |
import requests
|
7 |
|
8 |
|
9 |
-
def
|
10 |
"""
|
11 |
Get competition names from the config URL.
|
12 |
"""
|
@@ -20,11 +20,11 @@ def get_competition_id(CONFIG_URL):
|
|
20 |
return competition_names
|
21 |
|
22 |
|
23 |
-
def fetch_competition_summary(api,
|
24 |
data = []
|
25 |
|
26 |
-
entity = projects[selected_project]["entity"]
|
27 |
-
project = projects[selected_project]["project"]
|
28 |
|
29 |
runs = api.runs(f"{entity}/{project}")
|
30 |
|
@@ -48,11 +48,11 @@ def fetch_competition_summary(api, projects, selected_project):
|
|
48 |
|
49 |
return df
|
50 |
|
51 |
-
def fetch_models_evaluation(api,
|
52 |
data = []
|
53 |
|
54 |
-
entity = projects[selected_project]["entity"]
|
55 |
-
project = projects[selected_project]["project"]
|
56 |
|
57 |
runs = api.runs(f"{entity}/{project}")
|
58 |
|
|
|
6 |
import requests
|
7 |
|
8 |
|
9 |
+
def get_competitions(CONFIG_URL):
|
10 |
"""
|
11 |
Get competition names from the config URL.
|
12 |
"""
|
|
|
20 |
return competition_names
|
21 |
|
22 |
|
23 |
+
def fetch_competition_summary(api, entity, project):
|
24 |
data = []
|
25 |
|
26 |
+
# entity = projects[selected_project]["entity"]
|
27 |
+
# project = projects[selected_project]["project"]
|
28 |
|
29 |
runs = api.runs(f"{entity}/{project}")
|
30 |
|
|
|
48 |
|
49 |
return df
|
50 |
|
51 |
+
def fetch_models_evaluation(api, entity, project):
|
52 |
data = []
|
53 |
|
54 |
+
# entity = projects[selected_project]["entity"]
|
55 |
+
# project = projects[selected_project]["project"]
|
56 |
|
57 |
runs = api.runs(f"{entity}/{project}")
|
58 |
|