BerkIGuler commited on
Commit
bc368a6
·
1 Parent(s): 09de8fe

Initial commit for Hugging Face

Browse files
Files changed (1) hide show
  1. scripts/upload_to_huggingface.py +13 -2
scripts/upload_to_huggingface.py CHANGED
@@ -267,8 +267,19 @@ def upload_to_huggingface(repo_path: Path, repo_name: str, private: bool = False
267
 
268
  # Add Hugging Face remote
269
  remote_url = f"https://huggingface.co/{repo_id}"
270
- subprocess.run(["git", "remote", "add", "origin", remote_url], check=True)
271
- print(f" Added remote: {remote_url}")
 
 
 
 
 
 
 
 
 
 
 
272
 
273
  # Push to Hugging Face
274
  subprocess.run(["git", "push", "-u", "origin", "main"], check=True)
 
267
 
268
  # Add Hugging Face remote
269
  remote_url = f"https://huggingface.co/{repo_id}"
270
+
271
+ # Check if origin remote already exists
272
+ result = subprocess.run(["git", "remote", "get-url", "origin"],
273
+ capture_output=True, text=True, check=False)
274
+
275
+ if result.returncode == 0:
276
+ # Remote exists, update it
277
+ subprocess.run(["git", "remote", "set-url", "origin", remote_url], check=True)
278
+ print(f" Updated remote: {remote_url}")
279
+ else:
280
+ # Remote doesn't exist, add it
281
+ subprocess.run(["git", "remote", "add", "origin", remote_url], check=True)
282
+ print(f" Added remote: {remote_url}")
283
 
284
  # Push to Hugging Face
285
  subprocess.run(["git", "push", "-u", "origin", "main"], check=True)