rusticluftig commited on
Commit
8114ad7
1 Parent(s): b204628

Add infinite retries to fetching leaderboard data

Browse files
Files changed (1) hide show
  1. app.py +21 -13
app.py CHANGED
@@ -306,24 +306,32 @@ def restart_space():
306
 
307
 
308
  def main():
309
- subtensor, metagraph = get_subtensor_and_metagraph()
 
 
 
 
310
 
311
- model_data: List[ModelData] = get_subnet_data(subtensor, metagraph)
312
- model_data.sort(key=lambda x: x.incentive, reverse=True)
313
 
314
- vali_runs = get_wandb_runs(project=VALIDATOR_WANDB_PROJECT, filters={"config.type": "validator", "config.uid": 238})
315
 
316
- scores = get_scores([x.uid for x in model_data], vali_runs)
317
 
318
- current_block = metagraph.block.item()
319
- next_epoch_block = next_epoch(subtensor, current_block)
320
 
321
- validator_df = get_validator_weights(metagraph)
322
- weight_keys = set()
323
- for uid, stats in validator_df.items():
324
- weight_keys.update(stats[-1].keys())
325
-
326
- benchmarks, benchmark_timestamp = get_benchmarks()
 
 
 
 
327
 
328
  demo = gr.Blocks(css=".typewriter {font-family: 'JMH Typewriter', sans-serif;}")
329
  with demo:
 
306
 
307
 
308
  def main():
309
+ # To avoid leaderboard failures, infinitely try until we get all data
310
+ # needed to populate the dashboard
311
+ while True:
312
+ try:
313
+ subtensor, metagraph = get_subtensor_and_metagraph()
314
 
315
+ model_data: List[ModelData] = get_subnet_data(subtensor, metagraph)
316
+ model_data.sort(key=lambda x: x.incentive, reverse=True)
317
 
318
+ vali_runs = get_wandb_runs(project=VALIDATOR_WANDB_PROJECT, filters={"config.type": "validator", "config.uid": 238})
319
 
320
+ scores = get_scores([x.uid for x in model_data], vali_runs)
321
 
322
+ current_block = metagraph.block.item()
323
+ next_epoch_block = next_epoch(subtensor, current_block)
324
 
325
+ validator_df = get_validator_weights(metagraph)
326
+ weight_keys = set()
327
+ for uid, stats in validator_df.items():
328
+ weight_keys.update(stats[-1].keys())
329
+
330
+ benchmarks, benchmark_timestamp = get_benchmarks()
331
+ break
332
+ except Exception as e:
333
+ print(f"Failed to get data: {e}")
334
+ time.sleep(30)
335
 
336
  demo = gr.Blocks(css=".typewriter {font-family: 'JMH Typewriter', sans-serif;}")
337
  with demo: