forked from sergeyf/SmallDataBenchmarks
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_all.py
More file actions
59 lines (46 loc) · 1.84 KB
/
Copy pathrun_all.py
File metadata and controls
59 lines (46 loc) · 1.84 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
"""Run all benchmark scripts sequentially.
compare_baseline_models.py runs first — everything else reads its output.
"""
import subprocess
import sys
import time
from pathlib import Path
from config import AUTOML_SEC
PYTHON = sys.executable
RESULTS = Path("results")
SCRIPT_OUTPUTS = {
"compare_baseline_models.py": RESULTS / "compare_baseline_models.joblib",
"optuna_models.py": RESULTS / "optuna_models.joblib",
"benchmark_autogluon.py": RESULTS / f"autogluon_sec_{AUTOML_SEC}.joblib",
"benchmark_mljar.py": RESULTS / f"mljar_sec_{AUTOML_SEC}.joblib",
}
SCRIPTS = list(SCRIPT_OUTPUTS.keys())
# These skip finished work themselves, so an existing output must not stop them
# — otherwise a newly added model never runs and the script still reports success.
SELF_RESUMING = {"optuna_models.py"}
def run(script: str) -> subprocess.CompletedProcess:
print(f"\n{'='*60}")
print(f" Starting: {script}")
print(f"{'='*60}\n")
start = time.time()
result = subprocess.run([PYTHON, script])
elapsed = time.time() - start
status = "OK" if result.returncode == 0 else f"FAILED (exit {result.returncode})"
print(f"\n {script} finished in {elapsed/3600:.2f}h — {status}")
return result
if __name__ == "__main__":
RESULTS.mkdir(exist_ok=True)
total_start = time.time()
for script in SCRIPTS:
output = SCRIPT_OUTPUTS[script]
if script not in SELF_RESUMING and output.exists():
print(f"\n Skipping {script} — output already exists: {output}")
continue
result = run(script)
if result.returncode != 0:
print(f"\n{script} failed — aborting.")
sys.exit(1)
total = time.time() - total_start
print(f"\n{'='*60}")
print(f" All done in {total/3600:.2f}h")
print(f" Results saved in: {RESULTS}/")