from pathlib import Path import shutil def mv(src: Path, dst: Path): if not src.exists(): return dst.parent.mkdir(parents=True, exist_ok=True) if dst.exists(): if src.is_dir() and dst.is_dir(): for c in src.iterdir(): mv(c, dst / c.name) src.rmdir() return shutil.move(str(src), str(dst)) def main(): root = Path(__file__).resolve().parents[1] fg = root / "FineGrained_RL" for p in [root / "src" / "rlclean", root / "data" / "raw", root / "outputs" / "logs", root / "outputs" / "runs", root / "scripts", root / "docs", root / "tests"]: p.mkdir(parents=True, exist_ok=True) mv(fg / "configs", root / "configs") if (fg / "datasets").exists(): for p in (fg / "datasets").glob("*.pkl"): mv(p, root / "data" / "raw" / p.name) mv(fg / "runs", root / "outputs" / "runs") for p in fg.glob("eval_*.py"): mv(p, root / "scripts" / p.name) for p in fg.glob("verify_*.py"): mv(p, root / "scripts" / p.name) print("layout migration done") if __name__ == "__main__": main()