Upload code/1027_run/upload_results.sh with huggingface_hub
Browse files
code/1027_run/upload_results.sh
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env bash
|
| 2 |
+
# Upload completed task ckpts + task names to HuggingFace yqi19/dagger under a new folder.
|
| 3 |
+
# Usage: bash upload_results.sh <folder_name> e.g. bash upload_results.sh 1027_dp_ckpts
|
| 4 |
+
set -uo pipefail
|
| 5 |
+
|
| 6 |
+
FOLDER=${1:?usage: bash upload_results.sh <hf_folder_name>}
|
| 7 |
+
HF_TOKEN=<YOUR_HF_TOKEN>
|
| 8 |
+
ROOT=/lustre/fsw/portfolios/nvr/users/jtremblay/yu
|
| 9 |
+
RUN=$ROOT/1027_run
|
| 10 |
+
V5CODE=$ROOT/1027_sim_tasks/share_v5_sim2real_20260929/code
|
| 11 |
+
|
| 12 |
+
export HF_TOKEN=$HF_TOKEN
|
| 13 |
+
|
| 14 |
+
log() { echo "== $(date '+%F %T') $*"; }
|
| 15 |
+
|
| 16 |
+
# Build manifest of completed tasks
|
| 17 |
+
MANIFEST=$RUN/data/completed_tasks.txt
|
| 18 |
+
> $MANIFEST
|
| 19 |
+
|
| 20 |
+
declare -A TASK_CKPTS=(
|
| 21 |
+
["package_d5"]="$V5CODE/train_runs/package_d5_v1_aug_s0/checkpoints"
|
| 22 |
+
["bread_lever_bowl"]="$V5CODE/train_runs/blb_v1_aug_s0/checkpoints"
|
| 23 |
+
["ringpeg"]="$V5CODE/train_runs/ringpeg_dart_v1_s0/checkpoints"
|
| 24 |
+
["toaster_lever"]="$V5CODE/train_runs/toaster_lever_v1_aug_s0/checkpoints"
|
| 25 |
+
["battery"]="$V5CODE/train_runs/battery_v1_aug_s0/checkpoints"
|
| 26 |
+
["plug"]="$V5CODE/train_runs/plug_v1_aug_s0/checkpoints"
|
| 27 |
+
["ring"]="$V5CODE/train_runs/ring_v1_aug_s0/checkpoints"
|
| 28 |
+
)
|
| 29 |
+
|
| 30 |
+
log "Scanning for completed ckpts..."
|
| 31 |
+
for task in "${!TASK_CKPTS[@]}"; do
|
| 32 |
+
ckpt_dir="${TASK_CKPTS[$task]}"
|
| 33 |
+
ckpt=$(ls $ckpt_dir/latest.ckpt 2>/dev/null || ls $ckpt_dir/*.ckpt 2>/dev/null | sort | tail -1)
|
| 34 |
+
if [ -n "${ckpt:-}" ] && [ -f "$ckpt" ]; then
|
| 35 |
+
echo "$task $ckpt" >> $MANIFEST
|
| 36 |
+
log " DONE: $task -> $ckpt"
|
| 37 |
+
else
|
| 38 |
+
log " MISSING: $task (ckpt not found in $ckpt_dir)"
|
| 39 |
+
fi
|
| 40 |
+
done
|
| 41 |
+
|
| 42 |
+
if [ ! -s $MANIFEST ]; then
|
| 43 |
+
log "No completed tasks found, nothing to upload"
|
| 44 |
+
exit 0
|
| 45 |
+
fi
|
| 46 |
+
|
| 47 |
+
log "Uploading to yqi19/dagger/$FOLDER ..."
|
| 48 |
+
python3 << PYEOF
|
| 49 |
+
import os
|
| 50 |
+
from huggingface_hub import HfApi
|
| 51 |
+
|
| 52 |
+
api = HfApi(token=os.environ['HF_TOKEN'])
|
| 53 |
+
repo_id = "yqi19/dagger"
|
| 54 |
+
folder = "$FOLDER"
|
| 55 |
+
manifest_path = "$MANIFEST"
|
| 56 |
+
|
| 57 |
+
with open(manifest_path) as f:
|
| 58 |
+
tasks = [line.strip().split() for line in f if line.strip()]
|
| 59 |
+
|
| 60 |
+
# Upload manifest
|
| 61 |
+
api.upload_file(
|
| 62 |
+
path_or_fileobj=manifest_path.encode() if False else manifest_path,
|
| 63 |
+
path_in_repo=f"{folder}/completed_tasks.txt",
|
| 64 |
+
repo_id=repo_id,
|
| 65 |
+
repo_type="dataset",
|
| 66 |
+
)
|
| 67 |
+
print(f"Uploaded manifest with {len(tasks)} tasks")
|
| 68 |
+
|
| 69 |
+
for task_name, ckpt_path in tasks:
|
| 70 |
+
dest = f"{folder}/{task_name}/latest.ckpt"
|
| 71 |
+
print(f"Uploading {task_name}: {ckpt_path} -> {dest}")
|
| 72 |
+
api.upload_file(
|
| 73 |
+
path_or_fileobj=ckpt_path,
|
| 74 |
+
path_in_repo=dest,
|
| 75 |
+
repo_id=repo_id,
|
| 76 |
+
repo_type="dataset",
|
| 77 |
+
)
|
| 78 |
+
print(f" done")
|
| 79 |
+
|
| 80 |
+
print("All uploads complete")
|
| 81 |
+
PYEOF
|
| 82 |
+
|
| 83 |
+
log "Upload done"
|