2026-10-22 17:20:44 +05:30
|
|
|
"""
|
|
|
|
|
main.py
|
2026-10-24 15:57:20 +05:30
|
|
|
Unified Command-Line Interface (CLI) for the HIFFI Multi-Platform Intelligence Pipeline.
|
|
|
|
|
Orchestrates batch ingestion, provenance audit, anomaly detection, QA tests, review queue, and reporting.
|
2026-10-22 17:20:44 +05:30
|
|
|
"""
|
|
|
|
|
|
2026-10-24 09:48:37 +05:30
|
|
|
import argparse
|
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 15:57:20 +05:30
|
|
|
import pytest
|
|
|
|
|
from core.health_detector import main as run_health_audit
|
2026-10-24 11:20:10 +05:30
|
|
|
from pipeline.batch_500_runner import main as run_batch_pipeline
|
2026-10-24 15:57:20 +05:30
|
|
|
from reports.provenance_summary import main as run_provenance_summary
|
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 15:57:20 +05:30
|
|
|
run_health_audit()
|
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"
|
2026-10-24 15:57:20 +05:30
|
|
|
retcode = pytest.main(["-v", str(test_file)])
|
|
|
|
|
if retcode != 0:
|
2026-10-24 11:20:10 +05:30
|
|
|
print("\n[HIFFI CLI] QA Governance Test Suite FAILED.")
|
2026-10-24 15:57:20 +05:30
|
|
|
sys.exit(retcode)
|
2026-10-24 11:20:10 +05:30
|
|
|
|
|
|
|
|
|
|
|
|
|
def run_report():
|
2026-10-24 09:48:37 +05:30
|
|
|
print("\n[HIFFI CLI] Generating Executive Provenance Report...")
|
2026-10-24 15:57:20 +05:30
|
|
|
run_provenance_summary()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def run_review(apply_mode: bool = False, include_unmatched: bool = False):
|
|
|
|
|
print("\n[HIFFI CLI] Managing Instagram Candidate Review Queue...")
|
|
|
|
|
from pipeline.export_review_queue import apply_decisions, export_queue
|
|
|
|
|
if apply_mode:
|
|
|
|
|
apply_decisions()
|
2026-10-24 11:20:10 +05:30
|
|
|
else:
|
2026-10-24 15:57:20 +05:30
|
|
|
export_queue(include_unmatched=include_unmatched)
|
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 12:42:22 +05:30
|
|
|
run_pipeline()
|
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 15:57:20 +05:30
|
|
|
parser = argparse.ArgumentParser(
|
|
|
|
|
description="HIFFI 500-Artist Multi-Platform Pipeline CLI Engine"
|
|
|
|
|
)
|
2026-10-24 11:20:10 +05:30
|
|
|
parser.add_argument(
|
|
|
|
|
"action",
|
2026-10-24 15:57:20 +05:30
|
|
|
choices=["run", "audit", "test", "report", "review", "all"],
|
|
|
|
|
help="Pipeline command to execute: 'run', 'audit', 'test', 'report', 'review', or 'all'."
|
|
|
|
|
)
|
|
|
|
|
parser.add_argument(
|
|
|
|
|
"--apply",
|
|
|
|
|
action="store_true",
|
|
|
|
|
help="Apply review queue decisions to handle_overrides.json (used with 'review')"
|
|
|
|
|
)
|
|
|
|
|
parser.add_argument(
|
|
|
|
|
"--include-unmatched",
|
|
|
|
|
action="store_true",
|
|
|
|
|
help="Include records with missing candidate handles in review export"
|
2026-10-24 11:20:10 +05:30
|
|
|
)
|
|
|
|
|
|
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()
|
2026-10-24 15:57:20 +05:30
|
|
|
elif args.action == "review":
|
|
|
|
|
run_review(apply_mode=args.apply, include_unmatched=args.include_unmatched)
|
2026-10-24 11:20:10 +05:30
|
|
|
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()
|