TheXeos commited on
Commit
3a5a13b
1 Parent(s): 44c646a

Add back matchmaking process

Browse files
Files changed (1) hide show
  1. background_task.py +8 -5
background_task.py CHANGED
@@ -96,8 +96,10 @@ class Matchmaking:
96
 
97
  def to_csv(self):
98
  """ Save the match history as a CSV file to the hub. """
99
- data_dict = {"author": [], "model": [], "elo": [], "games_played": []}
100
- for model in self.models:
 
 
101
  data_dict["author"].append(model.author)
102
  data_dict["model"].append(model.name)
103
  data_dict["elo"].append(model.elo)
@@ -149,9 +151,10 @@ def get_models_list() -> list:
149
 
150
  def init_matchmaking():
151
  models = get_models_list()
152
- # matchmaking = Matchmaking(models)
153
- # matchmaking.run()
154
- # matchmaking.to_csv()
 
155
 
156
 
157
  if __name__ == "__main__":
 
96
 
97
  def to_csv(self):
98
  """ Save the match history as a CSV file to the hub. """
99
+ data_dict = {"rank": [], "author": [], "model": [], "elo": [], "games_played": []}
100
+ sorted_models = sorted(self.models, key=lambda x: x.elo, reverse=True)
101
+ for i, model in enumerate(sorted_models):
102
+ data_dict["rank"].append(i + 1)
103
  data_dict["author"].append(model.author)
104
  data_dict["model"].append(model.name)
105
  data_dict["elo"].append(model.elo)
 
151
 
152
  def init_matchmaking():
153
  models = get_models_list()
154
+ matchmaking = Matchmaking(models)
155
+ matchmaking.run()
156
+ matchmaking.to_csv()
157
+ print("Matchmaking done ---", datetime.now().strftime("%Y-%m-%d %H:%M:%S.%f"))
158
 
159
 
160
  if __name__ == "__main__":