Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -12,7 +12,7 @@ FONT = """<link href="https://fonts.googleapis.com/css2?family=Roboto+Mono&displ
|
|
12 |
|
13 |
TITLE = """<h1 align="center" id="space-title" class="typewriter">Synthia Leaderboard</h1>"""
|
14 |
|
15 |
-
IMAGE = """<
|
16 |
|
17 |
HEADER = """
|
18 |
<h2 align="center" class="typewriter">Welcome to the Synthia Commune Leaderboard!</h2>
|
@@ -75,7 +75,7 @@ def make_query(client: CommuneClient) -> tuple[dict[int, int], dict[int, str]]:
|
|
75 |
if emission != 0:
|
76 |
incentive = netuid_incentive[uid]
|
77 |
dividends = netuid_dividends[uid]
|
78 |
-
|
79 |
if incentive > dividends:
|
80 |
emission_dict[uid] = netuid_emission[uid]
|
81 |
name_dict[uid] = names[uid]
|
@@ -95,13 +95,15 @@ async def get_leaderboard_data():
|
|
95 |
# we are doing ** 11 because emission are for modules have 2 extra units,
|
96 |
# (otherwise it would be more intuive to do ** 9, hence from_nano)
|
97 |
scores[uid] = (emi / 10**11) * blocks_in_day
|
98 |
-
sorted_scores = sorted(
|
|
|
99 |
leaderboard_data = []
|
100 |
for rank, (uid, score) in enumerate(sorted_scores, start=1):
|
101 |
name = name_dict[uid]
|
102 |
units = score
|
103 |
usd_value = score * com_price
|
104 |
-
leaderboard_data.append(
|
|
|
105 |
return leaderboard_data
|
106 |
except Exception as e:
|
107 |
print(f"Error fetching leaderboard data: {e}")
|
@@ -133,6 +135,7 @@ stone_gray = Color(
|
|
133 |
c950="#1a1a1a",
|
134 |
)
|
135 |
|
|
|
136 |
class Seafoam(Base):
|
137 |
def __init__(
|
138 |
self,
|
@@ -196,7 +199,8 @@ with gr.Blocks(theme=seafoam, analytics_enabled=True) as demo:
|
|
196 |
)
|
197 |
|
198 |
refresh_button = gr.Button("Refresh Leaderboard")
|
199 |
-
refresh_button.click(fn=update_leaderboard_table,
|
|
|
200 |
|
201 |
# Initial load of leaderboard data
|
202 |
demo.load(update_leaderboard_table, inputs=None, outputs=leaderboard_table)
|
|
|
12 |
|
13 |
TITLE = """<h1 align="center" id="space-title" class="typewriter">Synthia Leaderboard</h1>"""
|
14 |
|
15 |
+
IMAGE = """<p align="center" style="font-size: 72px;">πππππ
ππ</p>"""
|
16 |
|
17 |
HEADER = """
|
18 |
<h2 align="center" class="typewriter">Welcome to the Synthia Commune Leaderboard!</h2>
|
|
|
75 |
if emission != 0:
|
76 |
incentive = netuid_incentive[uid]
|
77 |
dividends = netuid_dividends[uid]
|
78 |
+
|
79 |
if incentive > dividends:
|
80 |
emission_dict[uid] = netuid_emission[uid]
|
81 |
name_dict[uid] = names[uid]
|
|
|
95 |
# we are doing ** 11 because emission are for modules have 2 extra units,
|
96 |
# (otherwise it would be more intuive to do ** 9, hence from_nano)
|
97 |
scores[uid] = (emi / 10**11) * blocks_in_day
|
98 |
+
sorted_scores = sorted(
|
99 |
+
scores.items(), key=lambda x: x[1], reverse=True)
|
100 |
leaderboard_data = []
|
101 |
for rank, (uid, score) in enumerate(sorted_scores, start=1):
|
102 |
name = name_dict[uid]
|
103 |
units = score
|
104 |
usd_value = score * com_price
|
105 |
+
leaderboard_data.append(
|
106 |
+
(rank, uid, name, units, f"${usd_value:.2f}"))
|
107 |
return leaderboard_data
|
108 |
except Exception as e:
|
109 |
print(f"Error fetching leaderboard data: {e}")
|
|
|
135 |
c950="#1a1a1a",
|
136 |
)
|
137 |
|
138 |
+
|
139 |
class Seafoam(Base):
|
140 |
def __init__(
|
141 |
self,
|
|
|
199 |
)
|
200 |
|
201 |
refresh_button = gr.Button("Refresh Leaderboard")
|
202 |
+
refresh_button.click(fn=update_leaderboard_table,
|
203 |
+
outputs=leaderboard_table)
|
204 |
|
205 |
# Initial load of leaderboard data
|
206 |
demo.load(update_leaderboard_table, inputs=None, outputs=leaderboard_table)
|