dolev31 commited on
Commit
853a730
·
1 Parent(s): cfac2c7

Fix HF token detection: explicitly read HF_TOKEN from os.environ

Browse files

HfApi() auto-detection was failing in the Space's Python 3.13 runtime,
causing persistence to always be disabled. Now explicitly passes the
token from os.environ.get("HF_TOKEN") to HfApi(token=...).

Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -190,11 +190,14 @@ def _init_persistence() -> bool:
190
  global _scheduler
191
  _DATA_DIR.mkdir(parents=True, exist_ok=True)
192
 
193
- api = HfApi()
194
- if not api.token:
195
- logger.warning("No HF token found — data persistence disabled")
196
  return False
197
 
 
 
 
198
  try:
199
  # Download existing data files from the repo before starting the scheduler
200
  for filename in ["submissions.jsonl", "key_requests.jsonl", "admin_audit.jsonl"]:
 
190
  global _scheduler
191
  _DATA_DIR.mkdir(parents=True, exist_ok=True)
192
 
193
+ token = os.environ.get("HF_TOKEN")
194
+ if not token:
195
+ logger.warning("No HF token found — data persistence disabled (HF_TOKEN not in env)")
196
  return False
197
 
198
+ logger.info("HF_TOKEN found, initializing persistence...")
199
+ api = HfApi(token=token)
200
+
201
  try:
202
  # Download existing data files from the repo before starting the scheduler
203
  for filename in ["submissions.jsonl", "key_requests.jsonl", "admin_audit.jsonl"]: