🔍 Code Extractor

function main_v68

Maturity: 32

A debugging utility function that analyzes and displays execution tracking information for a specific session in a statistical analysis service.

File:
/tf/active/vicechatdev/full_smartstat/debug_execution_tracking.py
Lines:
9 - 35
Complexity:
simple

Purpose

This function serves as a diagnostic tool to inspect the execution steps and metadata of a statistical analysis session. It retrieves session steps from the database, displays detailed information about each step (including type, ID, success status, and metadata), and tests the internal execution tracking method. This is primarily used for debugging and verifying that session execution data is being properly stored and retrieved.

Source Code

def main():
    config = Config()
    service = StatisticalAnalysisService(config)
    
    session_id = '3fea9b6e-92ea-462a-ba67-996f251e39db'
    print(f"Debugging execution tracking for session: {session_id}")
    
    # Get steps directly
    steps = service.database_manager.get_session_steps(session_id)
    print(f"\nFound {len(steps)} steps:")
    
    for i, step in enumerate(steps):
        print(f"  Step {i+1}: {step.step_type}")
        print(f"    ID: {step.step_id}")
        print(f"    Success: {step.execution_success}")
        print(f"    Has metadata: {bool(step.metadata)}")
        if step.metadata:
            print(f"    Metadata keys: {list(step.metadata.keys())}")
            if 'execution_log' in step.metadata:
                print(f"    Execution log entries: {len(step.metadata['execution_log'])}")
        print()
    
    # Test the execution tracking method
    print("Testing _get_execution_tracking method:")
    result = service._get_execution_tracking(session_id)
    print(f"Result keys: {list(result.keys())}")
    print(f"Result: {result}")

Return Value

This function does not return any value (implicitly returns None). It produces console output displaying session step information and execution tracking results.

Dependencies

  • services.StatisticalAnalysisService
  • config.Config

Required Imports

from services import StatisticalAnalysisService
from config import Config

Usage Example

# Ensure config.py and services module are available
# from config import Config
# from services import StatisticalAnalysisService

def main():
    config = Config()
    service = StatisticalAnalysisService(config)
    
    session_id = '3fea9b6e-92ea-462a-ba67-996f251e39db'
    print(f"Debugging execution tracking for session: {session_id}")
    
    steps = service.database_manager.get_session_steps(session_id)
    print(f"\nFound {len(steps)} steps:")
    
    for i, step in enumerate(steps):
        print(f"  Step {i+1}: {step.step_type}")
        print(f"    ID: {step.step_id}")
        print(f"    Success: {step.execution_success}")
        print(f"    Has metadata: {bool(step.metadata)}")
        if step.metadata:
            print(f"    Metadata keys: {list(step.metadata.keys())}")
            if 'execution_log' in step.metadata:
                print(f"    Execution log entries: {len(step.metadata['execution_log'])}")
        print()
    
    print("Testing _get_execution_tracking method:")
    result = service._get_execution_tracking(session_id)
    print(f"Result keys: {list(result.keys())}")
    print(f"Result: {result}")

if __name__ == '__main__':
    main()

Best Practices

  • This function is hardcoded to debug a specific session ID ('3fea9b6e-92ea-462a-ba67-996f251e39db'). Modify the session_id variable to debug different sessions.
  • Ensure the database connection is properly configured before running this function to avoid connection errors.
  • This function accesses a private method (_get_execution_tracking) which may change in future versions of the service.
  • Use this function in development/debugging environments only, not in production code.
  • The function assumes the session exists in the database; add error handling if using with dynamic session IDs.
  • Consider parameterizing the session_id if this function will be reused for multiple sessions.

Similar Components

AI-powered semantic similarity - components with related functionality:

  • function debug_section_retrieval 61.2% similar

    A debugging utility function that tests database section retrieval by querying a specific text section and printing detailed diagnostic information about the section and its chat session association.

    From: /tf/active/vicechatdev/vice_ai/debug_section_retrieval.py
  • function main_v37 58.8% similar

    A diagnostic function that explores SharePoint site structure to investigate why only 2 folders are visible when more are expected in the web interface.

    From: /tf/active/vicechatdev/SPFCsync/diagnostic_comprehensive.py
  • function demo_analysis_workflow 58.3% similar

    Demonstrates a complete end-to-end statistical analysis workflow using the SmartStat system, including session creation, data loading, natural language query processing, analysis execution, and result interpretation.

    From: /tf/active/vicechatdev/full_smartstat/demo.py
  • function ensure_analysis_results_consistency 58.2% similar

    Validates and ensures that analysis results for a given session are properly stored in the database and accessible, performing consistency checks on generated files.

    From: /tf/active/vicechatdev/full_smartstat/app.py
  • function test_data_analysis_service 58.1% similar

    A test function that validates the functionality of the DataAnalysisService by creating, initializing, and retrieving analysis sessions.

    From: /tf/active/vicechatdev/vice_ai/test_integration.py
← Back to Browse