|
|
|
|
|
""" |
|
|
Debug script for search_code function |
|
|
""" |
|
|
|
|
|
import sys |
|
|
import os |
|
|
from pathlib import Path |
|
|
|
|
|
|
|
|
sys.path.insert(0, str(Path(__file__).parent / 'atles')) |
|
|
|
|
|
def debug_search(): |
|
|
"""Debug the search_code function step by step.""" |
|
|
print("π Debugging search_code function...") |
|
|
print("=" * 50) |
|
|
|
|
|
try: |
|
|
|
|
|
print("1οΈβ£ Testing direct import...") |
|
|
try: |
|
|
from atles.datasets.dataset_manager import CodeDatasetManager |
|
|
print(" β
Imported from atles.datasets.dataset_manager") |
|
|
except ImportError as e: |
|
|
print(f" β Import failed: {e}") |
|
|
return |
|
|
|
|
|
|
|
|
print("2οΈβ£ Creating CodeDatasetManager...") |
|
|
manager = CodeDatasetManager() |
|
|
print(" β
Manager created successfully") |
|
|
|
|
|
|
|
|
print("3οΈβ£ Checking available datasets...") |
|
|
info = manager.get_dataset_info() |
|
|
print(f" π Available datasets: {list(info.keys())}") |
|
|
|
|
|
|
|
|
print("4οΈβ£ Testing search with different parameters...") |
|
|
|
|
|
|
|
|
print(" π Test 4a: Basic search for 'python'") |
|
|
results = manager.search_code("python") |
|
|
print(f" Found {len(results)} results") |
|
|
|
|
|
|
|
|
print(" π Test 4b: Search for 'python' with language='python'") |
|
|
results = manager.search_code("python", "python") |
|
|
print(f" Found {len(results)} results") |
|
|
|
|
|
|
|
|
print(" π Test 4c: Search for 'python' with dataset_type='github_code'") |
|
|
results = manager.search_code("python", dataset_type="github_code") |
|
|
print(f" Found {len(results)} results") |
|
|
|
|
|
|
|
|
print(" π Test 4d: Search for 'flask' with language='python' and dataset_type='github_code'") |
|
|
results = manager.search_code("flask", "python", "github_code") |
|
|
print(f" Found {len(results)} results") |
|
|
|
|
|
if results: |
|
|
print(" First result:") |
|
|
first = results[0] |
|
|
print(f" Title: {first.get('title', 'No title')}") |
|
|
print(f" Language: {first.get('language', 'No language')}") |
|
|
print(f" Tags: {first.get('tags', [])}") |
|
|
|
|
|
|
|
|
print("5οΈβ£ Testing specific dataset...") |
|
|
try: |
|
|
github_dataset = manager.github_code |
|
|
print(f" π GitHub dataset: {github_dataset.get_metadata()}") |
|
|
github_results = github_dataset.search("flask", "python") |
|
|
print(f" π GitHub search results: {len(github_results)}") |
|
|
except Exception as e: |
|
|
print(f" β GitHub dataset test failed: {e}") |
|
|
|
|
|
print("\nβ
Debug completed!") |
|
|
|
|
|
except Exception as e: |
|
|
print(f"β Debug failed: {e}") |
|
|
import traceback |
|
|
traceback.print_exc() |
|
|
|
|
|
if __name__ == "__main__": |
|
|
debug_search() |
|
|
|