From 493d89026710f54faa59eb9970c51ff63f5011d5 Mon Sep 17 00:00:00 2001 From: Kaiyu Yang Date: Mon, 5 Aug 2024 02:10:21 +0000 Subject: [PATCH] fix get_cache_dirname --- src/lean_dojo/data_extraction/lean.py | 2 +- tests/data_extraction/test_lean_repo.py | 8 ++++---- tests/data_extraction/test_trace.py | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/lean_dojo/data_extraction/lean.py b/src/lean_dojo/data_extraction/lean.py index d7cdf32..010469a 100644 --- a/src/lean_dojo/data_extraction/lean.py +++ b/src/lean_dojo/data_extraction/lean.py @@ -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)) diff --git a/tests/data_extraction/test_lean_repo.py b/tests/data_extraction/test_lean_repo.py index 818182c..5d20bc4 100644 --- a/tests/data_extraction/test_lean_repo.py +++ b/tests/data_extraction/test_lean_repo.py @@ -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): @@ -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): @@ -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}" diff --git a/tests/data_extraction/test_trace.py b/tests/data_extraction/test_trace.py index 04bef5f..0c9710a 100644 --- a/tests/data_extraction/test_trace.py +++ b/tests/data_extraction/test_trace.py @@ -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 @@ -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 @@ -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