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

lean4lean python script #421

Draft
wants to merge 21 commits into
base: main
Choose a base branch
from
Draft

lean4lean python script #421

wants to merge 21 commits into from

Conversation

Shreyas4991
Copy link
Collaborator

@Shreyas4991 Shreyas4991 commented Oct 8, 2024

Add a lean4lean verification script

@Shreyas4991 Shreyas4991 linked an issue Oct 8, 2024 that may be closed by this pull request
@Shreyas4991 Shreyas4991 added the do-not-merge This PR is not meant to be merged label Oct 8, 2024
@Shreyas4991 Shreyas4991 marked this pull request as draft October 8, 2024 02:23
@Shreyas4991 Shreyas4991 removed the do-not-merge This PR is not meant to be merged label Oct 8, 2024
@Shreyas4991 Shreyas4991 marked this pull request as ready for review October 8, 2024 02:52
@Shreyas4991 Shreyas4991 marked this pull request as draft October 8, 2024 02:53
@Shreyas4991
Copy link
Collaborator Author

Shreyas4991 commented Oct 8, 2024

@pitmonticone : This PR is ready. The scripts work on my local setup. Given the current limitations about toolchain updates in lean4lean, the script will post a message to ping the maintainers and simply not run lean4lean if the toolchains don't match or if lean4lean CLI's build fails for some reason upstream.

@Shreyas4991
Copy link
Collaborator Author

awaiting-review

@github-actions github-actions bot added the awaiting-review the PR passes CI and is ready for review label Oct 8, 2024
@pitmonticone pitmonticone self-requested a review October 8, 2024 14:06
@pitmonticone pitmonticone self-assigned this Oct 8, 2024
@Shreyas4991
Copy link
Collaborator Author

Shreyas4991 commented Oct 9, 2024

@euprunin : I took your suggestion here and removed the gitpython dependency completely. Further the script currently performs a best-possible attempt to match lean4lean's toolchain (but does so using lake) with the project toolchain and gracefully exits if this isn't possible.

@teorth teorth removed the awaiting-CI label Oct 9, 2024
@Shreyas4991
Copy link
Collaborator Author

@pitmonticone : the GitHub clone step fails for want of an ssh key. We need to fix this before any merge.

@pitmonticone
Copy link
Collaborator

Sorry but I have not yet found the time to properly review this.

Just a quick and trivial question. Why don't we switch the clone URL from SSH to HTTPS as follows?

self.l4l_repo_url = "https://github.com/digama0/lean4lean.git"

@Shreyas4991
Copy link
Collaborator Author

We could try that.

@pitmonticone
Copy link
Collaborator

I'm from mobile now and can't test anything. If you can, let me know if it works.

@pitmonticone pitmonticone marked this pull request as draft October 9, 2024 10:33
@Shreyas4991
Copy link
Collaborator Author

Shreyas4991 commented Oct 9, 2024

@digama0 : Is lean4lean expected to be this blazing fast on a project of this size? It seems to be running almost too fast. I'd like to request you to check that I have invoked it correctly in this PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this empty requirements.txt file added unintentionally? If there's no clear reason for its inclusion, you may want to consider removing it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My goal is to turn this into a package later. For now it suffices for it to run in CI.

self.project_name = "equational_theories"
self.l4l_repo_url = "https://github.com/digama0/lean4lean.git"
self.toolchain_filename = Path('lean-toolchain')
self.topPath = Path(os.getcwd())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this script deletes subdirectories (using shutil.rmtree), it seems risky to do that in what happens to be the current directory. To avoid any unexpected issues, consider setting a specific working directory.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is intentional

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you provide more details? What's the reason behind it? Why not fix a working directory to avoid that potential pitfall?

Copy link
Collaborator Author

@Shreyas4991 Shreyas4991 Oct 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To use a fresh copy of lean4lean built from lake from scratch. There are good reasons to avoid debugging lake updates when it can be avoided. Git clone reacts poorly with cloning into existing directories. Further a crash can leave lean projects in an inconsistent state. Fresh copies avoid all this fuss.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not saying you should avoid doing a fresh copy. My suggestion is to perform it in a fixed directory to prevent accidentally deleting files in the user's current working directory.

To clarify:

At the moment, you're essentially running rm -rf lean4lean, without knowing what the current working directory is.

What I'm proposing is a safer approach, like rm -rf [some-fixed-working-directory]/lean4lean.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

People will likely run the scripts in the scripts/ directory locally as well, right? I certainly do.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The script is meant to be run from the project top level. The most direct use case is the CI. Of course there is a case to be made that the same script can be used as pre-commit or pre-push hooks, we can simply link to the script from bash.

Copy link
Collaborator Author

@Shreyas4991 Shreyas4991 Oct 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For locally running this script I can include an instruction that says it should be run from the top level. For the moment I am prioritising the CI, where we can't necessarily pin the project path better than getcwd(). I do agree an absolute path would be ideal.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not advocating for hard coding an absolute path. Instead, I recommend using __file__ to obtain the script's location and then constructing the appropriate working directory relative to it.

Copy link
Collaborator Author

@Shreyas4991 Shreyas4991 Oct 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good idea.

EDIT: One issue is it fixes the subdirectory of the script and makes it fragile for use in other projects

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-review the PR passes CI and is ready for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CI : Add external checker lean4lean to CI
4 participants