Spaces:
Sleeping
Sleeping
| import asyncio | |
| import os | |
| import json | |
| from supabase import create_client | |
| from dotenv import load_dotenv | |
| from src.matching.similarity import calculate_granular_match_score | |
| load_dotenv() | |
| SUPABASE_URL = os.environ.get("SUPABASE_URL") | |
| SUPABASE_KEY = os.environ.get("SUPABASE_SERVICE_ROLE_KEY") or os.environ.get("SUPABASE_KEY") | |
| client = create_client(SUPABASE_URL, SUPABASE_KEY) | |
| async def run_test(): | |
| res = client.table("applications").select("user_id, job_id").limit(1).execute() | |
| if not res.data: | |
| print("No apps found") | |
| return | |
| c_id = res.data[0]["user_id"] | |
| j_id = res.data[0]["job_id"] | |
| # Raw fetch | |
| p_emb = client.table("profile_embeddings").select("*").eq("id", c_id).execute().data[0] | |
| j_emb = client.table("job_embeddings").select("*").eq("job_id", j_id).execute().data[0] | |
| log = [] | |
| log.append(f"Testing {c_id} against {j_id}") | |
| def get_len(v): | |
| if v is None: return "None" | |
| if isinstance(v, str): | |
| try: | |
| # Approximate len by comma count | |
| return v.count(',') + 1 | |
| except: return "StringError" | |
| return len(v) | |
| log.append("\n--- Profile Lengths ---") | |
| for k in ['skills', 'technical_skills', 'experience', 'certifications']: | |
| log.append(f"{k}: {get_len(p_emb.get(k))}") | |
| log.append("\n--- Job Lengths ---") | |
| for k in ['skills', 'technical_skills', 'work_experience', 'certifications']: | |
| log.append(f"{k}: {get_len(j_emb.get(k))}") | |
| result = await calculate_granular_match_score(client, c_id, j_id) | |
| log.append(f"\nResult: {json.dumps(result)}") | |
| with open("debug_log.txt", "w") as f: | |
| f.write("\n".join(log)) | |
| print("Logged to debug_log.txt") | |
| if __name__ == "__main__": | |
| asyncio.run(run_test()) | |