winglian commited on
Commit
d3717aa
1 Parent(s): e85811c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -0
app.py CHANGED
@@ -5,9 +5,12 @@ from bittensor.extrinsics.serving import get_metadata
5
  from dataclasses import dataclass
6
  import requests
7
  import math
 
8
  import datetime
9
  import time
10
  from dotenv import load_dotenv
 
 
11
 
12
  load_dotenv()
13
 
@@ -17,6 +20,8 @@ IMAGE = """<a href="https://discord.gg/jqVphNsB4H" target="_blank"><img src="htt
17
  HEADER = """<h2 align="center" class="typewriter"><a href="https://github.com/NousResearch/finetuning-subnet" target="_blank">Subnet 6</a> is a <a href="https://bittensor.com/" target="_blank">Bittensor</a> subnet that incentivizes the creation of the best open models by evaluating submissions on a constant stream of newly generated synthetic GPT-4 data. The models with the best <a href="https://github.com/NousResearch/finetuning-subnet/blob/master/docs/validator.md" target="_blank">head-to-head loss</a> on the evaluation data receive a steady emission of TAO.</h3>"""
18
  EVALUATION_DETAILS = """<b>Name</b> is the 🤗 Hugging Face model name (click to go to the model card). <b>Rewards / Day</b> are the expected rewards per day for each model. <b>Perplexity</b> is represents the loss on all of the evaluation data for the model as calculated by the validator (lower is better). <b>UID</b> is the Bittensor user id of the submitter. <b>Block</b> is the Bittensor block that the model was submitted in. More stats on <a href="https://taostats.io/subnets/netuid-6/" target="_blank">taostats</a>."""
19
  EVALUATION_HEADER = """<h3 align="center">Shows the latest internal evaluation statistics as calculated by a validator run by Nous Research</h3>"""
 
 
20
  REPO_ID = "NousResearch/finetuning_subnet_leaderboard"
21
  METAGRAPH_RETRIES = 5
22
  METAGRAPH_DELAY_SECS = 3
@@ -202,4 +207,11 @@ with demo:
202
  visible=True,
203
  )
204
 
 
 
 
 
 
 
 
205
  demo.launch()
 
5
  from dataclasses import dataclass
6
  import requests
7
  import math
8
+ import os
9
  import datetime
10
  import time
11
  from dotenv import load_dotenv
12
+ from huggingface_hub import HfApi
13
+ from apscheduler.schedulers.background import BackgroundScheduler
14
 
15
  load_dotenv()
16
 
 
20
  HEADER = """<h2 align="center" class="typewriter"><a href="https://github.com/NousResearch/finetuning-subnet" target="_blank">Subnet 6</a> is a <a href="https://bittensor.com/" target="_blank">Bittensor</a> subnet that incentivizes the creation of the best open models by evaluating submissions on a constant stream of newly generated synthetic GPT-4 data. The models with the best <a href="https://github.com/NousResearch/finetuning-subnet/blob/master/docs/validator.md" target="_blank">head-to-head loss</a> on the evaluation data receive a steady emission of TAO.</h3>"""
21
  EVALUATION_DETAILS = """<b>Name</b> is the 🤗 Hugging Face model name (click to go to the model card). <b>Rewards / Day</b> are the expected rewards per day for each model. <b>Perplexity</b> is represents the loss on all of the evaluation data for the model as calculated by the validator (lower is better). <b>UID</b> is the Bittensor user id of the submitter. <b>Block</b> is the Bittensor block that the model was submitted in. More stats on <a href="https://taostats.io/subnets/netuid-6/" target="_blank">taostats</a>."""
22
  EVALUATION_HEADER = """<h3 align="center">Shows the latest internal evaluation statistics as calculated by a validator run by Nous Research</h3>"""
23
+ H4_TOKEN = os.environ.get("H4_TOKEN", None)
24
+ API = HfApi(token=H4_TOKEN)
25
  REPO_ID = "NousResearch/finetuning_subnet_leaderboard"
26
  METAGRAPH_RETRIES = 5
27
  METAGRAPH_DELAY_SECS = 3
 
207
  visible=True,
208
  )
209
 
210
+ def restart_space():
211
+ API.restart_space(repo_id=REPO_ID, token=H4_TOKEN)
212
+
213
+ scheduler = BackgroundScheduler()
214
+ scheduler.add_job(restart_space, "interval", seconds=60 * 10) # restart every 10 minutes
215
+ scheduler.start()
216
+
217
  demo.launch()