-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_all.py
More file actions
57 lines (45 loc) · 1.61 KB
/
run_all.py
File metadata and controls
57 lines (45 loc) · 1.61 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
"""Run the full data pipeline: create historical data, then train/generate predictions.
This script executes `create-nfl-historical.py` followed by `nfl-gather-data.py` using
the same Python interpreter. It prints progress and exits non-zero if either step fails.
Usage:
python run_all.py
Notes:
- Ensure your virtualenv is active and required packages are installed (see README).
"""
from __future__ import annotations
import subprocess
import sys
import os
from pathlib import Path
ROOT = Path(__file__).resolve().parent
def run_script(script_path: Path) -> int:
print(f"\n==> Running: {script_path.name}")
try:
proc = subprocess.run([sys.executable, str(script_path)], check=False)
print(f"<== Exit code: {proc.returncode}\n")
return proc.returncode
except Exception as e:
print(f"Failed to run {script_path}: {e}")
return 2
def main() -> int:
os.makedirs(ROOT / 'data_files', exist_ok=True)
create_script = ROOT / 'create-nfl-historical.py'
gather_script = ROOT / 'nfl-gather-data.py'
if not create_script.exists():
print(f"Missing script: {create_script}")
return 3
if not gather_script.exists():
print(f"Missing script: {gather_script}")
return 4
code = run_script(create_script)
if code != 0:
print("Aborting: create-nfl-historical failed")
return code
code = run_script(gather_script)
if code != 0:
print("Aborting: nfl-gather-data failed")
return code
print("\nALL STEPS COMPLETED SUCCESSFULLY")
return 0
if __name__ == '__main__':
raise SystemExit(main())