2026-10-22 17:20:44 +05:30
|
|
|
"""
|
|
|
|
|
main.py
|
2026-10-24 09:48:37 +05:30
|
|
|
Unified Command-Line Interface (CLI) Entry Point for HIFFI Artist Intelligence Pipeline.
|
|
|
|
|
|
|
|
|
|
Supported Commands:
|
|
|
|
|
python main.py run # Run the batch ingestion and signal merge pipeline
|
|
|
|
|
python main.py audit # Run automated anomaly detection and data health checks
|
|
|
|
|
python main.py report # Print the executive provenance and ranking report
|
|
|
|
|
python main.py test # Execute the automated Pytest governance suite
|
|
|
|
|
python main.py all # Run complete end-to-end pipeline (audit -> test -> report)
|
2026-10-22 17:20:44 +05:30
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
import sys
|
2026-10-24 09:48:37 +05:30
|
|
|
import argparse
|
|
|
|
|
import subprocess
|
|
|
|
|
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
|
|
|
|
|
from pipeline.batch_500_runner import BatchMultiPlatformRunner
|
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 cmd_run(args):
|
|
|
|
|
"""Executes the batch ingestion and multi-platform scoring pipeline."""
|
|
|
|
|
print("\n[HIFFI CLI] Initializing Multi-Platform Batch Runner...")
|
|
|
|
|
runner = BatchMultiPlatformRunner("enriched_artists.csv")
|
|
|
|
|
runner.run_full_pipeline(batch_size=args.batch_size, delay_range=(0.5, 1.0))
|
2026-10-22 17:20:44 +05:30
|
|
|
|
|
|
|
|
|
2026-10-24 09:48:37 +05:30
|
|
|
def cmd_audit(args):
|
|
|
|
|
"""Runs automated health checks and anomaly detection."""
|
|
|
|
|
print("\n[HIFFI CLI] Executing Automated Pipeline Health Detector...")
|
|
|
|
|
detector = PipelineHealthDetector()
|
|
|
|
|
detector.print_diagnostic_report()
|
2026-10-22 17:20:44 +05:30
|
|
|
|
|
|
|
|
|
2026-10-24 09:48:37 +05:30
|
|
|
def cmd_report(args):
|
|
|
|
|
"""Prints executive ranking and data provenance summaries."""
|
|
|
|
|
print("\n[HIFFI CLI] Generating Executive Provenance Report...")
|
|
|
|
|
report_script = PROJECT_ROOT / "pipeline" / "generate_report.py"
|
|
|
|
|
subprocess.run([sys.executable, str(report_script)], check=True)
|
2026-10-22 13:06:10 +05:30
|
|
|
|
|
|
|
|
|
2026-10-24 09:48:37 +05:30
|
|
|
def cmd_test(args):
|
|
|
|
|
"""Executes the pytest QA test suite."""
|
|
|
|
|
print("\n[HIFFI CLI] Running QA Governance Test Suite...")
|
|
|
|
|
test_file = PROJECT_ROOT / "test_multiplatform_ranking.py"
|
|
|
|
|
cmd = [sys.executable, "-m", "pytest", "-v" if args.verbose else "-q", str(test_file)]
|
|
|
|
|
subprocess.run(cmd, check=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def cmd_all(args):
|
|
|
|
|
"""Executes end-to-end workflow: Audit -> Pytest -> Report."""
|
|
|
|
|
print("\n" + "=" * 80)
|
|
|
|
|
print("HIFFI PIPELINE: EXECUTING FULL END-TO-END VALIDATION & REPORTING")
|
|
|
|
|
print("=" * 80)
|
|
|
|
|
|
|
|
|
|
# 1. Health Audit
|
|
|
|
|
cmd_audit(args)
|
|
|
|
|
|
|
|
|
|
# 2. Pytest Governance Check
|
|
|
|
|
cmd_test(args)
|
|
|
|
|
|
|
|
|
|
# 3. Final Report
|
|
|
|
|
cmd_report(args)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def build_parser() -> argparse.ArgumentParser:
|
|
|
|
|
parser = argparse.ArgumentParser(
|
|
|
|
|
prog="hiffi",
|
|
|
|
|
description="HIFFI Multi-Platform Artist Intelligence Data Pipeline CLI",
|
|
|
|
|
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
|
2026-10-22 17:20:44 +05:30
|
|
|
)
|
2026-10-24 09:48:37 +05:30
|
|
|
subparsers = parser.add_subparsers(dest="command", required=True, help="Pipeline action to execute")
|
2026-10-22 13:06:10 +05:30
|
|
|
|
2026-10-24 09:48:37 +05:30
|
|
|
# Command: run
|
|
|
|
|
p_run = subparsers.add_parser("run", help="Run batch ingestion & multi-platform scoring")
|
|
|
|
|
p_run.add_argument("--batch-size", type=int, default=15, help="Batch size for checkpoint saves")
|
|
|
|
|
p_run.set_defaults(func=cmd_run)
|
2026-10-22 13:06:10 +05:30
|
|
|
|
2026-10-24 09:48:37 +05:30
|
|
|
# Command: audit
|
|
|
|
|
p_audit = subparsers.add_parser("audit", help="Run automated anomaly detection & health checks")
|
|
|
|
|
p_audit.set_defaults(func=cmd_audit)
|
2026-10-22 13:06:10 +05:30
|
|
|
|
2026-10-24 09:48:37 +05:30
|
|
|
# Command: report
|
|
|
|
|
p_report = subparsers.add_parser("report", help="Display executive movers & provenance report")
|
|
|
|
|
p_report.set_defaults(func=cmd_report)
|
2026-10-22 13:06:10 +05:30
|
|
|
|
2026-10-24 09:48:37 +05:30
|
|
|
# Command: test
|
|
|
|
|
p_test = subparsers.add_parser("test", help="Run the automated QA test suite")
|
|
|
|
|
p_test.add_argument("-v", "--verbose", action="store_true", help="Verbose pytest output")
|
|
|
|
|
p_test.set_defaults(func=cmd_test)
|
2026-10-22 13:06:10 +05:30
|
|
|
|
2026-10-24 09:48:37 +05:30
|
|
|
# Command: all
|
|
|
|
|
p_all = subparsers.add_parser("all", help="Execute complete health check, QA suite, and executive report")
|
|
|
|
|
p_all.add_argument("-v", "--verbose", action="store_true", help="Verbose pytest output")
|
|
|
|
|
p_all.set_defaults(func=cmd_all)
|
2026-10-22 13:06:10 +05:30
|
|
|
|
2026-10-24 09:48:37 +05:30
|
|
|
return parser
|
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():
|
|
|
|
|
parser = build_parser()
|
|
|
|
|
args = parser.parse_args()
|
|
|
|
|
args.func(args)
|
2026-10-22 13:06:10 +05:30
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2026-10-24 09:48:37 +05:30
|
|
|
main()
|