Upload folder using huggingface_hub
Browse files- scripts/upload_to_hf.py +16 -2
scripts/upload_to_hf.py
CHANGED
|
@@ -61,7 +61,7 @@ def main():
|
|
| 61 |
print(f"[HF] Create repo: {e}")
|
| 62 |
# Continue; repo might already exist
|
| 63 |
|
| 64 |
-
# Exclude cache/outputs
|
| 65 |
ignore_patterns = [
|
| 66 |
"__pycache__",
|
| 67 |
"*.pyc",
|
|
@@ -72,13 +72,27 @@ def main():
|
|
| 72 |
".eggs",
|
| 73 |
]
|
| 74 |
|
| 75 |
-
print(f"[HF] Uploading from {PROJECT_ROOT} to {repo_id} ...")
|
| 76 |
api.upload_folder(
|
| 77 |
folder_path=PROJECT_ROOT,
|
| 78 |
repo_id=repo_id,
|
| 79 |
repo_type=repo_type,
|
| 80 |
ignore_patterns=ignore_patterns,
|
| 81 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 82 |
print(f"[HF] Done: https://huggingface.co/{repo_id}")
|
| 83 |
|
| 84 |
|
|
|
|
| 61 |
print(f"[HF] Create repo: {e}")
|
| 62 |
# Continue; repo might already exist
|
| 63 |
|
| 64 |
+
# Exclude cache/outputs; checkpoints is in .gitignore so upload it explicitly below
|
| 65 |
ignore_patterns = [
|
| 66 |
"__pycache__",
|
| 67 |
"*.pyc",
|
|
|
|
| 72 |
".eggs",
|
| 73 |
]
|
| 74 |
|
| 75 |
+
print(f"[HF] Uploading code from {PROJECT_ROOT} to {repo_id} ...")
|
| 76 |
api.upload_folder(
|
| 77 |
folder_path=PROJECT_ROOT,
|
| 78 |
repo_id=repo_id,
|
| 79 |
repo_type=repo_type,
|
| 80 |
ignore_patterns=ignore_patterns,
|
| 81 |
)
|
| 82 |
+
|
| 83 |
+
# .gitignore contains "checkpoints", so upload_folder skips it. Upload checkpoints explicitly.
|
| 84 |
+
checkpoints_dir = os.path.join(PROJECT_ROOT, "checkpoints")
|
| 85 |
+
if os.path.isdir(checkpoints_dir):
|
| 86 |
+
print(f"[HF] Uploading checkpoints/ to {repo_id} ...")
|
| 87 |
+
api.upload_folder(
|
| 88 |
+
folder_path=checkpoints_dir,
|
| 89 |
+
repo_id=repo_id,
|
| 90 |
+
path_in_repo="checkpoints",
|
| 91 |
+
repo_type=repo_type,
|
| 92 |
+
)
|
| 93 |
+
else:
|
| 94 |
+
print("[HF] No local checkpoints/ folder, skipping.")
|
| 95 |
+
|
| 96 |
print(f"[HF] Done: https://huggingface.co/{repo_id}")
|
| 97 |
|
| 98 |
|