Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: deleting incorrect repo path #426

Merged
merged 3 commits into from
Jan 10, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions evals/eval_swe_bench.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from cognee.modules.retrieval.description_to_codepart_search import (
code_description_to_code_part_search,
)
from evals.eval_utils import download_github_repo, retrieved_edges_to_string


def check_install_package(package_name):
Expand All @@ -33,12 +34,11 @@ def check_install_package(package_name):


async def generate_patch_with_cognee(instance):
"""repo_path = download_github_repo(instance, "../RAW_GIT_REPOS")"""
repo_path = download_github_repo(instance, "../RAW_GIT_REPOS")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Improve repository path handling and add error handling

Several improvements needed for the repository download:

  1. The hardcoded relative path "../RAW_GIT_REPOS" is fragile and traverses outside the package directory. Consider:

    • Using an absolute path from a configuration
    • Using a path within the package directory
    • Using a temporary directory
  2. Add error handling for download failures

Example implementation:

-    repo_path = download_github_repo(instance, "../RAW_GIT_REPOS")
+    try:
+        # Option 1: Use package directory
+        from pathlib import Path
+        package_root = Path(__file__).parent.parent
+        repos_dir = package_root / "data" / "repos"
+        repo_path = download_github_repo(instance, repos_dir)
+        
+        # Option 2: Use temporary directory
+        # import tempfile
+        # with tempfile.TemporaryDirectory() as repos_dir:
+        #     repo_path = download_github_repo(instance, repos_dir)
+    except Exception as e:
+        raise RuntimeError(f"Failed to download repository: {e}")

Committable suggestion skipped: line range outside the PR's diff.

include_docs = True
problem_statement = instance["problem_statement"]
instructions = read_query_prompt("patch_gen_kg_instructions.txt")

repo_path = "/Users/laszlohajdu/Documents/GitHub/graph_rag/"
async for result in run_code_graph_pipeline(repo_path, include_docs=include_docs):
print(result)

Expand Down
Loading