šŸ” Code Extractor

function main_v46

Maturity: 42

Entry point function that orchestrates vendor enrichment testing by parsing command-line arguments, running setup validation, and executing a single vendor test against a ChromaDB collection.

File:
/tf/active/vicechatdev/find_email/test_enrichment.py
Lines:
137 - 163
Complexity:
moderate

Purpose

This function serves as the main test harness for vendor enrichment functionality. It validates the testing environment setup, allows users to specify a vendor name and ChromaDB collection via command-line arguments, executes a test enrichment for a single vendor, and provides clear success/failure feedback with next steps. It's designed to be run before executing the full vendor enrichment pipeline to ensure everything is configured correctly.

Source Code

def main():
    """Main test function"""
    import argparse
    
    parser = argparse.ArgumentParser(description='Test vendor enrichment')
    parser.add_argument('--vendor', type=str, 
                       default='Merck',
                       help='Vendor name to test')
    parser.add_argument('--collection', type=str,
                       default='00_company_governance',
                       help='ChromaDB collection to search')
    
    args = parser.parse_args()
    
    if not test_setup():
        logger.error("Setup failed")
        return
    
    logger.info("\nāœ“ Setup complete")
    
    success = test_single_vendor(args.vendor, args.collection)
    
    if success:
        logger.info("\nāœ… Test completed successfully!")
        logger.info("You can now run the full enrichment with: python vendor_enrichment.py")
    else:
        logger.error("\nāŒ Test failed - check logs above")

Return Value

This function does not return any value (implicitly returns None). It performs side effects including logging output to console/file and executing test functions. The success or failure is communicated through log messages rather than return values.

Dependencies

  • argparse
  • logging
  • os
  • sys
  • re
  • hybrid_rag_engine

Required Imports

import argparse
import logging
import os
import sys
import re
from hybrid_rag_engine import OneCo_hybrid_RAG

Usage Example

# Run from command line with default arguments (tests 'Merck' vendor):
# python script_name.py

# Run with custom vendor:
# python script_name.py --vendor "Pfizer"

# Run with custom vendor and collection:
# python script_name.py --vendor "Johnson & Johnson" --collection "01_vendor_data"

# In code (if calling programmatically):
if __name__ == '__main__':
    main()

Best Practices

  • This function should only be called as the main entry point of the script, typically within an 'if __name__ == "__main__"' block
  • Ensure the logger is properly configured before calling this function to capture all test output
  • The test_setup() and test_single_vendor() functions must be implemented in the same module
  • Run this test function before executing the full vendor_enrichment.py script to validate configuration
  • The function exits gracefully on setup failure without raising exceptions, making it suitable for command-line usage
  • Command-line arguments allow flexible testing of different vendors and collections without code modification

Similar Components

AI-powered semantic similarity - components with related functionality:

  • function main_v9 80.3% similar

    Command-line interface function that orchestrates the enrichment of vendor data from an Excel file with email and VAT information using ChromaDB and RAG engine.

    From: /tf/active/vicechatdev/find_email/vendor_enrichment.py
  • function test_single_vendor 71.8% similar

    Tests vendor enrichment by querying a RAG (Retrieval-Augmented Generation) system to find official contact information (email and VAT number) for a specified vendor using document search and web search capabilities.

    From: /tf/active/vicechatdev/find_email/test_enrichment.py
  • function main_v31 71.5% similar

    Entry point function that executes a comprehensive test suite for Chroma DB collections, including collection listing and creation tests, followed by troubleshooting suggestions.

    From: /tf/active/vicechatdev/test_chroma_collections.py
  • function main_v26 65.2% similar

    Command-line entry point that parses arguments and orchestrates the extraction of vendor emails from all vicebio.com mailboxes using Microsoft Graph API.

    From: /tf/active/vicechatdev/find_email/extract_vendor_batch.py
  • function run_all_tests 63.8% similar

    Orchestrates a comprehensive test suite for the Vendor Email Extractor system, verifying configuration, authentication, mailbox access, email search, and LLM connectivity.

    From: /tf/active/vicechatdev/find_email/test_vendor_extractor.py
← Back to Browse