File size: 1,242 Bytes
522ed11
 
faf5e01
 
522ed11
 
 
 
faf5e01
 
 
 
 
 
 
 
522ed11
 
faf5e01
 
 
 
 
 
 
 
 
 
 
 
 
8553b38
 
 
 
faf5e01
 
 
 
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
import sys
import os
from pathlib import Path
from dotenv import load_dotenv

# Add project root to sys.path
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))

# Load env explicitly
load_dotenv(override=True)

from app import SyncManager

DATA_DIR = Path("hf_project_showcase_data")
HF_TOKEN = os.getenv("HF_TOKEN")
HF_DB_REPO = os.getenv("HF_DB_REPO", "duqing2026/project-show-data")

if __name__ == "__main__":
    print("Starting manual sync...")
    if not HF_TOKEN:
        print("Error: HF_TOKEN not found.")
        sys.exit(1)
        
    manager = SyncManager(HF_DB_REPO, HF_TOKEN, DATA_DIR)
    
    # 1. Pull first (to merge or avoid conflict, though here we prioritize local push for the image)
    # Actually, if we want to fix the QR code, we should just push the file.
    # But to be safe, let's just push.
    
    print(f"Token: {HF_TOKEN[:4]}...")
    try:
        # Pull first to ensure we have latest visits (though app.py logic now prevents local push of visits)
        # manager.pull() 
        
        # Push all (app.py will exclude visits.jsonl if local)
        manager.push()
        print("Sync completed successfully.")
    except Exception as e:
        print(f"Sync failed: {e}")