Spaces:
Runtime error
Runtime error
Remove double Repository calls
Browse files- app.py +2 -21
- background_task.py +6 -6
app.py
CHANGED
@@ -2,23 +2,14 @@ import json
|
|
2 |
import requests
|
3 |
from datasets import load_dataset
|
4 |
import gradio as gr
|
5 |
-
from huggingface_hub import HfApi, hf_hub_download
|
6 |
from huggingface_hub.repocard import metadata_load
|
7 |
import pandas as pd
|
8 |
from matchmaking import *
|
9 |
-
from background_task import init_matchmaking,
|
10 |
from apscheduler.schedulers.background import BackgroundScheduler
|
11 |
import asyncio
|
12 |
|
13 |
-
|
14 |
-
DATASET_REPO_URL = "https://huggingface.co/datasets/CarlCochet/BotFightData"
|
15 |
-
ELO_FILENAME = "soccer_elo.csv"
|
16 |
-
HF_TOKEN = os.environ.get("HF_TOKEN")
|
17 |
-
|
18 |
-
repo = Repository(
|
19 |
-
local_dir="soccer_elo", clone_from=DATASET_REPO_URL, use_auth_token=HF_TOKEN
|
20 |
-
)
|
21 |
-
|
22 |
matchmaking = Matchmaking()
|
23 |
api = HfApi()
|
24 |
|
@@ -27,16 +18,6 @@ scheduler = BackgroundScheduler()
|
|
27 |
scheduler.add_job(func=init_matchmaking, trigger="interval", seconds=15000)
|
28 |
scheduler.start()
|
29 |
|
30 |
-
# loop = asyncio.get_event_loop()
|
31 |
-
# loop.create_task(run_background_loop())
|
32 |
-
# loop.run_forever()
|
33 |
-
|
34 |
-
|
35 |
-
def get_elo_data() -> pd.DataFrame:
|
36 |
-
repo.git_pull()
|
37 |
-
data = pd.read_csv(os.path.join(DATASET_REPO_URL, "resolve", "main", ELO_FILENAME))
|
38 |
-
return data
|
39 |
-
|
40 |
|
41 |
def update_elos():
|
42 |
matchmaking.read_history()
|
|
|
2 |
import requests
|
3 |
from datasets import load_dataset
|
4 |
import gradio as gr
|
5 |
+
from huggingface_hub import HfApi, hf_hub_download
|
6 |
from huggingface_hub.repocard import metadata_load
|
7 |
import pandas as pd
|
8 |
from matchmaking import *
|
9 |
+
from background_task import init_matchmaking, get_elo_data
|
10 |
from apscheduler.schedulers.background import BackgroundScheduler
|
11 |
import asyncio
|
12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
matchmaking = Matchmaking()
|
14 |
api = HfApi()
|
15 |
|
|
|
18 |
scheduler.add_job(func=init_matchmaking, trigger="interval", seconds=15000)
|
19 |
scheduler.start()
|
20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
|
22 |
def update_elos():
|
23 |
matchmaking.read_history()
|
background_task.py
CHANGED
@@ -179,6 +179,12 @@ def get_models_list() -> list:
|
|
179 |
return models
|
180 |
|
181 |
|
|
|
|
|
|
|
|
|
|
|
|
|
182 |
def init_matchmaking():
|
183 |
models = get_models_list()
|
184 |
# matchmaking = Matchmaking(models)
|
@@ -187,12 +193,6 @@ def init_matchmaking():
|
|
187 |
print("Matchmaking done ---", datetime.now().strftime("%Y-%m-%d %H:%M:%S.%f"))
|
188 |
|
189 |
|
190 |
-
async def run_background_loop():
|
191 |
-
while True:
|
192 |
-
print("It's running!", datetime.now().strftime("%Y-%m-%d %H:%M:%S.%f"))
|
193 |
-
await asyncio.sleep(60)
|
194 |
-
|
195 |
-
|
196 |
if __name__ == "__main__":
|
197 |
print("It's running!")
|
198 |
api = HfApi()
|
|
|
179 |
return models
|
180 |
|
181 |
|
182 |
+
def get_elo_data() -> pd.DataFrame:
|
183 |
+
repo.git_pull()
|
184 |
+
data = pd.read_csv(os.path.join(DATASET_REPO_URL, "resolve", "main", ELO_FILENAME))
|
185 |
+
return data
|
186 |
+
|
187 |
+
|
188 |
def init_matchmaking():
|
189 |
models = get_models_list()
|
190 |
# matchmaking = Matchmaking(models)
|
|
|
193 |
print("Matchmaking done ---", datetime.now().strftime("%Y-%m-%d %H:%M:%S.%f"))
|
194 |
|
195 |
|
|
|
|
|
|
|
|
|
|
|
|
|
196 |
if __name__ == "__main__":
|
197 |
print("It's running!")
|
198 |
api = HfApi()
|