Spaces:
Sleeping
Sleeping
File size: 3,713 Bytes
65bb1b0 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | """
Debug script to verify grant data is loading correctly.
Run with: python debug_data.py
"""
from pathlib import Path
from src.analyzer.data_loader import load_current_grants
from src.analyzer.search.service import get_grant_by_id
print("=" * 60)
print("GRANT DATA DEBUG")
print("=" * 60)
# Load all grants
print("\n1. Loading grants from snapshots...")
grants = load_current_grants(Path('data/snapshots'))
print(f" β Loaded {len(grants)} grants")
# Check grant 2313 specifically
print("\n2. Checking competition-2313 (Battery Feasibility)...")
grant_2313 = next((g for g in grants if '2313' in g.id), None)
if grant_2313:
print(f" β Found grant: {grant_2313.title}")
print(f" Status: {grant_2313.status}")
print(f" Has funding: {grant_2313.funding is not None}")
if grant_2313.funding:
print(f" Funding min: Β£{grant_2313.funding.min:,.0f}" if grant_2313.funding.min else " Funding min: None")
print(f" Funding max: Β£{grant_2313.funding.max:,.0f}" if grant_2313.funding.max else " Funding max: None")
print(f" Total pot: Β£{grant_2313.funding.total_pot:,.0f}" if grant_2313.funding.total_pot else " Total pot: None")
else:
print(" β NO FUNDING DATA")
print(f" Has summary: {grant_2313.summary is not None and len(grant_2313.summary) > 0}")
print(f" Close date: {grant_2313.close_date}")
print(f" URL: {grant_2313.url}")
else:
print(" β Grant 2313 not found in loaded grants!")
# Check grant 2314
print("\n3. Checking competition-2314 (Battery Concept)...")
grant_2314 = next((g for g in grants if '2314' in g.id), None)
if grant_2314:
print(f" β Found grant: {grant_2314.title}")
print(f" Status: {grant_2314.status}")
if grant_2314.funding:
print(f" Funding min: Β£{grant_2314.funding.min:,.0f}" if grant_2314.funding.min else " Funding min: None")
print(f" Funding max: Β£{grant_2314.funding.max:,.0f}" if grant_2314.funding.max else " Funding max: None")
else:
print(" β NO FUNDING DATA")
else:
print(" β Grant 2314 not found!")
# Check search index
print("\n4. Checking search index (get_grant_by_id)...")
try:
indexed_grant = get_grant_by_id("competition-2313")
if indexed_grant:
print(f" β Found via search index: {indexed_grant.title}")
print(f" Status via index: {indexed_grant.status}")
print(f" Has funding via index: {indexed_grant.funding is not None}")
if indexed_grant.funding:
print(f" Funding via index: Β£{indexed_grant.funding.min:,.0f} - Β£{indexed_grant.funding.max:,.0f}")
else:
print(" β NO FUNDING DATA VIA INDEX")
else:
print(" β Not found via search index")
except Exception as e:
print(f" β Error accessing index: {e}")
# Summary
print("\n" + "=" * 60)
print("DIAGNOSIS:")
print("=" * 60)
has_data = grant_2313 and grant_2313.funding and grant_2313.funding.min
has_indexed_data = False
try:
indexed_grant = get_grant_by_id("competition-2313")
has_indexed_data = indexed_grant and indexed_grant.funding and indexed_grant.funding.min
except:
pass
if has_data and has_indexed_data:
print("β Data is present and index is working")
print(" Issue is likely in context building or LLM prompt")
elif has_data and not has_indexed_data:
print("β Data exists in snapshots")
print("β Search index is not preserving the data")
print(" ACTION: Rebuild search index")
elif not has_data:
print("β Data missing from snapshot files")
print(" ACTION: Re-run scraper to get funding data")
else:
print("? Unclear - check logs above")
print("=" * 60)
|