-
Notifications
You must be signed in to change notification settings - Fork 96
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
Extend function features to allow new repo types #190
Closed
Closed
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
a8a0977
simplify commit hash & delay initalization of lean4 repo
RexWzh fab19e2
lean version: use string instead of commit
RexWzh 570e787
Merge remote-tracking branch 'origin/dev' into simplify-funcs
RexWzh eabaa22
update cache method
RexWzh ff0f9f4
update functions for git Repos & add tests
RexWzh 6c7ef63
fix url_exists
RexWzh e5941ff
allow repo_type of git@github.com
RexWzh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# test for cache manager | ||
from git import Repo | ||
from lean_dojo.utils import working_directory | ||
from pathlib import Path | ||
from lean_dojo.data_extraction.lean import _format_dirname | ||
from lean_dojo.data_extraction.cache import cache | ||
|
||
|
||
def test_get_cache(lean4_example_url, remote_example_url, example_commit_hash): | ||
# Note: The `git.Repo` requires the local repo to be cloned in a directory | ||
# all cached repos are stored in CACHE_DIR/repos | ||
prefix = "repos" | ||
|
||
# test local repo cache | ||
with working_directory() as tmp_dir: | ||
# assume that the local repo placed in `/.../testrepo/lean4-example` | ||
repo = Repo.clone_from(lean4_example_url, "testrepo/lean4-example") | ||
repo.git.checkout(example_commit_hash) | ||
local_dir = tmp_dir / "testrepo/lean4-example" | ||
# use local_dir as the key to store the cache | ||
rel_cache_dir = ( | ||
prefix | ||
/ Path(_format_dirname(str(local_dir), example_commit_hash)) | ||
/ local_dir.name | ||
) | ||
cache.store(local_dir, rel_cache_dir) | ||
# get the cache | ||
local_url, local_commit = str(local_dir), example_commit_hash | ||
repo_cache = cache.get(local_url, local_commit, prefix) | ||
assert ( | ||
_format_dirname(local_url, local_commit) | ||
== f"{local_dir.parent.name}-{local_dir.name}-{local_commit}" | ||
) | ||
assert repo_cache is not None | ||
|
||
# test remote repo cache | ||
with working_directory() as tmp_dir: | ||
repo = Repo.clone_from(remote_example_url, "lean4-example") | ||
repo.git.checkout(example_commit_hash) | ||
tmp_remote_dir = tmp_dir / "lean4-example" | ||
# use remote url as the key to store the cache | ||
rel_cache_dir = ( | ||
prefix | ||
/ Path(_format_dirname(str(remote_example_url), example_commit_hash)) | ||
/ tmp_remote_dir.name | ||
) | ||
cache.store(tmp_remote_dir, rel_cache_dir) | ||
# get the cache | ||
remote_url, remote_commit = remote_example_url, example_commit_hash | ||
repo_cache = cache.get(remote_url, remote_commit, prefix) | ||
assert repo_cache is not None | ||
assert ( | ||
_format_dirname(remote_url, remote_commit) | ||
== f"rexzong-lean4-example-{example_commit_hash}" | ||
) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
repo.exists
call in thetrace
function is taking a long time due to the absence of GitHub token here