Skip to content

Commit

Permalink
fix get_cache_dirname
Browse files Browse the repository at this point in the history
  • Loading branch information
yangky11 committed Aug 5, 2024
1 parent 0d38707 commit 493d890
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/lean_dojo/data_extraction/lean.py
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ def is_lean4(self) -> bool:
def commit_url(self) -> str:
return f"{self.url}/tree/{self.commit}"

def format_dirname(self) -> Path:
def get_cache_dirname(self) -> Path:
"""Return the formatted cache directory name"""
assert is_commit_hash(self.commit), f"Invalid commit hash: {self.commit}"
return Path(_format_cache_dirname(self.url, self.commit))
Expand Down
8 changes: 4 additions & 4 deletions tests/data_extraction/test_lean_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def test_github_type(lean4_example_url, example_commit_hash):
assert repo.commit_url == f"{lean4_example_url}/tree/{example_commit_hash}"
# cache name
assert isinstance(repo.repo, Repository)
assert str(repo.format_dirname()) == f"yangky11-{repo_name}-{example_commit_hash}"
assert str(repo.get_cache_dirname()) == f"yangky11-{repo_name}-{example_commit_hash}"


def test_remote_type(remote_example_url, example_commit_hash):
Expand Down Expand Up @@ -83,7 +83,7 @@ def test_remote_type(remote_example_url, example_commit_hash):
assert repo.commit_url == f"{remote_example_url}/tree/{example_commit_hash}"
# cache name
assert isinstance(repo.repo, Repo)
assert str(repo.format_dirname()) == f"gitpython-{repo_name}-{example_commit_hash}"
assert str(repo.get_cache_dirname()) == f"gitpython-{repo_name}-{example_commit_hash}"


def test_local_type(lean4_example_url, example_commit_hash):
Expand Down Expand Up @@ -131,6 +131,6 @@ def test_local_type(lean4_example_url, example_commit_hash):
# cache name
assert isinstance(repo.repo, Repo) and isinstance(repo2.repo, Repo)
assert (
str(repo.format_dirname()) == f"gitpython-{repo_name}-{example_commit_hash}"
str(repo.get_cache_dirname()) == f"gitpython-{repo_name}-{example_commit_hash}"
)
assert str(repo2.format_dirname()) == f"gitpython-{repo_name}-{gh_cm_hash}"
assert str(repo2.get_cache_dirname()) == f"gitpython-{repo_name}-{gh_cm_hash}"
6 changes: 3 additions & 3 deletions tests/data_extraction/test_trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def test_github_trace(lean4_example_url):
github_repo = LeanGitRepo(lean4_example_url, "main")
assert github_repo.repo_type == RepoType.GITHUB
trace_repo = trace(github_repo)
path = cache.get(github_repo.format_dirname() / github_repo.name)
path = cache.get(github_repo.get_cache_dirname() / github_repo.name)
assert path is not None


Expand All @@ -20,7 +20,7 @@ def test_remote_trace(remote_example_url):
remote_repo = LeanGitRepo(remote_example_url, "main")
assert remote_repo.repo_type == RepoType.REMOTE
trace_repo = trace(remote_repo)
path = cache.get(remote_repo.format_dirname() / remote_repo.name)
path = cache.get(remote_repo.get_cache_dirname() / remote_repo.name)
assert path is not None


Expand All @@ -35,7 +35,7 @@ def test_local_trace(lean4_example_url):
assert local_repo.url == local_url
assert local_repo.repo_type == RepoType.LOCAL
trace_repo = trace(local_repo)
path = cache.get(local_repo.format_dirname() / local_repo.name)
path = cache.get(local_repo.get_cache_dirname() / local_repo.name)
assert path is not None


Expand Down

0 comments on commit 493d890

Please sign in to comment.