keynes42 commited on
Commit
e0e637b
·
verified ·
1 Parent(s): 17bbe28

Update app.py

Browse files

Add authorization to download attachments from GAIA Github repo.

Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -332,18 +332,18 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
332
  if file_name:
333
  print(f"Task {task_id} requires file: '{file_name}'. Attempting to download...")
334
 
335
- # --- THIS IS THE NEW, ROBUST DOWNLOAD LOGIC ---
336
  file_downloaded = False
337
  # List of URLs to try in order
338
  urls_to_try = [
339
- f"{GAIA_DATASET_URL_1}/{file_name}",
340
- f"{GAIA_DATASET_URL_2}/{file_name}"
341
  ]
342
 
343
- for i, url in enumerate(urls_to_try):
344
  try:
345
  print(f"Attempting download from URL #{i+1}: {url}")
346
- file_response = requests.get(url, timeout=30)
347
 
348
  if file_response.status_code == 200:
349
  # Success! Save the file locally.
 
332
  if file_name:
333
  print(f"Task {task_id} requires file: '{file_name}'. Attempting to download...")
334
 
335
+ headers = {"Authorization": f"Bearer {hf_token}"}
336
  file_downloaded = False
337
  # List of URLs to try in order
338
  urls_to_try = [
339
+ (f"{GAIA_DATASET_URL_1}/{file_name}", headers),
340
+ (f"{GAIA_DATASET_URL_2}/{file_name}", headers)
341
  ]
342
 
343
+ for i, (url, request_headers) in enumerate(urls_to_try):
344
  try:
345
  print(f"Attempting download from URL #{i+1}: {url}")
346
+ file_response = requests.get(url, headers=request_headers, timeout=30)
347
 
348
  if file_response.status_code == 200:
349
  # Success! Save the file locally.