Spaces:
Runtime error
Runtime error
Reset match history after load
Browse files- background_task.py +13 -0
background_task.py
CHANGED
@@ -6,13 +6,20 @@ from datetime import datetime
|
|
6 |
from huggingface_hub import HfApi, Repository
|
7 |
|
8 |
DATASET_REPO_URL = "https://huggingface.co/datasets/CarlCochet/BotFightData"
|
|
|
9 |
ELO_FILENAME = "soccer_elo.csv"
|
|
|
10 |
ELO_DIR = "soccer_elo"
|
|
|
11 |
HF_TOKEN = os.environ.get("HF_TOKEN")
|
12 |
|
13 |
repo = Repository(
|
14 |
local_dir=ELO_DIR, clone_from=DATASET_REPO_URL, use_auth_token=HF_TOKEN
|
15 |
)
|
|
|
|
|
|
|
|
|
16 |
api = HfApi()
|
17 |
os.chmod('./SoccerTows.x86_64', 0o755)
|
18 |
|
@@ -96,6 +103,12 @@ class Matchmaking:
|
|
96 |
self.matches["model2"].append(model2.name)
|
97 |
self.matches["result"].append(result)
|
98 |
self.matches["timestamp"].append(row["timestamp"])
|
|
|
|
|
|
|
|
|
|
|
|
|
99 |
|
100 |
def find_model(self, author, name):
|
101 |
""" Find a model in the models list. """
|
|
|
6 |
from huggingface_hub import HfApi, Repository
|
7 |
|
8 |
DATASET_REPO_URL = "https://huggingface.co/datasets/CarlCochet/BotFightData"
|
9 |
+
DATASET_TEMP_REPO_URL = "https://huggingface.co/datasets/huggingface-projects/temp-match-results"
|
10 |
ELO_FILENAME = "soccer_elo.csv"
|
11 |
+
TEMP_FILENAME = "results.csv"
|
12 |
ELO_DIR = "soccer_elo"
|
13 |
+
TEMP_DIR = "temp"
|
14 |
HF_TOKEN = os.environ.get("HF_TOKEN")
|
15 |
|
16 |
repo = Repository(
|
17 |
local_dir=ELO_DIR, clone_from=DATASET_REPO_URL, use_auth_token=HF_TOKEN
|
18 |
)
|
19 |
+
repo_temp = Repository(
|
20 |
+
local_dir=ELO_DIR, clone_from=DATASET_TEMP_REPO_URL, use_auth_token=HF_TOKEN
|
21 |
+
)
|
22 |
+
|
23 |
api = HfApi()
|
24 |
os.chmod('./SoccerTows.x86_64', 0o755)
|
25 |
|
|
|
103 |
self.matches["model2"].append(model2.name)
|
104 |
self.matches["result"].append(result)
|
105 |
self.matches["timestamp"].append(row["timestamp"])
|
106 |
+
data_dict = {"model1": [], "model2": [], "timestamp": [], "result": []}
|
107 |
+
df = pd.DataFrame(data_dict)
|
108 |
+
print(df.head())
|
109 |
+
repo_temp.git_pull()
|
110 |
+
df.to_csv(os.path.join(TEMP_DIR, TEMP_FILENAME), index=False)
|
111 |
+
repo_temp.push_to_hub(commit_message="Reset results.csv")
|
112 |
|
113 |
def find_model(self, author, name):
|
114 |
""" Find a model in the models list. """
|