Skip to content

Commit

Permalink
fix: repo_id scheme to use a better separator (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
manishshettym authored Jun 26, 2024
1 parent c5dfd2e commit 2ddb089
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
1 change: 0 additions & 1 deletion r2e/config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
bucket_dir: buckets/repoeval_bucket
r2e_bucket_dir: buckets/r2e_bucket
repos_dir: buckets/local_repoeval_bucket/repos
cache_dir: cache_dir
2 changes: 1 addition & 1 deletion r2e/models/repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def from_file_path(cls, file_path: Path | str) -> "Repo":
# NOTE: this is a hacky way to get the repo path
repo_path = file_path.split(str(REPOS_DIR))[1].split("/")[1]
try:
repo_org, repo_name = repo_path.split("|")
repo_org, repo_name = repo_path.split("___")
except:
repo_org = repo_path
repo_name = repo_path
Expand Down
2 changes: 0 additions & 2 deletions r2e/paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
from pathlib import Path
import yaml

# TODO: FIXME! eventually, bucket_dir and r2e_bucket_dir will be merged

# Load configuration from config.yaml

current_dir = Path(__file__).parent
Expand Down
4 changes: 2 additions & 2 deletions r2e/repo_builder/run_pycg.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
def construct_pycg(repo: Repo):
cgraph = CallGraphGenerator.construct_call_graph(repo.repo_path)
GRAPHS_DIR.mkdir(parents=True, exist_ok=True)
with open(GRAPHS_DIR / f"{repo.repo_id}_cgraph.json", "w") as f:
with open(repo.callgraph_path, "w") as f:
json.dump(cgraph, f, indent=4)

CallGraphProcessor.remove_unresolvable_callers(repo)
Expand All @@ -24,7 +24,7 @@ def construct_pycg(repo: Repo):

new_cgraph = {"graph": cgdict, "id2type": id2type}

with open(GRAPHS_DIR / f"{repo.repo_id}_cgraph.json", "w") as f:
with open(repo.callgraph_path, "w") as f:
json.dump(new_cgraph, f, indent=4)

return new_cgraph
Expand Down
7 changes: 5 additions & 2 deletions r2e/repo_builder/setup_repos.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ def clone_and_setup_repos(repo_args: RepoArgs):
REPOS_DIR.mkdir(parents=True, exist_ok=True)
if repo_args.repo_url:
SetupRepos.clone_repo_from_url(repo_args.repo_url)

elif repo_args.local_repo_path:
SetupRepos.copy_repo(repo_args.local_repo_path)

elif repo_args.repo_paths_file:
with open(repo_args.repo_paths_file) as f:
repo_paths: list[str] = json.load(f)
Expand All @@ -31,6 +33,7 @@ def clone_and_setup_repos(repo_args: RepoArgs):
isinstance(x, str) for x in repo_paths
), f"Expected list of strings, got {repo_paths}"
SetupRepos.copy_repos(repo_paths, repo_args.cloning_multiprocess)

elif repo_args.repo_urls_file:
with open(repo_args.repo_urls_file) as f:
repo_urls: list[str] = json.load(f)
Expand All @@ -49,7 +52,7 @@ def clone_repo_from_url(repo_url: str):
repo_username, repo_name = (
repo_url.rstrip("/").removesuffix(".git").split("/")[-2:]
)
local_repo_clone_path = REPOS_DIR / f"{repo_username}|{repo_name}"
local_repo_clone_path = REPOS_DIR / f"{repo_username}___{repo_name}"

if os.path.exists(local_repo_clone_path):
print(
Expand All @@ -66,7 +69,7 @@ def copy_repo(local_repo_path: str):
local_repo_path = str(Path(local_repo_path).resolve())

local_repo_name = local_repo_path.split("/")[-1]
local_repo_clone_path = REPOS_DIR / f"LOCAL|{local_repo_name}"
local_repo_clone_path = REPOS_DIR / f"LOCAL___{local_repo_name}"

if os.path.exists(local_repo_clone_path):
print(
Expand Down

0 comments on commit 2ddb089

Please sign in to comment.