TheXeos commited on
Commit
951b897
1 Parent(s): 0a48cbd

Fix model duplication

Browse files
Files changed (1) hide show
  1. background_task.py +5 -3
background_task.py CHANGED
@@ -120,6 +120,8 @@ class Matchmaking:
120
  :param n: Number of close models from which to pick a candidate
121
  :return: id of the chosen candidate
122
  """
 
 
123
  indexes = []
124
  closest_diffs = [9999999] * n
125
  for i, m in enumerate(self.queue):
@@ -174,15 +176,15 @@ def get_models_list() -> list:
174
  :return: list of Model objects
175
  """
176
  models = []
177
- models_names = []
178
  data = pd.read_csv(os.path.join(DATASET_REPO_URL, "resolve", "main", ELO_FILENAME))
179
  models_on_hub = api.list_models(filter=["reinforcement-learning", "ml-agents", "ML-Agents-SoccerTwos"])
180
  for i, row in data.iterrows():
181
  models.append(Model(row["author"], row["model"], row["elo"], row["games_played"]))
182
- models_names.append(row["model"])
183
  for model in models_on_hub:
184
  author, name = model.modelId.split("/")[0], model.modelId.split("/")[1]
185
- if model.modelId not in models_names:
186
  models.append(Model(author, name))
187
  print("New model found: ", author, "-", name)
188
  return models
 
120
  :param n: Number of close models from which to pick a candidate
121
  :return: id of the chosen candidate
122
  """
123
+ if len(self.queue) == 1:
124
+ return 0
125
  indexes = []
126
  closest_diffs = [9999999] * n
127
  for i, m in enumerate(self.queue):
 
176
  :return: list of Model objects
177
  """
178
  models = []
179
+ models_ids = []
180
  data = pd.read_csv(os.path.join(DATASET_REPO_URL, "resolve", "main", ELO_FILENAME))
181
  models_on_hub = api.list_models(filter=["reinforcement-learning", "ml-agents", "ML-Agents-SoccerTwos"])
182
  for i, row in data.iterrows():
183
  models.append(Model(row["author"], row["model"], row["elo"], row["games_played"]))
184
+ models_ids.append(row["author"] + "/" + row["model"])
185
  for model in models_on_hub:
186
  author, name = model.modelId.split("/")[0], model.modelId.split("/")[1]
187
+ if model.modelId not in models_ids:
188
  models.append(Model(author, name))
189
  print("New model found: ", author, "-", name)
190
  return models