Scandiumlabs commited on
Commit
889c477
·
verified ·
1 Parent(s): 1d3a679

Upload scripts/run_phase1_pipeline.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. scripts/run_phase1_pipeline.py +116 -0
scripts/run_phase1_pipeline.py ADDED
@@ -0,0 +1,116 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Phase 1 pipeline runner — executes all Phase 1 scripts in sequence.
2
+
3
+ This script runs the complete Phase 1 pipeline:
4
+ 1. Electrochemical stability windows (Li/Na entries)
5
+ 2. CAVD channel dimensionality (all Li/Na entries with structures)
6
+ 3. SSE candidate score (all entries, 5-gate system)
7
+ 4. Mechanical properties (all entries, geometric proxy)
8
+ 5. Oxidation states (all entries, BVA + heuristic)
9
+ 6. JARVIS EaH (internal convex hull)
10
+ 7. Commercial-safe edition extraction
11
+ 8. Garnet enrichment (structure-based reclassification)
12
+
13
+ Usage:
14
+ python scripts/run_phase1_pipeline.py # full pipeline
15
+ python scripts/run_phase1_pipeline.py --steps 1,3,5 # specific steps only
16
+ python scripts/run_phase1_pipeline.py --dry-run # stats only, no writes
17
+ python scripts/run_phase1_pipeline.py --skip-write # compute but don't save
18
+ """
19
+ import sys, time, argparse, subprocess
20
+ from pathlib import Path
21
+
22
+ SCRIPTS_DIR = Path(__file__).resolve().parent
23
+ BASE_DIR = SCRIPTS_DIR.parent
24
+
25
+ STEPS = {
26
+ 1: ("Electrochemical Windows", "compute_electrochemical_windows.py",
27
+ ["python", "scripts/compute_electrochemical_windows.py", "--subset", "full"]),
28
+ 2: ("CAVD Channel Dimensionality", "compute_cavd_channel_dimensionality.py",
29
+ ["python", "scripts/compute_cavd_channel_dimensionality.py", "--subset", "full"]),
30
+ 3: ("SSE Candidate Score", "compute_sse_candidate_score.py",
31
+ ["python", "scripts/compute_sse_candidate_score.py", "--subset", "full"]),
32
+ 4: ("Mechanical Properties", "compute_mechanical_properties.py",
33
+ ["python", "scripts/compute_mechanical_properties.py"]),
34
+ 5: ("Oxidation States", "compute_oxidation_states.py",
35
+ ["python", "scripts/compute_oxidation_states.py"]),
36
+ 6: ("JARVIS EaH", "compute_jarvis_hull_energy.py",
37
+ ["python", "scripts/compute_jarvis_hull_energy.py"]),
38
+ 7: ("Commercial-Safe Edition", "extract_commercial_safe_edition.py",
39
+ ["python", "scripts/extract_commercial_safe_edition.py"]),
40
+ 8: ("Garnet Enrichment", "enrich_garnet_family.py",
41
+ ["python", "scripts/enrich_garnet_family.py"]),
42
+ }
43
+
44
+ STEP_ORDER = [1, 2, 3, 4, 5, 6, 7, 8]
45
+
46
+
47
+ def main():
48
+ parser = argparse.ArgumentParser(description="Phase 1 pipeline runner")
49
+ parser.add_argument("--steps", type=str, default=None,
50
+ help="Comma-separated step numbers (e.g. 1,3,5)")
51
+ parser.add_argument("--dry-run", action="store_true",
52
+ help="Add --dry-run to all scripts")
53
+ parser.add_argument("--skip-write", action="store_true",
54
+ help="Add --dry-run to dataset-modifying scripts")
55
+ args = parser.parse_args()
56
+
57
+ if args.steps:
58
+ selected_steps = [int(s.strip()) for s in args.steps.split(",")]
59
+ else:
60
+ selected_steps = STEP_ORDER
61
+
62
+ print("=" * 60)
63
+ print(" PHASE 1 PIPELINE")
64
+ print(" 8 steps to transform Scandium-Dataset into SSB screening resource")
65
+ print("=" * 60)
66
+
67
+ total_start = time.time()
68
+
69
+ for step_num in selected_steps:
70
+ if step_num not in STEPS:
71
+ print(f"\n [SKIP] Step {step_num}: unknown")
72
+ continue
73
+
74
+ name, script, base_cmd = STEPS[step_num]
75
+
76
+ print(f"\n{'─' * 60}")
77
+ print(f" Step {step_num}/8: {name}")
78
+ print(f" Script: scripts/{script}")
79
+ print(f"{'─' * 60}")
80
+
81
+ cmd = list(base_cmd)
82
+ if args.dry_run or args.skip_write:
83
+ cmd.append("--dry-run")
84
+
85
+ step_start = time.time()
86
+ print(f" Running: {' '.join(cmd)}")
87
+ print()
88
+
89
+ result = subprocess.run(cmd, cwd=str(BASE_DIR), capture_output=True, text=True)
90
+
91
+ # Print stdout
92
+ for line in result.stdout.split("\n"):
93
+ print(f" {line}")
94
+
95
+ if result.stderr.strip():
96
+ print(f"\n stderr:")
97
+ for line in result.stderr.strip().split("\n"):
98
+ print(f" ! {line}")
99
+
100
+ if result.returncode != 0:
101
+ print(f"\n [FAILED] exit code {result.returncode}")
102
+ if not args.dry_run:
103
+ print(" Aborting pipeline.")
104
+ sys.exit(1)
105
+
106
+ elapsed = time.time() - step_start
107
+ print(f"\n [{elapsed/60:.1f} min]")
108
+
109
+ total_elapsed = time.time() - total_start
110
+ print(f"\n{'=' * 60}")
111
+ print(f" Pipeline complete: {len(selected_steps)} steps in {total_elapsed/60:.1f} min")
112
+ print(f"{'=' * 60}")
113
+
114
+
115
+ if __name__ == "__main__":
116
+ main()