bobby-nakamoto commited on
Commit
ae329ab
1 Parent(s): b748005

Exclude Validators From Leaderboard

Browse files

Will hopefully make it so the leaderboard doesn't display validators

Files changed (1) hide show
  1. app.py +14 -0
app.py CHANGED
@@ -6,6 +6,8 @@ from gradio.themes.base import Base
6
  from gradio.themes.utils import colors, fonts, sizes
7
  from gradio.themes.utils.colors import Color
8
  from communex.client import CommuneClient
 
 
9
  import aiohttp
10
  import time
11
 
@@ -25,6 +27,15 @@ LANGUAGES_SUPPORTED = """
25
  netuid = 1
26
  node_url = "wss://commune-api-node-2.communeai.net"
27
 
 
 
 
 
 
 
 
 
 
28
  async def get_com_price(session: aiohttp.ClientSession) -> float:
29
  try:
30
  async with session.get("https://api.mexc.com/api/v3/avgPrice?symbol=COMAIUSDT") as response:
@@ -60,7 +71,10 @@ async def make_query(client: CommuneClient) -> tuple[dict[int, int], dict[int, s
60
 
61
  names = result["Name"]
62
  highest_uid = max(names.keys())
 
63
  for uid in range(highest_uid + 1):
 
 
64
  emission = netuid_emission[uid]
65
  if emission != 0:
66
  incentive = netuid_incentive[uid]
 
6
  from gradio.themes.utils import colors, fonts, sizes
7
  from gradio.themes.utils.colors import Color
8
  from communex.client import CommuneClient
9
+ from communex.misc import get_map_modules
10
+ from typing import Any, cast
11
  import aiohttp
12
  import time
13
 
 
27
  netuid = 1
28
  node_url = "wss://commune-api-node-2.communeai.net"
29
 
30
+ def get_validator_uids(client, netuid):
31
+ modules = cast(dict[str, Any], get_map_modules(client, netuid=netuid))
32
+ modules = [value for _, value in modules.items()]
33
+ validator_uids = []
34
+ for module in modules:
35
+ if not (module["incentive"] == module["dividends"] == 0 or module["incentive"] > module["dividends"]):
36
+ validator_uids.append(int(module['uid']))
37
+ return validator_uids
38
+
39
  async def get_com_price(session: aiohttp.ClientSession) -> float:
40
  try:
41
  async with session.get("https://api.mexc.com/api/v3/avgPrice?symbol=COMAIUSDT") as response:
 
71
 
72
  names = result["Name"]
73
  highest_uid = max(names.keys())
74
+ validator_uids = get_validator_uids(client, netuid)
75
  for uid in range(highest_uid + 1):
76
+ if uid in validator_uids:
77
+ continue
78
  emission = netuid_emission[uid]
79
  if emission != 0:
80
  incentive = netuid_incentive[uid]