73 lines
2.8 KiB
Python
73 lines
2.8 KiB
Python
import os
|
|
import sys
|
|
import argparse
|
|
import logging
|
|
|
|
# Add the backend directory to the Python path
|
|
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
|
|
|
|
from backend.database import get_db, Company
|
|
from backend.services.classification import ClassificationService
|
|
from backend.lib.logging_setup import setup_logging
|
|
|
|
# --- CONFIGURATION ---
|
|
# Setup logging to be very verbose for this script
|
|
setup_logging()
|
|
logger = logging.getLogger(__name__)
|
|
logger.setLevel(logging.DEBUG)
|
|
logger = logging.getLogger(__name__)
|
|
|
|
def run_debug_analysis(company_id: int):
|
|
"""
|
|
Runs the full classification and enrichment process for a single company
|
|
in the foreground and prints detailed results.
|
|
"""
|
|
logger.info(f"--- Starting Interactive Debug for Company ID: {company_id} ---")
|
|
|
|
db_session = next(get_db())
|
|
|
|
try:
|
|
# 1. Fetch the company
|
|
company = db_session.query(Company).filter(Company.id == company_id).first()
|
|
if not company:
|
|
logger.error(f"Company with ID {company_id} not found.")
|
|
return
|
|
|
|
logger.info(f"Found Company: {company.name}")
|
|
|
|
# --- PRE-ANALYSIS STATE ---
|
|
print("\n--- METRICS BEFORE ---")
|
|
print(f"Calculated: {company.calculated_metric_value} {company.calculated_metric_unit}")
|
|
print(f"Standardized: {company.standardized_metric_value} {company.standardized_metric_unit}")
|
|
print("----------------------\n")
|
|
|
|
# 2. Instantiate the service
|
|
classifier = ClassificationService()
|
|
|
|
# 3. RUN THE CORE LOGIC
|
|
# This will now print all the detailed logs we added
|
|
updated_company = classifier.classify_company_potential(company, db_session)
|
|
|
|
# --- POST-ANALYSIS STATE ---
|
|
print("\n--- METRICS AFTER ---")
|
|
print(f"Industry (AI): {updated_company.industry_ai}")
|
|
print(f"Metric Source: {updated_company.metric_source}")
|
|
print(f"Proof Text: {updated_company.metric_proof_text}")
|
|
print(f"Calculated: {updated_company.calculated_metric_value} {updated_company.calculated_metric_unit}")
|
|
print(f"Standardized: {updated_company.standardized_metric_value} {updated_company.standardized_metric_unit}")
|
|
print(f"\nOpener 1 (Infra): {updated_company.ai_opener}")
|
|
print(f"Opener 2 (Ops): {updated_company.ai_opener_secondary}")
|
|
print("---------------------")
|
|
|
|
logger.info(f"--- Interactive Debug Finished for Company ID: {company_id} ---")
|
|
|
|
finally:
|
|
db_session.close()
|
|
|
|
if __name__ == "__main__":
|
|
parser = argparse.ArgumentParser(description="Run a single company analysis for debugging.")
|
|
parser.add_argument("--id", type=int, default=1, help="The ID of the company to analyze.")
|
|
args = parser.parse_args()
|
|
|
|
run_debug_analysis(args.id)
|