File size: 1,129 Bytes
5679f59
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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()