""" BatchMind OS: End-to-End Pipeline Runner Automates the sequential execution of all layers. """ import os import sys import subprocess import time def run_script(script_path): print(f"\n--- Running: {script_path} ---") start_time = time.time() result = subprocess.run([sys.executable, script_path], capture_output=False) elapsed = time.time() - start_time if result.returncode == 0: print(f"SUCCESS: {script_path} (Took {elapsed:.2f}s)") return True else: print(f"FAILURE: {script_path} returned code {result.returncode}") return False def main(): print("============================================================") print(" BATCHMIND OS: MANUFACTURING INTELLIGENCE ") print("============================================================") pipeline = [ "layer0_preprocessing/preprocess.py", "layer1_features/phase_stats.py", "layer1_features/physics_features.py", "layer1_features/chronos_embedding.py", "layer1_features/build_features.py", "layer2_predictor/train_model.py", "layer2_predictor/evaluate.py", "layer3_carbon/carbon_engine.py", "layer4_optimizer/optuna_optimizer.py", "layer5_golden_signature/signature_manager.py", "layer5_golden_signature/dtw_scorer.py", "layer6_anomaly/matrix_profile.py", "layer7_governance/llm_parser.py", "layer7_governance/promotion_engine.py", "layer7_governance/drift_detector.py", "realtime_inference.py" ] total_start = time.time() for stage in pipeline: if not run_script(stage): print("\n!!! PIPELINE HALTED DUE TO ERROR !!!") sys.exit(1) print("\n" + "="*60) print(f"PIPELINE COMPLETE (Total Time: {(time.time() - total_start)/60:.2f} mins)") print("SYSTEM STATUS: ONLINE") print("="*60) print("\nTo start the system interface:") print("1. API: uvicorn api.main:app --port 8000") print("2. Dashboard: cd frontend && npm run dev") print("="*60) if __name__ == "__main__": main()