TheXeos commited on
Commit
ab30b6b
1 Parent(s): b0e6a26

Check if model is none

Browse files
Files changed (1) hide show
  1. background_task.py +8 -7
background_task.py CHANGED
@@ -7,13 +7,11 @@ import pandas as pd
7
  from datetime import datetime
8
  from huggingface_hub import HfApi, Repository
9
 
10
-
11
  DATASET_REPO_URL = "https://huggingface.co/datasets/CarlCochet/BotFightData"
12
  ELO_FILENAME = "soccer_elo.csv"
13
  ELO_DIR = "soccer_elo"
14
  HF_TOKEN = os.environ.get("HF_TOKEN")
15
 
16
-
17
  subprocess.run("rm -rf .git/hooks".split())
18
  repo = Repository(
19
  local_dir=ELO_DIR, clone_from=DATASET_REPO_URL, use_auth_token=HF_TOKEN
@@ -30,6 +28,7 @@ class Model:
30
  :param elo: Elo rating of the model
31
  :param games_played: Number of games played by the model (useful if we implement sigma uncertainty)
32
  """
 
33
  def __init__(self, author, name, elo=1200, games_played=0):
34
  self.author = author
35
  self.name = name
@@ -47,6 +46,7 @@ class Matchmaking:
47
  :param max_diff: Maximum difference considered between two models' elo
48
  :param matches: Dictionary containing the match history (to later upload as CSV)
49
  """
 
50
  def __init__(self, models):
51
  self.models = models
52
  self.queue = self.models.copy()
@@ -92,11 +92,12 @@ class Matchmaking:
92
  model1 = self.find_model(model1[0], model1[1])
93
  model2 = self.find_model(model2[0], model2[1])
94
  result = row["result"]
95
- self.compute_elo(row["model1"], row["model2"], row["result"])
96
- self.matches["model1"].append(model1.name)
97
- self.matches["model2"].append(model2.name)
98
- self.matches["result"].append(result)
99
- self.matches["timestamp"].append(row["timestamp"])
 
100
 
101
  def find_model(self, author, name):
102
  """ Find a model in the models list. """
 
7
  from datetime import datetime
8
  from huggingface_hub import HfApi, Repository
9
 
 
10
  DATASET_REPO_URL = "https://huggingface.co/datasets/CarlCochet/BotFightData"
11
  ELO_FILENAME = "soccer_elo.csv"
12
  ELO_DIR = "soccer_elo"
13
  HF_TOKEN = os.environ.get("HF_TOKEN")
14
 
 
15
  subprocess.run("rm -rf .git/hooks".split())
16
  repo = Repository(
17
  local_dir=ELO_DIR, clone_from=DATASET_REPO_URL, use_auth_token=HF_TOKEN
 
28
  :param elo: Elo rating of the model
29
  :param games_played: Number of games played by the model (useful if we implement sigma uncertainty)
30
  """
31
+
32
  def __init__(self, author, name, elo=1200, games_played=0):
33
  self.author = author
34
  self.name = name
 
46
  :param max_diff: Maximum difference considered between two models' elo
47
  :param matches: Dictionary containing the match history (to later upload as CSV)
48
  """
49
+
50
  def __init__(self, models):
51
  self.models = models
52
  self.queue = self.models.copy()
 
92
  model1 = self.find_model(model1[0], model1[1])
93
  model2 = self.find_model(model2[0], model2[1])
94
  result = row["result"]
95
+ if model1 is not None or model2 is not None:
96
+ self.compute_elo(row["model1"], row["model2"], row["result"])
97
+ self.matches["model1"].append(model1.name)
98
+ self.matches["model2"].append(model2.name)
99
+ self.matches["result"].append(result)
100
+ self.matches["timestamp"].append(row["timestamp"])
101
 
102
  def find_model(self, author, name):
103
  """ Find a model in the models list. """