import json import os import sys # Mock paths PROJECT_ROOT = os.path.abspath(os.getcwd()) sys.path.append(PROJECT_ROOT) from leaderboard import rank_results def test_dataset(name): path = os.path.join(PROJECT_ROOT, "results", f"{name}.json") if not os.path.exists(path): print(f"[ERROR] {name} not found") return with open(path, 'r', encoding='utf-8') as f: data = json.load(f) print(f"--- Testing {name} ---") try: ranked = rank_results(data) if len(ranked) > 0: first = ranked[0] print("Keys in first item:", first.keys()) # Check for critical keys for key in ['mean_f1', 'mean_auc', 'time']: if key not in first: print(f"[FAIL] Missing key: {key}") elif first[key] is None: print(f"[FAIL] Key is None: {key}") else: print(f"[OK] {key}: {first[key]} (type: {type(first[key])})") else: print("[WARN] Ranked list is empty") except Exception as e: print(f"[ERROR] Ranking failed: {e}") test_dataset("Authorship") test_dataset("Factors") test_dataset("dna")