jashdoshi77 commited on
Commit
67dc59c
·
1 Parent(s): 63f7810

Fix: Add git lfs pull on startup to ensure data files are available

Browse files
Files changed (1) hide show
  1. server.py +22 -0
server.py CHANGED
@@ -48,6 +48,28 @@ logging.getLogger("apscheduler").setLevel(logging.WARNING)
48
  # =============================================================================
49
  ROOT_DIR = Path(__file__).parent
50
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
  # Check if we're on Hugging Face Spaces (has /data folder)
52
  HF_PERSISTENT_DIR = Path("/data")
53
  IS_HF_SPACES = HF_PERSISTENT_DIR.exists() and os.access(HF_PERSISTENT_DIR, os.W_OK)
 
48
  # =============================================================================
49
  ROOT_DIR = Path(__file__).parent
50
 
51
+ # Pull Git LFS content to ensure parquet files are available (not just LFS pointers)
52
+ import subprocess
53
+ try:
54
+ api_data_dir = ROOT_DIR / "data" / "api_data"
55
+ test_file = api_data_dir / "all_games_summary.parquet"
56
+ # Check if file exists and is an LFS pointer (very small size)
57
+ if test_file.exists() and test_file.stat().st_size < 500:
58
+ logger.info("Detected LFS pointers, pulling actual file content...")
59
+ result = subprocess.run(
60
+ ["git", "lfs", "pull"],
61
+ cwd=str(ROOT_DIR),
62
+ capture_output=True,
63
+ text=True,
64
+ timeout=180
65
+ )
66
+ if result.returncode == 0:
67
+ logger.info("Git LFS pull completed successfully")
68
+ else:
69
+ logger.warning(f"Git LFS pull issue: {result.stderr[:200]}")
70
+ except Exception as e:
71
+ logger.info(f"LFS check skipped: {e}")
72
+
73
  # Check if we're on Hugging Face Spaces (has /data folder)
74
  HF_PERSISTENT_DIR = Path("/data")
75
  IS_HF_SPACES = HF_PERSISTENT_DIR.exists() and os.access(HF_PERSISTENT_DIR, os.W_OK)