lcipolina commited on
Commit
f267d0a
·
verified ·
1 Parent(s): 559249d

Deduplication of entries in the game drop down

Browse files
Files changed (1) hide show
  1. app.py +18 -32
app.py CHANGED
@@ -181,30 +181,11 @@ def extract_agent_info(filename: str) -> Tuple[str, str]:
181
 
182
 
183
  def get_available_games(include_aggregated: bool = True) -> List[str]:
184
- """Union of games seen in DBs and in registry."""
185
- game_names = set()
186
-
187
- # From DBs
188
- for db_file in find_or_download_db():
189
- conn = sqlite3.connect(db_file)
190
- try:
191
- df = pd.read_sql_query(
192
- "SELECT DISTINCT game_name FROM moves", conn
193
- )
194
- game_names.update(df["game_name"].tolist())
195
- except Exception:
196
- pass
197
- finally:
198
- conn.close()
199
-
200
- # From registry
201
  if GAMES_REGISTRY:
202
- game_names.update(GAMES_REGISTRY.keys())
203
-
204
- if not game_names:
205
- game_names.update(["tic_tac_toe", "kuhn_poker", "connect_four"])
206
-
207
- game_list = sorted(game_names)
208
  if include_aggregated:
209
  game_list.insert(0, "Aggregated Performance")
210
  return game_list
@@ -280,13 +261,17 @@ def create_player_config() -> GameArenaConfig:
280
 
281
  # Map internal names to display names
282
  key_to_display = _get_game_display_mapping()
283
- available_games = [
284
  key_to_display.get(key, key.replace("_", " ").title())
285
  for key in available_keys
286
  ]
287
-
288
- # Collect models seen in DBs for charts/labels
289
- database_models = [model for _, _, model in iter_agent_databases()]
 
 
 
 
290
 
291
  player_types = ["random_bot"]
292
  player_type_display = {"random_bot": "Random Bot"}
@@ -297,7 +282,7 @@ def create_player_config() -> GameArenaConfig:
297
  tag = model_key.split("/")[-1]
298
  player_type_display[key] = f"HuggingFace: {tag}"
299
 
300
- all_models = list(HUGGINGFACE_MODELS.keys()) + database_models
301
  model_info = (
302
  "HuggingFace transformer models integrated with backend system."
303
  if BACKEND_SYSTEM_AVAILABLE
@@ -305,10 +290,11 @@ def create_player_config() -> GameArenaConfig:
305
  )
306
 
307
  # Build display→key mapping for games
308
- display_to_key = {
309
- key_to_display.get(key, key.replace("_", " ").title()): key
310
- for key in available_keys
311
- }
 
312
 
313
  return {
314
  "available_games": available_games,
 
181
 
182
 
183
  def get_available_games(include_aggregated: bool = True) -> List[str]:
184
+ """Return only games from the registry."""
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
185
  if GAMES_REGISTRY:
186
+ game_list = sorted(GAMES_REGISTRY.keys())
187
+ else:
188
+ game_list = ["tic_tac_toe", "kuhn_poker", "connect_four"]
 
 
 
189
  if include_aggregated:
190
  game_list.insert(0, "Aggregated Performance")
191
  return game_list
 
261
 
262
  # Map internal names to display names
263
  key_to_display = _get_game_display_mapping()
264
+ mapped_games = [
265
  key_to_display.get(key, key.replace("_", " ").title())
266
  for key in available_keys
267
  ]
268
+ # Deduplicate while preserving order
269
+ seen = set()
270
+ available_games = []
271
+ for name in mapped_games:
272
+ if name not in seen:
273
+ available_games.append(name)
274
+ seen.add(name)
275
 
276
  player_types = ["random_bot"]
277
  player_type_display = {"random_bot": "Random Bot"}
 
282
  tag = model_key.split("/")[-1]
283
  player_type_display[key] = f"HuggingFace: {tag}"
284
 
285
+ all_models = list(HUGGINGFACE_MODELS.keys())
286
  model_info = (
287
  "HuggingFace transformer models integrated with backend system."
288
  if BACKEND_SYSTEM_AVAILABLE
 
290
  )
291
 
292
  # Build display→key mapping for games
293
+ display_to_key = {}
294
+ for key in available_keys:
295
+ display = key_to_display.get(key, key.replace("_", " ").title())
296
+ if display not in display_to_key:
297
+ display_to_key[display] = key
298
 
299
  return {
300
  "available_games": available_games,