2026-10-22 17:20:44 +05:30
|
|
|
"""
|
|
|
|
|
main.py
|
2026-10-24 11:20:10 +05:30
|
|
|
HIFFI Artist Intelligence Pipeline CLI Orchestrator.
|
|
|
|
|
Supports unified commands: run, audit, test, report, all.
|
2026-10-22 17:20:44 +05:30
|
|
|
"""
|
|
|
|
|
|
2026-10-24 09:48:37 +05:30
|
|
|
import argparse
|
|
|
|
|
import subprocess
|
2026-10-24 11:20:10 +05:30
|
|
|
import sys
|
2026-10-24 09:48:37 +05:30
|
|
|
from pathlib import Path
|
2026-10-22 13:06:10 +05:30
|
|
|
|
2026-10-24 09:48:37 +05:30
|
|
|
PROJECT_ROOT = Path(__file__).resolve().parent
|
|
|
|
|
if str(PROJECT_ROOT) not in sys.path:
|
|
|
|
|
sys.path.insert(0, str(PROJECT_ROOT))
|
2026-10-22 13:06:10 +05:30
|
|
|
|
2026-10-24 09:48:37 +05:30
|
|
|
from core.health_detector import PipelineHealthDetector
|
2026-10-24 11:20:10 +05:30
|
|
|
from pipeline.batch_500_runner import main as run_batch_pipeline
|
2026-10-22 13:06:10 +05:30
|
|
|
|
2026-10-22 17:20:44 +05:30
|
|
|
|
2026-10-24 11:20:10 +05:30
|
|
|
def run_pipeline():
|
|
|
|
|
print("\n[HIFFI CLI] Executing Batch Multi-Platform Signal Ingestion & Scoring...")
|
|
|
|
|
run_batch_pipeline()
|
2026-10-22 17:20:44 +05:30
|
|
|
|
|
|
|
|
|
2026-10-24 11:20:10 +05:30
|
|
|
def run_audit():
|
|
|
|
|
print("\n[HIFFI CLI] Executing Automated Pipeline Health & Anomaly Detector...")
|
2026-10-24 09:48:37 +05:30
|
|
|
detector = PipelineHealthDetector()
|
2026-10-24 11:20:10 +05:30
|
|
|
anomalies_df, summary = detector.run_health_audit()
|
|
|
|
|
|
|
|
|
|
print("=" * 85)
|
|
|
|
|
print("HIFFI PIPELINE AUTOMATED HEALTH & ANOMALY DETECTOR")
|
|
|
|
|
print("=" * 85)
|
|
|
|
|
print(f"Total Cohort Rows Evaluated: {summary['total_rows']}")
|
|
|
|
|
print(f"Total Anomalies Flagged: {summary['total_anomalies']}")
|
|
|
|
|
print(f"Actionable Unresolved (P0/P1): {summary['actionable_p0_p1']}")
|
|
|
|
|
print(f"Data Governance Breaches: {summary['governance_breaches']}")
|
|
|
|
|
print("-" * 85)
|
|
|
|
|
if not anomalies_df.empty:
|
|
|
|
|
print(anomalies_df.to_string(index=False))
|
|
|
|
|
else:
|
|
|
|
|
print("No anomalous signals detected across active cohort.")
|
|
|
|
|
print("=" * 85)
|
2026-10-22 17:20:44 +05:30
|
|
|
|
|
|
|
|
|
2026-10-24 11:20:10 +05:30
|
|
|
def run_tests():
|
|
|
|
|
print("\n[HIFFI CLI] Running QA Governance Test Suite via Pytest...")
|
|
|
|
|
test_file = PROJECT_ROOT / "test_multiplatform_ranking.py"
|
|
|
|
|
cmd = [sys.executable, "-m", "pytest", str(test_file), "-v"]
|
|
|
|
|
result = subprocess.run(cmd)
|
|
|
|
|
if result.returncode != 0:
|
|
|
|
|
print("\n[HIFFI CLI] QA Governance Test Suite FAILED.")
|
|
|
|
|
sys.exit(result.returncode)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def run_report():
|
2026-10-24 09:48:37 +05:30
|
|
|
print("\n[HIFFI CLI] Generating Executive Provenance Report...")
|
|
|
|
|
report_script = PROJECT_ROOT / "pipeline" / "generate_report.py"
|
2026-10-24 11:20:10 +05:30
|
|
|
if report_script.exists():
|
|
|
|
|
subprocess.run([sys.executable, str(report_script)])
|
|
|
|
|
else:
|
|
|
|
|
print(f"[HIFFI CLI] Report script not found at {report_script}")
|
2026-10-22 13:06:10 +05:30
|
|
|
|
|
|
|
|
|
2026-10-24 11:20:10 +05:30
|
|
|
def run_all():
|
|
|
|
|
print("=" * 80)
|
2026-10-24 09:48:37 +05:30
|
|
|
print("HIFFI PIPELINE: EXECUTING FULL END-TO-END VALIDATION & REPORTING")
|
|
|
|
|
print("=" * 80)
|
2026-10-24 11:20:10 +05:30
|
|
|
run_audit()
|
|
|
|
|
run_tests()
|
|
|
|
|
run_report()
|
2026-10-22 13:06:10 +05:30
|
|
|
|
2026-10-22 17:20:44 +05:30
|
|
|
|
2026-10-24 09:48:37 +05:30
|
|
|
def main():
|
2026-10-24 11:20:10 +05:30
|
|
|
parser = argparse.ArgumentParser(description="HIFFI Artist Intelligence Multi-Platform Pipeline CLI")
|
|
|
|
|
parser.add_argument(
|
|
|
|
|
"action",
|
|
|
|
|
choices=["run", "audit", "test", "report", "all"],
|
|
|
|
|
help="Pipeline command to execute: 'run' (ingest & score), 'audit' (health checks), 'test' (pytest suite), 'report' (executive movers), or 'all' (audit + test + report)."
|
|
|
|
|
)
|
|
|
|
|
|
2026-10-24 09:48:37 +05:30
|
|
|
args = parser.parse_args()
|
2026-10-24 11:20:10 +05:30
|
|
|
|
|
|
|
|
if args.action == "run":
|
|
|
|
|
run_pipeline()
|
|
|
|
|
elif args.action == "audit":
|
|
|
|
|
run_audit()
|
|
|
|
|
elif args.action == "test":
|
|
|
|
|
run_tests()
|
|
|
|
|
elif args.action == "report":
|
|
|
|
|
run_report()
|
|
|
|
|
elif args.action == "all":
|
|
|
|
|
run_all()
|
2026-10-22 13:06:10 +05:30
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2026-10-24 09:48:37 +05:30
|
|
|
main()
|