function main_v68
A debugging utility function that analyzes and displays execution tracking information for a specific session in a statistical analysis service.
/tf/active/vicechatdev/full_smartstat/debug_execution_tracking.py
9 - 35
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.StatisticalAnalysisServiceconfig.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.
Tags
Similar Components
AI-powered semantic similarity - components with related functionality:
-
function debug_section_retrieval 61.2% similar
-
function main_v37 58.8% similar
-
function demo_analysis_workflow 58.3% similar
-
function ensure_analysis_results_consistency 58.2% similar
-
function test_data_analysis_service 58.1% similar