Spaces:
Sleeping
Sleeping
Create upload_index_to_hf.py
Browse files- upload_index_to_hf.py +27 -0
upload_index_to_hf.py
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
from huggingface_hub import HfApi
|
| 3 |
+
from pathlib import Path
|
| 4 |
+
import argparse
|
| 5 |
+
|
| 6 |
+
def main():
|
| 7 |
+
ap = argparse.ArgumentParser()
|
| 8 |
+
ap.add_argument("--local_dir", required=True, help="Path to the built index folder (uuid dir)")
|
| 9 |
+
ap.add_argument("--repo_id", required=True, help="e.g., Azizahalq/materialmind-index")
|
| 10 |
+
args = ap.parse_args()
|
| 11 |
+
|
| 12 |
+
local_dir = Path(args.local_dir).resolve()
|
| 13 |
+
if not local_dir.exists():
|
| 14 |
+
raise SystemExit(f"Local dir not found: {local_dir}")
|
| 15 |
+
|
| 16 |
+
api = HfApi()
|
| 17 |
+
api.create_repo(repo_id=args.repo_id, repo_type="dataset", exist_ok=True)
|
| 18 |
+
api.upload_folder(
|
| 19 |
+
folder_path=str(local_dir),
|
| 20 |
+
repo_id=args.repo_id,
|
| 21 |
+
repo_type="dataset",
|
| 22 |
+
path_in_repo="MaterialMind", # keeps structure
|
| 23 |
+
)
|
| 24 |
+
print("Uploaded:", local_dir, "->", args.repo_id)
|
| 25 |
+
|
| 26 |
+
if __name__ == "__main__":
|
| 27 |
+
main()
|