Spaces:
Runtime error
Runtime error
Update Down/run_all.py
Browse files- Down/run_all.py +69 -69
Down/run_all.py
CHANGED
|
@@ -12,13 +12,12 @@ from pathlib import Path
|
|
| 12 |
|
| 13 |
ROOT = Path(__file__).resolve().parent
|
| 14 |
|
| 15 |
-
# IMPORTANT:
|
| 16 |
-
# In your repo structure (as shown by HF logs), these exist:
|
| 17 |
-
# /app/Down/down
|
| 18 |
-
# /app/Down/AntiDown
|
| 19 |
DOWN_DIR = ROOT / "down"
|
| 20 |
ANTIDOWN_DIR = ROOT / "AntiDown"
|
| 21 |
-
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
|
| 24 |
def _run(cmd: list[str], cwd: Path, env: dict[str, str]) -> None:
|
|
@@ -28,8 +27,9 @@ def _run(cmd: list[str], cwd: Path, env: dict[str, str]) -> None:
|
|
| 28 |
|
| 29 |
def _build_parser() -> argparse.ArgumentParser:
|
| 30 |
p = argparse.ArgumentParser(description="Run DOWN + AntiDown pipelines and generate plots.")
|
| 31 |
-
p.add_argument("--episodes", type=int, default=
|
| 32 |
p.add_argument("--seed", type=int, default=2025, help="Seed for DOWN tabular experiment.")
|
|
|
|
| 33 |
return p
|
| 34 |
|
| 35 |
|
|
@@ -37,29 +37,25 @@ def main() -> None:
|
|
| 37 |
args = _build_parser().parse_args()
|
| 38 |
py = sys.executable
|
| 39 |
|
| 40 |
-
# Sanity checks (fail fast with good errors)
|
| 41 |
if not DOWN_DIR.exists():
|
| 42 |
-
raise RuntimeError(f"DOWN_DIR not found: {DOWN_DIR} (check
|
| 43 |
if not ANTIDOWN_DIR.exists():
|
| 44 |
-
raise RuntimeError(f"ANTIDOWN_DIR not found: {ANTIDOWN_DIR} (check
|
|
|
|
|
|
|
|
|
|
| 45 |
|
| 46 |
-
|
|
|
|
|
|
|
| 47 |
|
| 48 |
-
#
|
| 49 |
-
|
|
|
|
| 50 |
|
| 51 |
# ----------------------------
|
| 52 |
-
# DOWN
|
| 53 |
# ----------------------------
|
| 54 |
-
down_results_dir = DOWN_DIR / "results"
|
| 55 |
-
down_results_dir.mkdir(parents=True, exist_ok=True)
|
| 56 |
-
|
| 57 |
-
# Keep the filename your plot script already expects
|
| 58 |
-
down_csv = down_results_dir / "paradox_tabular_results.csv"
|
| 59 |
-
|
| 60 |
-
down_env = base_env.copy()
|
| 61 |
-
down_env["TWOQUARKS_RESULTS_DIR"] = str(down_results_dir)
|
| 62 |
-
|
| 63 |
_run(
|
| 64 |
[
|
| 65 |
py,
|
|
@@ -72,69 +68,73 @@ def main() -> None:
|
|
| 72 |
str(down_csv),
|
| 73 |
],
|
| 74 |
cwd=DOWN_DIR,
|
| 75 |
-
env=
|
| 76 |
-
)
|
| 77 |
-
|
| 78 |
-
_run(
|
| 79 |
-
[
|
| 80 |
-
py,
|
| 81 |
-
str(DOWN_DIR / "exp" / "plot_paradox_results.py"),
|
| 82 |
-
"--csv",
|
| 83 |
-
str(down_csv),
|
| 84 |
-
"--out",
|
| 85 |
-
str(OUT_GRAPHICS),
|
| 86 |
-
"--prefix",
|
| 87 |
-
"down",
|
| 88 |
-
],
|
| 89 |
-
cwd=DOWN_DIR,
|
| 90 |
-
env=down_env,
|
| 91 |
)
|
| 92 |
|
| 93 |
# ----------------------------
|
| 94 |
-
# AntiDown
|
| 95 |
# ----------------------------
|
| 96 |
-
|
| 97 |
-
antidown_results_dir.mkdir(parents=True, exist_ok=True)
|
| 98 |
-
|
| 99 |
-
# Your current plot script expects this exact filename
|
| 100 |
-
antidown_csv = antidown_results_dir / "paradox_tabular_results.csv"
|
| 101 |
-
|
| 102 |
-
antidown_env = base_env.copy()
|
| 103 |
-
antidown_env["TWOQUARKS_RESULTS_DIR"] = str(antidown_results_dir)
|
| 104 |
-
|
| 105 |
-
# NOTE:
|
| 106 |
-
# I’m not passing --episodes here because I don’t know if your AntiDown runner parses it.
|
| 107 |
-
# If it DOES, you can safely add: "--episodes", str(int(args.episodes))
|
| 108 |
_run(
|
| 109 |
[
|
| 110 |
py,
|
| 111 |
str(ANTIDOWN_DIR / "exp" / "run_corrupted_valley_tabular.py"),
|
|
|
|
|
|
|
| 112 |
],
|
| 113 |
cwd=ANTIDOWN_DIR,
|
| 114 |
-
env=
|
| 115 |
)
|
| 116 |
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 131 |
|
| 132 |
# ----------------------------
|
| 133 |
-
# Dual plot
|
| 134 |
# ----------------------------
|
| 135 |
-
_run([py, str(ROOT / "plot_dual_down_antidown.py")], cwd=ROOT, env=
|
| 136 |
|
| 137 |
-
print(f"[ok] Finished.
|
|
|
|
|
|
|
|
|
|
| 138 |
|
| 139 |
|
| 140 |
if __name__ == "__main__":
|
|
|
|
| 12 |
|
| 13 |
ROOT = Path(__file__).resolve().parent
|
| 14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
DOWN_DIR = ROOT / "down"
|
| 16 |
ANTIDOWN_DIR = ROOT / "AntiDown"
|
| 17 |
+
|
| 18 |
+
# Shared outputs (so plot_dual can find both CSVs)
|
| 19 |
+
RESULTS_DIR = ROOT / "results"
|
| 20 |
+
GRAPHICS_DIR = ROOT / "graphics"
|
| 21 |
|
| 22 |
|
| 23 |
def _run(cmd: list[str], cwd: Path, env: dict[str, str]) -> None:
|
|
|
|
| 27 |
|
| 28 |
def _build_parser() -> argparse.ArgumentParser:
|
| 29 |
p = argparse.ArgumentParser(description="Run DOWN + AntiDown pipelines and generate plots.")
|
| 30 |
+
p.add_argument("--episodes", type=int, default=200, help="Episodes per phase (for both DOWN and AntiDown).")
|
| 31 |
p.add_argument("--seed", type=int, default=2025, help="Seed for DOWN tabular experiment.")
|
| 32 |
+
p.add_argument("--skip_individual_plots", action="store_true", help="Only generate the dual overlay plot.")
|
| 33 |
return p
|
| 34 |
|
| 35 |
|
|
|
|
| 37 |
args = _build_parser().parse_args()
|
| 38 |
py = sys.executable
|
| 39 |
|
|
|
|
| 40 |
if not DOWN_DIR.exists():
|
| 41 |
+
raise RuntimeError(f"DOWN_DIR not found: {DOWN_DIR} (check folder names)")
|
| 42 |
if not ANTIDOWN_DIR.exists():
|
| 43 |
+
raise RuntimeError(f"ANTIDOWN_DIR not found: {ANTIDOWN_DIR} (check folder names)")
|
| 44 |
+
|
| 45 |
+
RESULTS_DIR.mkdir(parents=True, exist_ok=True)
|
| 46 |
+
GRAPHICS_DIR.mkdir(parents=True, exist_ok=True)
|
| 47 |
|
| 48 |
+
env = os.environ.copy()
|
| 49 |
+
env["TWOQUARKS_RESULTS_DIR"] = str(RESULTS_DIR)
|
| 50 |
+
env["TWOQUARKS_GRAPHICS_DIR"] = str(GRAPHICS_DIR)
|
| 51 |
|
| 52 |
+
# Canonical CSV names expected by plot_dual_down_antidown.py
|
| 53 |
+
down_csv = RESULTS_DIR / "down_paradox_tabular_results.csv"
|
| 54 |
+
antidown_csv = RESULTS_DIR / "antidown_corrupted_valley_tabular.csv"
|
| 55 |
|
| 56 |
# ----------------------------
|
| 57 |
+
# DOWN (tabular)
|
| 58 |
# ----------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
_run(
|
| 60 |
[
|
| 61 |
py,
|
|
|
|
| 68 |
str(down_csv),
|
| 69 |
],
|
| 70 |
cwd=DOWN_DIR,
|
| 71 |
+
env=env,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
)
|
| 73 |
|
| 74 |
# ----------------------------
|
| 75 |
+
# AntiDown (tabular)
|
| 76 |
# ----------------------------
|
| 77 |
+
# Requires the updated AntiDown runner below (adds --episodes support)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
_run(
|
| 79 |
[
|
| 80 |
py,
|
| 81 |
str(ANTIDOWN_DIR / "exp" / "run_corrupted_valley_tabular.py"),
|
| 82 |
+
"--episodes",
|
| 83 |
+
str(int(args.episodes)),
|
| 84 |
],
|
| 85 |
cwd=ANTIDOWN_DIR,
|
| 86 |
+
env=env,
|
| 87 |
)
|
| 88 |
|
| 89 |
+
# ----------------------------
|
| 90 |
+
# Individual plots (optional)
|
| 91 |
+
# ----------------------------
|
| 92 |
+
if not args.skip_individual_plots:
|
| 93 |
+
# If these plot scripts exist in your repo, keep them.
|
| 94 |
+
# They can read from the shared RESULTS_DIR, via explicit --csv.
|
| 95 |
+
plot_down = DOWN_DIR / "exp" / "plot_paradox_results.py"
|
| 96 |
+
if plot_down.exists():
|
| 97 |
+
_run(
|
| 98 |
+
[
|
| 99 |
+
py,
|
| 100 |
+
str(plot_down),
|
| 101 |
+
"--csv",
|
| 102 |
+
str(down_csv),
|
| 103 |
+
"--out",
|
| 104 |
+
str(GRAPHICS_DIR),
|
| 105 |
+
"--prefix",
|
| 106 |
+
"Down",
|
| 107 |
+
],
|
| 108 |
+
cwd=DOWN_DIR,
|
| 109 |
+
env=env,
|
| 110 |
+
)
|
| 111 |
+
|
| 112 |
+
plot_antidown = ANTIDOWN_DIR / "exp" / "plot_corrupted_valley_results.py"
|
| 113 |
+
if plot_antidown.exists():
|
| 114 |
+
_run(
|
| 115 |
+
[
|
| 116 |
+
py,
|
| 117 |
+
str(plot_antidown),
|
| 118 |
+
"--csv",
|
| 119 |
+
str(antidown_csv),
|
| 120 |
+
"--out",
|
| 121 |
+
str(GRAPHICS_DIR),
|
| 122 |
+
"--prefix",
|
| 123 |
+
"AntiDown",
|
| 124 |
+
],
|
| 125 |
+
cwd=ANTIDOWN_DIR,
|
| 126 |
+
env=env,
|
| 127 |
+
)
|
| 128 |
|
| 129 |
# ----------------------------
|
| 130 |
+
# Dual overlay plot (canonical)
|
| 131 |
# ----------------------------
|
| 132 |
+
_run([py, str(ROOT / "plot_dual_down_antidown.py")], cwd=ROOT, env=env)
|
| 133 |
|
| 134 |
+
print(f"[ok] Finished.")
|
| 135 |
+
print(f" CSV: {down_csv}")
|
| 136 |
+
print(f" CSV: {antidown_csv}")
|
| 137 |
+
print(f" Plots: {GRAPHICS_DIR}")
|
| 138 |
|
| 139 |
|
| 140 |
if __name__ == "__main__":
|