function main_v46
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.
/tf/active/vicechatdev/find_email/test_enrichment.py
137 - 163
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
argparseloggingossysrehybrid_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
Tags
Similar Components
AI-powered semantic similarity - components with related functionality:
-
function main_v9 80.3% similar
-
function test_single_vendor 71.8% similar
-
function main_v31 71.5% similar
-
function main_v26 65.2% similar
-
function run_all_tests 63.8% similar