winglian commited on
Commit
bec1c5f
1 Parent(s): 5c986f5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -22
app.py CHANGED
@@ -24,12 +24,20 @@ EVALUATION_HEADER = """<h3 align="center">Shows the latest internal evaluation s
24
  H4_TOKEN = os.environ.get("H4_TOKEN", None)
25
  API = HfApi(token=H4_TOKEN)
26
  REPO_ID = "winglian/finetuning_subnet_leaderboard"
27
- METAGRAPH_RETRIES = 5
28
- METAGRAPH_DELAY_SECS = 3
29
  NETUID = 6
30
  SUBNET_START_BLOCK = 2225782
31
  SECONDS_PER_BLOCK = 12
32
 
 
 
 
 
 
 
 
 
33
  def get_subtensor_and_metagraph() -> typing.Tuple[bt.subtensor, bt.metagraph]:
34
  for i in range(0, METAGRAPH_RETRIES):
35
  try:
@@ -53,6 +61,7 @@ class ModelData:
53
  block: int
54
  incentive: float
55
  emission: float
 
56
 
57
  @classmethod
58
  def from_compressed_str(cls, uid: int, hotkey: str, cs: str, block: int, incentive: float, emission: float):
@@ -65,6 +74,7 @@ class ModelData:
65
  name=tokens[1],
66
  commit=tokens[2] if tokens[2] != "None" else None,
67
  hash=tokens[3] if tokens[3] != "None" else None,
 
68
  block=block,
69
  incentive=incentive,
70
  emission=emission
@@ -173,33 +183,37 @@ with demo:
173
 
174
  gr.HTML(value=get_next_update())
175
 
176
- gr.Label(
177
- value={ f"{c.namespace}/{c.name} ({c.commit[0:8]}) · ${round(c.emission * tao_price, 2):,} (τ{round(c.emission, 2):,})": c.incentive for c in leaderboard_df if c.incentive},
178
- num_top_classes=10,
179
- )
180
 
181
-
182
- with gr.Accordion("Validator Stats"):
183
- validator_table = gr.components.Dataframe(
184
- value=[
185
- [uid, int(validator_df[uid][1]), round(validator_df[uid][0], 4)] + [validator_df[uid][-1].get(c.uid) for c in leaderboard_df if c.incentive]
186
- for uid, _ in sorted(
187
- zip(validator_df.keys(), [validator_df[x][1] for x in validator_df.keys()]),
188
- key=lambda x: x[1],
189
- reverse=True
190
  )
191
- ],
192
- headers=["UID", "Stake (τ)", "V-Trust"] + [f"{c.namespace}/{c.name} ({c.commit[0:8]})" for c in leaderboard_df if c.incentive],
193
- datatype=["number", "number", "number"] + ["number" for c in leaderboard_df if c.incentive],
194
- interactive=False,
195
- visible=True,
196
- )
 
 
 
 
 
 
 
 
 
 
 
197
 
198
  def restart_space():
199
  API.restart_space(repo_id=REPO_ID, token=H4_TOKEN)
200
 
201
  scheduler = BackgroundScheduler()
202
- scheduler.add_job(restart_space, "interval", seconds=60 * 10) # restart every 5 minutes
203
  scheduler.start()
204
 
205
  demo.launch()
 
24
  H4_TOKEN = os.environ.get("H4_TOKEN", None)
25
  API = HfApi(token=H4_TOKEN)
26
  REPO_ID = "winglian/finetuning_subnet_leaderboard"
27
+ METAGRAPH_RETRIES = 10
28
+ METAGRAPH_DELAY_SECS = 30
29
  NETUID = 6
30
  SUBNET_START_BLOCK = 2225782
31
  SECONDS_PER_BLOCK = 12
32
 
33
+ @dataclass
34
+ class Competition:
35
+ id: str
36
+ name: str
37
+
38
+ COMPETITIONS = [Competition(id="m1", name="mistral-7b"), Competition(id="g1", name="gemma-2b")]
39
+ DEFAULT_COMPETITION_ID = "g1"
40
+
41
  def get_subtensor_and_metagraph() -> typing.Tuple[bt.subtensor, bt.metagraph]:
42
  for i in range(0, METAGRAPH_RETRIES):
43
  try:
 
61
  block: int
62
  incentive: float
63
  emission: float
64
+ competition: str
65
 
66
  @classmethod
67
  def from_compressed_str(cls, uid: int, hotkey: str, cs: str, block: int, incentive: float, emission: float):
 
74
  name=tokens[1],
75
  commit=tokens[2] if tokens[2] != "None" else None,
76
  hash=tokens[3] if tokens[3] != "None" else None,
77
+ competition=tokens[4] if len(tokens) > 4 and tokens[4] != "None" else DEFAULT_COMPETITION_ID,
78
  block=block,
79
  incentive=incentive,
80
  emission=emission
 
183
 
184
  gr.HTML(value=get_next_update())
185
 
186
+ with gr.Tabs():
187
+ for competition in COMPETITIONS:
188
+ with gr.Tab(competition.name):
 
189
 
190
+ gr.Label(
191
+ value={ f"{c.namespace}/{c.name} ({c.commit[0:8]}, UID={c.uid}) · ${round(c.emission * tao_price, 2):,} (τ{round(c.emission, 2):,})": c.incentive for c in leaderboard_df if c.incentive and c.competition == competition.id},
192
+ num_top_classes=10,
 
 
 
 
 
 
193
  )
194
+
195
+
196
+ with gr.Accordion("Validator Stats"):
197
+ validator_table = gr.components.Dataframe(
198
+ value=[
199
+ [uid, int(validator_df[uid][1]), round(validator_df[uid][0], 4)] + [validator_df[uid][-1].get(c.uid) for c in leaderboard_df if c.incentive]
200
+ for uid, _ in sorted(
201
+ zip(validator_df.keys(), [validator_df[x][1] for x in validator_df.keys()]),
202
+ key=lambda x: x[1],
203
+ reverse=True
204
+ )
205
+ ],
206
+ headers=["UID", "Stake (τ)", "V-Trust"] + [f"{c.namespace}/{c.name} ({c.commit[0:8]})" for c in leaderboard_df if c.incentive],
207
+ datatype=["number", "number", "number"] + ["number" for c in leaderboard_df if c.incentive],
208
+ interactive=False,
209
+ visible=True,
210
+ )
211
 
212
  def restart_space():
213
  API.restart_space(repo_id=REPO_ID, token=H4_TOKEN)
214
 
215
  scheduler = BackgroundScheduler()
216
+ scheduler.add_job(restart_space, "interval", seconds=60 * 10) # restart every 10 minutes
217
  scheduler.start()
218
 
219
  demo.launch()