ashikshaffi08
commited on
Commit
•
a749388
1
Parent(s):
3eaa599
Update app.py
Browse files
app.py
CHANGED
@@ -21,7 +21,6 @@ LANGUAGES_SUPPORTED = """
|
|
21 |
<h3 align="center">Languages Supported</h3>
|
22 |
<p align="center">Arabic, Chinese, English, French, German, Hebrew, Hindi, Portuguese, Russian, Spanish, Urdu, Vietnamese, and more to come!</p>
|
23 |
"""
|
24 |
-
|
25 |
netuid = 1
|
26 |
node_url = "wss://commune-api-node-2.communeai.net"
|
27 |
|
@@ -52,6 +51,8 @@ async def make_query(client: CommuneClient) -> tuple[dict[int, int], dict[int, s
|
|
52 |
name_dict = {}
|
53 |
result = client.query_batch_map(request_dict)
|
54 |
|
|
|
|
|
55 |
emission = result["Emission"]
|
56 |
netuid_emission = emission[netuid]
|
57 |
incentive = result["Incentive"]
|
@@ -62,13 +63,15 @@ async def make_query(client: CommuneClient) -> tuple[dict[int, int], dict[int, s
|
|
62 |
names = result["Name"]
|
63 |
highest_uid = max(names.keys())
|
64 |
for uid in range(highest_uid + 1):
|
65 |
-
emission = netuid_emission
|
66 |
if emission != 0:
|
67 |
-
incentive = netuid_incentive
|
68 |
-
dividends = netuid_dividends
|
69 |
if incentive > 0:
|
70 |
-
emission_dict[uid] =
|
71 |
name_dict[uid] = names[uid]
|
|
|
|
|
72 |
return emission_dict, name_dict
|
73 |
|
74 |
async def get_leaderboard_data():
|
@@ -89,6 +92,7 @@ async def get_leaderboard_data():
|
|
89 |
units = score
|
90 |
usd_value = score * com_price
|
91 |
leaderboard_data.append((rank, uid, name, units, f"${usd_value:.2f}"))
|
|
|
92 |
return leaderboard_data
|
93 |
except Exception as e:
|
94 |
print(f"Error fetching leaderboard data: {e}")
|
@@ -203,10 +207,10 @@ with gr.Blocks(theme=seafoam, analytics_enabled=True, css=custom_css) as demo:
|
|
203 |
elem_id="leaderboard-table",
|
204 |
)
|
205 |
refresh_button = gr.Button("Refresh Leaderboard")
|
206 |
-
refresh_button.click(fn=
|
207 |
leaderboard_table, total_usd_value_html])
|
208 |
|
209 |
-
demo.load(
|
210 |
leaderboard_table, total_usd_value_html])
|
211 |
|
212 |
if __name__ == "__main__":
|
|
|
21 |
<h3 align="center">Languages Supported</h3>
|
22 |
<p align="center">Arabic, Chinese, English, French, German, Hebrew, Hindi, Portuguese, Russian, Spanish, Urdu, Vietnamese, and more to come!</p>
|
23 |
"""
|
|
|
24 |
netuid = 1
|
25 |
node_url = "wss://commune-api-node-2.communeai.net"
|
26 |
|
|
|
51 |
name_dict = {}
|
52 |
result = client.query_batch_map(request_dict)
|
53 |
|
54 |
+
print("Query result:", result)
|
55 |
+
|
56 |
emission = result["Emission"]
|
57 |
netuid_emission = emission[netuid]
|
58 |
incentive = result["Incentive"]
|
|
|
63 |
names = result["Name"]
|
64 |
highest_uid = max(names.keys())
|
65 |
for uid in range(highest_uid + 1):
|
66 |
+
emission = netuid_emission[uid]
|
67 |
if emission != 0:
|
68 |
+
incentive = netuid_incentive[uid]
|
69 |
+
dividends = netuid_dividends[uid]
|
70 |
if incentive > 0:
|
71 |
+
emission_dict[uid] = netuid_emission[uid]
|
72 |
name_dict[uid] = names[uid]
|
73 |
+
print("Emission dict:", emission_dict)
|
74 |
+
print("Name dict:", name_dict)
|
75 |
return emission_dict, name_dict
|
76 |
|
77 |
async def get_leaderboard_data():
|
|
|
92 |
units = score
|
93 |
usd_value = score * com_price
|
94 |
leaderboard_data.append((rank, uid, name, units, f"${usd_value:.2f}"))
|
95 |
+
print("Leaderboard data:", leaderboard_data)
|
96 |
return leaderboard_data
|
97 |
except Exception as e:
|
98 |
print(f"Error fetching leaderboard data: {e}")
|
|
|
207 |
elem_id="leaderboard-table",
|
208 |
)
|
209 |
refresh_button = gr.Button("Refresh Leaderboard")
|
210 |
+
refresh_button.click(fn=update_leaderboard_table, outputs=[
|
211 |
leaderboard_table, total_usd_value_html])
|
212 |
|
213 |
+
demo.load(update_leaderboard_table, inputs=None, outputs=[
|
214 |
leaderboard_table, total_usd_value_html])
|
215 |
|
216 |
if __name__ == "__main__":
|