Files
hiffi-artist-intelligence/main.py
T

112 lines
3.9 KiB
Python
Raw Normal View History

"""
main.py
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)
"""
import sys
import argparse
import subprocess
from pathlib import Path
PROJECT_ROOT = Path(__file__).resolve().parent
if str(PROJECT_ROOT) not in sys.path:
sys.path.insert(0, str(PROJECT_ROOT))
from core.health_detector import PipelineHealthDetector
from pipeline.batch_500_runner import BatchMultiPlatformRunner
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))
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()
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)
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,
)
subparsers = parser.add_subparsers(dest="command", required=True, help="Pipeline action to execute")
# 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)
# Command: audit
p_audit = subparsers.add_parser("audit", help="Run automated anomaly detection & health checks")
p_audit.set_defaults(func=cmd_audit)
# Command: report
p_report = subparsers.add_parser("report", help="Display executive movers & provenance report")
p_report.set_defaults(func=cmd_report)
# 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)
# 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)
return parser
def main():
parser = build_parser()
args = parser.parse_args()
args.func(args)
if __name__ == "__main__":
main()