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

Extend function features to allow new repo types #190

Closed
wants to merge 7 commits into from

Conversation

RexWzh
Copy link
Contributor

@RexWzh RexWzh commented Jul 25, 2024

Main Changes

  1. Lean Version: Use string for lean_version instead of a commit hash. Postpone the initialization of the Lean4 repository.
  2. Cache: Update cache.get and cache.store for increased flexibility.
  3. Repository Type: Extend function capabilities to support new repository types, such as _to_commit_hash, normalize_url, get_latest_commit, and url_to_repo, each with tests to ensure reliability.

Progress

Implementation plan for the new feature:

@RexWzh RexWzh marked this pull request as draft July 25, 2024 08:21
@RexWzh RexWzh marked this pull request as ready for review July 25, 2024 19:32
Comment on lines 241 to +246
try:
with urllib.request.urlopen(url) as _:
request = urllib.request.Request(url)
gh_token = os.getenv("GITHUB_ACCESS_TOKEN")
if gh_token is not None:
request.add_header("Authorization", f"token {gh_token}")
with urllib.request.urlopen(request) as _:
Copy link
Contributor Author

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 the trace function is taking a long time due to the absence of GitHub token here

def _trace(repo: LeanGitRepo, build_deps: bool) -> None:
    assert (
        repo.exists()
    ), f"The {repo} does not exist. Please check the URL `{repo.commit_url}`."

@RexWzh
Copy link
Contributor Author

RexWzh commented Jul 25, 2024

Thank you @yangky11 , for your thorough review of most of the work.

The remaining tasks are straightforward after this PR merged.

Two notes to mention:

  1. The test case remote_example_url currently uses my cloned URL on gitee.com, which will not change, but can be replaced if needed.
  2. As git.Repo requires a directory, I plan to place them in .cache/lean_dojo/repos in the last PR.

For compatibility, the cache directory looks like:

❯ tree -L 2 lean_dojo
lean_dojo
├── leanprover-community-aesop-79fb157c6a5061190d169535f8e5cb007914a82e
├── leanprover-community-batteries-d2b1546c5fc05a06426e3f6ee1cb020e71be5592
├── repos
│   ├── rexzong-lean4-example-3f8c5eb303a225cdef609498b8d87262e5ef344b
│   └── testrepo-lean4-example-3f8c5eb303a225cdef609498b8d87262e5ef344b
├── yangky11-lean4-example-3f8c5eb303a225cdef609498b8d87262e5ef344b
└── yangky11-lean4-example-7b6ecb9ad4829e4e73600a3329baeb3b5df8d23f

11 directories, 0 files

Pytest result
image

@RexWzh
Copy link
Contributor Author

RexWzh commented Jul 29, 2024

merge to #179

@RexWzh RexWzh closed this Jul 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant