#!/usr/bin/env python """HF_PUSH_ALL: real-world rows of scratch/hf_push/real_inventory.tsv with no remote match -> real_map.tsv for rli14/rsm_real_checkpoints. hf_path = path under runs/. Orbax step dirs: params/ + assets/ + _CHECKPOINT_METADATA only (no train_state / optimizer). Small *.json/*.yaml next to each file ride along.""" import os, csv ROOT = "/proj/dmfexp/zwhong/rsm_rise"; S = 50 * 2**20 rows, seen = [], set() def add(src, kind): real = os.path.realpath(src); rel = os.path.relpath(src, ROOT) hf = rel[5:] if rel.startswith("runs/") else rel if hf in seen or not os.path.isfile(real): return seen.add(hf); rows.append((hf, real, os.path.getsize(real), "", "", kind)) for r in csv.DictReader(open(f"{ROOT}/scratch/hf_push/real_inventory.tsv"), delimiter="\t"): if r["remote_match"] or r["kind"] not in ("file", "orbax"): continue p = os.path.join(ROOT, r["path"]) if r["kind"] == "orbax": for sub in ("params", "assets"): for d, _, fs in os.walk(os.path.join(p, sub), followlinks=True): for f in fs: add(os.path.join(d, f), "orbax") add(os.path.join(p, "_CHECKPOINT_METADATA"), "orbax") else: add(p, "ckpt"); d = os.path.dirname(p) for g in os.listdir(d): q = os.path.join(d, g) if g.endswith((".json", ".yaml", ".yml")) and os.path.isfile(q) and os.path.getsize(q) < S: add(q, "sidecar") with open(f"{ROOT}/scratch/hf_push/real_map.tsv", "w") as f: f.write("hf_path\tsource_path\tbytes\tn_cells\texample_cell\tkind\n") for r in rows: f.write("\t".join(map(str, r)) + "\n") print(len(rows), "files", round(sum(r[2] for r in rows) / 2**30, 1), "GiB")