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

Devops: Install from abstract dependencies for pre-commit CI #6368

Merged
merged 3 commits into from
Apr 23, 2024

Conversation

sphuber
Copy link
Contributor

@sphuber sphuber commented Apr 22, 2024

Fixes #6366

The workflow running pre-commit was installing from the requirements before installing pip install .[pre-commit]. The install from the requirements file was added because some hooks would fail due to import errors. The proper solution is simply to install all extras whose dependencies are imported during pre-commit checks.

sphuber added 2 commits April 21, 2024 17:38
The workflow running pre-commit was installing from the requirements
before installing `pip install .[pre-commit]`. The install from the
requirements file was added because some hooks would fail due to import
errors. The proper solution is simply to install all extras whose
dependencies are imported during pre-commit checks.
@sphuber sphuber force-pushed the fix/6366/pre-commit-dependencies branch 2 times, most recently from e2689b1 to fcfffdd Compare April 22, 2024 22:09
- name: Install python dependencies
uses: ./.github/actions/install-aiida-core
with:
python-version: '3.10'
extras: '[pre-commit]'
from-requirements: 'true'
extras: '[atomic_tools,pre-commit,rest,tests,tui]'
Copy link
Collaborator

Choose a reason for hiding this comment

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

I was thinking about this and I found this solution really unintuitive and ran into this problem many times locally.

As a developer, I would expect that if I install pre-commit extras, the pre-commit checks shoud simply pass, instead of having to figure out essentially manually which other extras I need...

Copy link
Collaborator

Choose a reason for hiding this comment

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

Could we instead tell mypy to install additional dependencies (e..g type stubs), like we do in aiidalab-launch? Although I guess i am not sure how to ensure the correct versions are installed?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Another option, seems like since pip 21.2, one could define extras recursively, so [pre-commit] could transitively include all the needed extras?

https://hynek.me/articles/python-recursive-optional-dependencies/

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As a developer, I would expect that if I install pre-commit extras, the pre-commit checks shoud simply pass, instead of having to figure out essentially manually which other extras I need...

Fair enough, but I really didn't want to duplicate requirements in pre-commit just because they need to be importable.

Could we instead tell mypy to install additional dependencie

We could, but that would require again duplicating requirements which risk running out of sync, and it is not just mypy that would need this.

Another option, seems like since pip 21.2, one could define extras recursively, so [pre-commit] could transitively include all the needed extras?

That is great actually. If that also works with uv, that'd be a great solution as far as I am concerned.

pyproject.toml Outdated Show resolved Hide resolved
Co-authored-by: Daniel Hollas <[email protected]>
@sphuber sphuber requested a review from danielhollas April 23, 2024 07:09
Copy link
Collaborator

@danielhollas danielhollas left a comment

Choose a reason for hiding this comment

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

Awesome, also tested with pip / uv locally

@sphuber sphuber merged commit 6564e78 into aiidateam:main Apr 23, 2024
19 checks passed
@sphuber sphuber deleted the fix/6366/pre-commit-dependencies branch April 23, 2024 07:52
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.

pre-commit extras missing dependencies
2 participants