jasonshaoshun commited on
Commit
7d21286
·
1 Parent(s): 4a47622
Files changed (1) hide show
  1. app.py +114 -41
app.py CHANGED
@@ -125,6 +125,8 @@ LEADERBOARD_DF_MIB_CAUSALGRAPH_DETAILED, LEADERBOARD_DF_MIB_CAUSALGRAPH_AGGREGAT
125
 
126
 
127
  from src.about import TasksMib_Subgraph
 
 
128
  # def init_leaderboard_mib_subgraph(dataframe, track):
129
  # if dataframe is None or dataframe.empty:
130
  # raise ValueError("Leaderboard DataFrame is empty or None.")
@@ -386,62 +388,133 @@ from src.about import TasksMib_Subgraph
386
 
387
 
388
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
389
  def init_leaderboard_mib_subgraph(dataframe, track):
390
- """Initialize the subgraph leaderboard with benchmark and model filtering capabilities."""
391
  if dataframe is None or dataframe.empty:
392
  raise ValueError("Leaderboard DataFrame is empty or None.")
393
 
394
- # Print DataFrame information for debugging
395
- # print("\nDebugging DataFrame columns:", dataframe.columns.tolist())
396
-
397
- # Get result columns (excluding Method and Average)
398
- result_columns = [col for col in dataframe.columns
399
- if col not in ['Method', 'Average', 'eval_name'] and '_' in col]
400
-
401
- # Create benchmark and model selections
402
- benchmarks = set()
403
- models = set()
404
-
405
- print(f"\nDebugging Result Columns: {result_columns}")
406
- # Extract unique benchmarks and models from column names
407
- for col in result_columns:
408
- print(f"col is {col}")
409
- benchmark, model = col.split('_', maxsplit=1)
410
- benchmarks.add(benchmark)
411
- models.add(model)
412
- print(f"benchmark is {benchmark} and model is {model}")
413
-
414
- # Create selection groups
415
- benchmark_selections = {
416
- # For each benchmark, store which columns should be shown
417
- benchmark: [col for col in result_columns if col.startswith(f"{benchmark}_")]
418
- for benchmark in benchmarks
419
- }
420
-
421
- model_selections = {
422
- # For each model, store which columns should be shown
423
- model: [col for col in result_columns if col.startswith(f"_{model}")]
424
- for model in models
425
- }
426
-
427
- # Combine the selection mappings
 
 
 
 
 
 
 
428
  selection_groups = {
429
  **benchmark_selections,
430
  **model_selections
431
  }
432
 
433
- print("\nDebugging Selection Groups:")
434
- print("Benchmarks:", benchmark_selections.keys())
435
- print("Models:", model_selections.keys())
436
-
437
- # Convert keys to list for selection options
438
  selection_options = list(selection_groups.keys())
 
439
 
440
  return Leaderboard(
441
  value=dataframe,
442
  datatype=[c.type for c in fields(AutoEvalColumn_mib_subgraph)],
443
  select_columns=SelectColumns(
444
- default_selection=selection_options, # Show all options by default
445
  label="Filter by Benchmark or Model:"
446
  ),
447
  search_columns=["Method"],
 
125
 
126
 
127
  from src.about import TasksMib_Subgraph
128
+
129
+
130
  # def init_leaderboard_mib_subgraph(dataframe, track):
131
  # if dataframe is None or dataframe.empty:
132
  # raise ValueError("Leaderboard DataFrame is empty or None.")
 
388
 
389
 
390
 
391
+ # def init_leaderboard_mib_subgraph(dataframe, track):
392
+ # """Initialize the subgraph leaderboard with benchmark and model filtering capabilities."""
393
+ # if dataframe is None or dataframe.empty:
394
+ # raise ValueError("Leaderboard DataFrame is empty or None.")
395
+
396
+ # # Print DataFrame information for debugging
397
+ # # print("\nDebugging DataFrame columns:", dataframe.columns.tolist())
398
+
399
+ # # Get result columns (excluding Method and Average)
400
+ # result_columns = [col for col in dataframe.columns
401
+ # if col not in ['Method', 'Average', 'eval_name'] and '_' in col]
402
+
403
+ # # Create benchmark and model selections
404
+ # benchmarks = set()
405
+ # models = set()
406
+
407
+ # print(f"\nDebugging Result Columns: {result_columns}")
408
+ # # Extract unique benchmarks and models from column names
409
+ # for col in result_columns:
410
+ # print(f"col is {col}")
411
+ # benchmark, model = col.split('_', maxsplit=1)
412
+ # benchmarks.add(benchmark)
413
+ # models.add(model)
414
+ # print(f"benchmark is {benchmark} and model is {model}")
415
+
416
+ # # Create selection groups
417
+ # benchmark_selections = {
418
+ # # For each benchmark, store which columns should be shown
419
+ # benchmark: [col for col in result_columns if col.startswith(f"{benchmark}_")]
420
+ # for benchmark in benchmarks
421
+ # }
422
+
423
+ # model_selections = {
424
+ # # For each model, store which columns should be shown
425
+ # model: [col for col in result_columns if col.startswith(f"_{model}")]
426
+ # for model in models
427
+ # }
428
+
429
+ # # Combine the selection mappings
430
+ # selection_groups = {
431
+ # **benchmark_selections,
432
+ # **model_selections
433
+ # }
434
+
435
+ # print("\nDebugging Selection Groups:")
436
+ # print("Benchmarks:", benchmark_selections.keys())
437
+ # print("Models:", model_selections.keys())
438
+
439
+ # # Convert keys to list for selection options
440
+ # selection_options = list(selection_groups.keys())
441
+
442
+ # return Leaderboard(
443
+ # value=dataframe,
444
+ # datatype=[c.type for c in fields(AutoEvalColumn_mib_subgraph)],
445
+ # select_columns=SelectColumns(
446
+ # default_selection=selection_options, # Show all options by default
447
+ # label="Filter by Benchmark or Model:"
448
+ # ),
449
+ # search_columns=["Method"],
450
+ # hide_columns=[],
451
+ # interactive=False,
452
+ # )
453
+
454
+
455
+
456
+
457
+
458
  def init_leaderboard_mib_subgraph(dataframe, track):
459
+ """Initialize the subgraph leaderboard with benchmark and model filtering using direct enum access."""
460
  if dataframe is None or dataframe.empty:
461
  raise ValueError("Leaderboard DataFrame is empty or None.")
462
 
463
+ print("\nDebugging DataFrame columns:", dataframe.columns.tolist())
464
+
465
+ # Get benchmarks directly from TasksMib_Subgraph
466
+ benchmarks = [task.value.benchmark for task in TasksMib_Subgraph]
467
+ print("\nBenchmarks from enum:", benchmarks)
468
+
469
+ # Get unique models from all tasks
470
+ models = list(set(
471
+ model # Get each model
472
+ for task in TasksMib_Subgraph # For each task
473
+ for model in task.value.models # Get all its models
474
+ ))
475
+ print("\nModels from enum:", models)
476
+
477
+ # Create benchmark selections - map each benchmark to its columns
478
+ benchmark_selections = {}
479
+ for task in TasksMib_Subgraph:
480
+ benchmark = task.value.benchmark
481
+ # For this benchmark, get all its valid model combinations
482
+ valid_columns = [
483
+ f"{benchmark}_{model}"
484
+ for model in task.value.models
485
+ if f"{benchmark}_{model}" in dataframe.columns
486
+ ]
487
+ benchmark_selections[benchmark] = valid_columns
488
+ print(f"\nBenchmark {benchmark} maps to columns:", valid_columns)
489
+
490
+ # Create model selections - map each model to its columns
491
+ model_selections = {}
492
+ for model in models:
493
+ # For this model, find all benchmarks where it's used
494
+ valid_columns = [
495
+ f"{task.value.benchmark}_{model}"
496
+ for task in TasksMib_Subgraph
497
+ if model in task.value.models
498
+ and f"{task.value.benchmark}_{model}" in dataframe.columns
499
+ ]
500
+ model_selections[model] = valid_columns
501
+ print(f"\nModel {model} maps to columns:", valid_columns)
502
+
503
+ # Combine all selections
504
  selection_groups = {
505
  **benchmark_selections,
506
  **model_selections
507
  }
508
 
509
+ # Get the final selection options
 
 
 
 
510
  selection_options = list(selection_groups.keys())
511
+ print("\nFinal selection options:", selection_options)
512
 
513
  return Leaderboard(
514
  value=dataframe,
515
  datatype=[c.type for c in fields(AutoEvalColumn_mib_subgraph)],
516
  select_columns=SelectColumns(
517
+ default_selection=selection_options,
518
  label="Filter by Benchmark or Model:"
519
  ),
520
  search_columns=["Method"],