File size: 1,391 Bytes
c90ac2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env python3
"""
Reset the CodeLens database: deletes the SQLite file and re-initializes tables.
Useful for clearing test data and starting fresh evaluation benchmarks.
"""

import os
import sys
from pathlib import Path

# Add project root to path
sys.path.insert(0, str(Path(__file__).parent.parent))

from codelens_env.config import get_settings
from codelens_env.database import create_db_and_tables

def reset_db():
    settings = get_settings()
    db_path = Path(settings.db_path)
    
    # 1. Delete existing database file
    if db_path.exists():
        print(f"Removing existing database at: {db_path}")
        try:
            os.remove(db_path)
            print("Successfully deleted old records.")
        except Exception as e:
            print(f"Error deleting file: {e}")
            sys.exit(1)
    else:
        print(f"No existing database found at {db_path}")

    # 2. Re-initialize
    print(f"Re-initializing schema...")
    try:
        create_db_and_tables()
        print("Database reset successfully. You now have a clean dashboard.")
    except Exception as e:
        print(f"Error re-initializing: {e}")
        sys.exit(1)

if __name__ == "__main__":
    confirm = input("This will permanently delete all leaderboard and episode data. Proceed? [y/N]: ")
    if confirm.lower() == 'y':
        reset_db()
    else:
        print("Reset aborted.")