BerkIGuler commited on
Commit
b262800
·
1 Parent(s): 32478ba

Initial commit for Hugging Face

Browse files
Files changed (1) hide show
  1. scripts/upload_to_huggingface.py +16 -4
scripts/upload_to_huggingface.py CHANGED
@@ -273,8 +273,20 @@ def upload_to_huggingface(repo_path: Path, repo_name: str, private: bool = False
273
  # No changes to commit
274
  print(" No changes to commit (working tree clean)")
275
 
276
- # Add Hugging Face remote
277
- remote_url = f"https://huggingface.co/{repo_id}"
 
 
 
 
 
 
 
 
 
 
 
 
278
 
279
  # Check if origin remote already exists
280
  result = subprocess.run(["git", "remote", "get-url", "origin"],
@@ -283,11 +295,11 @@ def upload_to_huggingface(repo_path: Path, repo_name: str, private: bool = False
283
  if result.returncode == 0:
284
  # Remote exists, update it
285
  subprocess.run(["git", "remote", "set-url", "origin", remote_url], check=True)
286
- print(f" Updated remote: {remote_url}")
287
  else:
288
  # Remote doesn't exist, add it
289
  subprocess.run(["git", "remote", "add", "origin", remote_url], check=True)
290
- print(f" Added remote: {remote_url}")
291
 
292
  # Get current branch name
293
  result = subprocess.run(["git", "branch", "--show-current"],
 
273
  # No changes to commit
274
  print(" No changes to commit (working tree clean)")
275
 
276
+ # Get Hugging Face token for authentication
277
+ try:
278
+ token = api.token
279
+ if not token:
280
+ print("❌ No Hugging Face token found")
281
+ print("Please run: huggingface-cli login")
282
+ return False
283
+ except Exception:
284
+ print("❌ Failed to get Hugging Face token")
285
+ print("Please run: huggingface-cli login")
286
+ return False
287
+
288
+ # Add Hugging Face remote with token authentication
289
+ remote_url = f"https://{username}:{token}@huggingface.co/{repo_id}"
290
 
291
  # Check if origin remote already exists
292
  result = subprocess.run(["git", "remote", "get-url", "origin"],
 
295
  if result.returncode == 0:
296
  # Remote exists, update it
297
  subprocess.run(["git", "remote", "set-url", "origin", remote_url], check=True)
298
+ print(f" Updated remote: {repo_id}")
299
  else:
300
  # Remote doesn't exist, add it
301
  subprocess.run(["git", "remote", "add", "origin", remote_url], check=True)
302
+ print(f" Added remote: {repo_id}")
303
 
304
  # Get current branch name
305
  result = subprocess.run(["git", "branch", "--show-current"],