Final_Assignment_Template / debug_spans.py
Romain Fayoux
Trying to debug phoenix evals
16c91c0
raw
history blame
2.61 kB
#!/usr/bin/env python3
"""
Debug script to see Phoenix spans column structure.
"""
import sys
import os
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
import phoenix as px
import pandas as pd
def debug_spans_structure():
"""Debug the structure of Phoenix spans."""
print("πŸ” Debugging Phoenix Spans Structure")
print("=" * 50)
try:
client = px.Client()
print("βœ… Phoenix connected successfully")
except Exception as e:
print(f"❌ Phoenix connection failed: {e}")
return
try:
spans_df = client.get_spans_dataframe()
print(f"πŸ“Š Found {len(spans_df)} spans in Phoenix")
if len(spans_df) == 0:
print("⚠️ No spans found. Run your agent first to create spans.")
return
print(f"\nπŸ“‹ Available Columns ({len(spans_df.columns)} total):")
for i, col in enumerate(spans_df.columns):
print(f" {i+1:2d}. {col}")
print(f"\nπŸ” Sample Data (first span):")
sample_span = spans_df.iloc[0]
for col in spans_df.columns:
value = sample_span.get(col)
if value is not None:
value_str = str(value)[:100] + "..." if len(str(value)) > 100 else str(value)
print(f" {col}: {value_str}")
# Look for input/output related columns
input_cols = [col for col in spans_df.columns if 'input' in col.lower()]
output_cols = [col for col in spans_df.columns if 'output' in col.lower()]
print(f"\n🎯 Input-related columns: {input_cols}")
print(f"🎯 Output-related columns: {output_cols}")
# Look for span ID columns
id_cols = [col for col in spans_df.columns if 'id' in col.lower()]
print(f"🎯 ID-related columns: {id_cols}")
# Look for columns that might contain task IDs
print(f"\nπŸ” Searching for task IDs in spans...")
task_id_sample = "8e867cd7-cff9-4e6c-867a-ff5ddc2550be"
for col in spans_df.columns:
if spans_df[col].dtype == 'object': # String-like columns
try:
matches = spans_df[spans_df[col].astype(str).str.contains(task_id_sample, na=False, case=False)]
if len(matches) > 0:
print(f" βœ… Found task ID in column '{col}': {len(matches)} matches")
except:
pass
except Exception as e:
print(f"❌ Error debugging spans: {e}")
import traceback
traceback.print_exc()
if __name__ == "__main__":
debug_spans_structure()