Spaces:
Sleeping
Sleeping
File size: 1,818 Bytes
4b3a33f | 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 | 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())
|