Datasets:
Upload experiments/exp5_upload.py with huggingface_hub
Browse files- experiments/exp5_upload.py +97 -0
experiments/exp5_upload.py
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""
|
| 3 |
+
Experiment 5: Upload all artifacts to HuggingFace.
|
| 4 |
+
Uploads: 50K dataset, model weights, training logs, all experiment results.
|
| 5 |
+
"""
|
| 6 |
+
|
| 7 |
+
import os
|
| 8 |
+
import json
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
def upload_all(results_dir, token):
|
| 12 |
+
from huggingface_hub import HfApi, upload_file, upload_folder
|
| 13 |
+
|
| 14 |
+
api = HfApi()
|
| 15 |
+
repo_id = "vnmoorthy/pavo-bench"
|
| 16 |
+
|
| 17 |
+
parent_dir = os.path.dirname(results_dir)
|
| 18 |
+
outputs_dir = os.path.join(results_dir, "outputs")
|
| 19 |
+
|
| 20 |
+
print(f" Uploading to {repo_id}...")
|
| 21 |
+
|
| 22 |
+
# 1. Upload 50K dataset files (train + test)
|
| 23 |
+
for fname in ["tier3_50k_train.jsonl", "tier3_50k_test.jsonl", "tier3_50k_summary.json"]:
|
| 24 |
+
fpath = os.path.join(parent_dir, fname)
|
| 25 |
+
if os.path.exists(fpath):
|
| 26 |
+
print(f" Uploading {fname}...")
|
| 27 |
+
api.upload_file(
|
| 28 |
+
path_or_fileobj=fpath,
|
| 29 |
+
path_in_repo=f"data/{fname}",
|
| 30 |
+
repo_id=repo_id,
|
| 31 |
+
repo_type="dataset",
|
| 32 |
+
token=token,
|
| 33 |
+
)
|
| 34 |
+
else:
|
| 35 |
+
print(f" WARNING: {fname} not found at {fpath}")
|
| 36 |
+
|
| 37 |
+
# 2. Upload original experiment results
|
| 38 |
+
for fname in os.listdir(parent_dir):
|
| 39 |
+
if fname.endswith(".json") and not fname.startswith("tier3_50k"):
|
| 40 |
+
fpath = os.path.join(parent_dir, fname)
|
| 41 |
+
print(f" Uploading {fname}...")
|
| 42 |
+
api.upload_file(
|
| 43 |
+
path_or_fileobj=fpath,
|
| 44 |
+
path_in_repo=f"results/{fname}",
|
| 45 |
+
repo_id=repo_id,
|
| 46 |
+
repo_type="dataset",
|
| 47 |
+
token=token,
|
| 48 |
+
)
|
| 49 |
+
|
| 50 |
+
# 3. Upload new experiment outputs
|
| 51 |
+
if os.path.exists(outputs_dir):
|
| 52 |
+
for fname in os.listdir(outputs_dir):
|
| 53 |
+
fpath = os.path.join(outputs_dir, fname)
|
| 54 |
+
if os.path.isfile(fpath):
|
| 55 |
+
print(f" Uploading outputs/{fname}...")
|
| 56 |
+
api.upload_file(
|
| 57 |
+
path_or_fileobj=fpath,
|
| 58 |
+
path_in_repo=f"outputs/{fname}",
|
| 59 |
+
repo_id=repo_id,
|
| 60 |
+
repo_type="dataset",
|
| 61 |
+
token=token,
|
| 62 |
+
)
|
| 63 |
+
|
| 64 |
+
# 4. Upload model weights specifically to a models/ directory
|
| 65 |
+
for model_file in ["meta_controller.pt", "meta_controller_best.pt"]:
|
| 66 |
+
model_path = os.path.join(outputs_dir, model_file)
|
| 67 |
+
if os.path.exists(model_path):
|
| 68 |
+
print(f" Uploading model: {model_file}...")
|
| 69 |
+
api.upload_file(
|
| 70 |
+
path_or_fileobj=model_path,
|
| 71 |
+
path_in_repo=f"models/{model_file}",
|
| 72 |
+
repo_id=repo_id,
|
| 73 |
+
repo_type="dataset",
|
| 74 |
+
token=token,
|
| 75 |
+
)
|
| 76 |
+
|
| 77 |
+
# 5. Upload training log
|
| 78 |
+
log_path = os.path.join(outputs_dir, "training_log.json")
|
| 79 |
+
if os.path.exists(log_path):
|
| 80 |
+
print(f" Uploading training_log.json...")
|
| 81 |
+
api.upload_file(
|
| 82 |
+
path_or_fileobj=log_path,
|
| 83 |
+
path_in_repo=f"training/training_log.json",
|
| 84 |
+
repo_id=repo_id,
|
| 85 |
+
repo_type="dataset",
|
| 86 |
+
token=token,
|
| 87 |
+
)
|
| 88 |
+
|
| 89 |
+
print(" Upload complete!")
|
| 90 |
+
print(f" View at: https://huggingface.co/datasets/{repo_id}")
|
| 91 |
+
|
| 92 |
+
|
| 93 |
+
if __name__ == "__main__":
|
| 94 |
+
import sys
|
| 95 |
+
token = sys.argv[1] if len(sys.argv) > 1 else input("HuggingFace token: ").strip()
|
| 96 |
+
results_dir = os.path.dirname(os.path.abspath(__file__))
|
| 97 |
+
upload_all(results_dir, token)
|