afght12 commited on
Commit
2da42f8
1 Parent(s): d9baa86

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -8
app.py CHANGED
@@ -27,8 +27,7 @@ def get_leaderboard_data():
27
  com_price = get_com_price()
28
  blocks_in_day = 10_800
29
  client = CommuneClient(node_url)
30
- #emission = client.query("Emission", params=[netuid])
31
- emission = [1212212112121212, 1212122122, 112122121211]
32
  scores = {}
33
  for uid, emi in enumerate(emission):
34
  scores[uid] = ((emi / 10**11) * blocks_in_day) * com_price
@@ -44,6 +43,10 @@ def get_leaderboard_data():
44
  print(f"Error fetching leaderboard data: {e}")
45
  return []
46
 
 
 
 
 
47
  with gr.Blocks() as demo:
48
  gr.Markdown("# Commune Leaderboard")
49
 
@@ -51,16 +54,13 @@ with gr.Blocks() as demo:
51
  headers=["rank", "uid", "score"],
52
  datatype=["number", "number", "number"],
53
  interactive=False,
54
- visible=True
 
55
  )
56
 
57
  refresh_button = gr.Button("Refresh Leaderboard")
58
 
59
- def refresh_leaderboard():
60
- leaderboard_data = get_leaderboard_data()
61
- return gr.components.DataFrame.update(value=leaderboard_data)
62
-
63
- refresh_button.click(fn=refresh_leaderboard, outputs=leaderboard_table)
64
 
65
  # Initial load of leaderboard data
66
  leaderboard_data = get_leaderboard_data()
 
27
  com_price = get_com_price()
28
  blocks_in_day = 10_800
29
  client = CommuneClient(node_url)
30
+ emission = client.query("Emission", params=[netuid])
 
31
  scores = {}
32
  for uid, emi in enumerate(emission):
33
  scores[uid] = ((emi / 10**11) * blocks_in_day) * com_price
 
43
  print(f"Error fetching leaderboard data: {e}")
44
  return []
45
 
46
+ def update_leaderboard_table():
47
+ leaderboard_data = get_leaderboard_data()
48
+ return gr.components.DataFrame.update(value=leaderboard_data)
49
+
50
  with gr.Blocks() as demo:
51
  gr.Markdown("# Commune Leaderboard")
52
 
 
54
  headers=["rank", "uid", "score"],
55
  datatype=["number", "number", "number"],
56
  interactive=False,
57
+ visible=True,
58
+ elem_id="leaderboard-table"
59
  )
60
 
61
  refresh_button = gr.Button("Refresh Leaderboard")
62
 
63
+ refresh_button.click(fn=update_leaderboard_table, outputs=leaderboard_table)
 
 
 
 
64
 
65
  # Initial load of leaderboard data
66
  leaderboard_data = get_leaderboard_data()