|
|
|
|
|
""" |
|
|
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}") |
|
|
|
|
|
|
|
|
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}") |
|
|
|
|
|
|
|
|
id_cols = [col for col in spans_df.columns if 'id' in col.lower()] |
|
|
print(f"π― ID-related columns: {id_cols}") |
|
|
|
|
|
|
|
|
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': |
|
|
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() |
|
|
|