-
Notifications
You must be signed in to change notification settings - Fork 198
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
Use uv-pre-commit to validate lockfile #6699
Conversation
@@ -45,9 +45,6 @@ jobs: | |||
- name: Install utils/ dependencies | |||
run: uv pip install --system -r utils/requirements.txt | |||
|
|||
- name: Validate uv lockfile |
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.
I think it's better to have this check only in one place.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #6699 +/- ##
=======================================
Coverage 78.09% 78.09%
=======================================
Files 564 564
Lines 42544 42544
=======================================
Hits 33219 33219
Misses 9325 9325 ☔ View full report in Codecov by Sentry. |
Hmm, this might be a problem, looks like
EDIT: Indeed, this is a known issue when using dynamic metadata (such as version in our case) in `pyproject.toml: astral-sh/uv-pre-commit#35 |
This might get resolved in next uv version: astral-sh/uv#10622 |
7583f79
to
aae9e94
Compare
c7189a8
to
3766c25
Compare
06bfeb3
to
7d77899
Compare
I notified the uv maintainers about the issue that blocks this PR and they already replied and it looks like it might not be difficult to fix. Other people are hitting the same issue as well so let wait a bit for the next release. astral-sh/uv#10689 |
7e12fb3
to
87b098e
Compare
@@ -85,7 +85,7 @@ jobs: | |||
with: | |||
token: ${{ secrets.CODECOV_TOKEN }} | |||
name: aiida-pytests-py3.9 | |||
file: ./coverage.xml | |||
files: ./coverage.xml |
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.
Unrelated change, this was throwing a warning in CI jobs.
@@ -512,4 +512,8 @@ commands = molecule {posargs:test} | |||
""" | |||
|
|||
[tool.uv] | |||
required-version = ">=0.5.20" | |||
# NOTE: When you bump the minimum uv version, you also need to change it in: |
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.
Thanks a lot @danielhollas
Do we need to update also here? .github/workflows/test-install.yml
(where you have astral-sh/[email protected]
)
Is it possible to simplify this, somehow?
Right now, this has to be updated manually in like 4 places...
Maybe one idea could be to have a hook on pre-commit
to read the required version from pyproject.toml
and if that doesn't match with other places (action.yml, .readthedocs.yml, etc), would automatically update them.
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.
Do we need to update also here? .github/workflows/test-install.yml (where you have astral-sh/[email protected])
Good catch. In this case, I opted to simply always install the latest uv version, since we only use it to uv pip install utils/requirements.txt
(i.e. no lockfile operations) so installing latest should be safe.
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.
Is it possible to simplify this, somehow?
I've created #6721 as a follow-up, since it is not immediately clear how to improve this, and I don't want to block this PR since it is a clear improvement over status quo. I do agree it's not ideal, but also don't see it as a huge deal. Let's discuss in #6721.
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.
Thanks @danielhollas for opening the issue #6721
I agree and LGTM! :)
with: | ||
version: 0.5.x | ||
version: latest |
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.
why do we use here latest and not version 0.5.22 as in the install-aiida-core
action. Also in that action python-version: ${{ inputs.python-version }}
is specified. Should we add here also a python-version: 3.11
?
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.
Please see: #6699 (comment)
We're only using the uv pip install
interface here so we can keep things simple.
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.
Also in that action python-version: ${{ inputs.python-version }} is specified. Should we add here also a python-version: 3.11 ?
In the actions case, specifying the python version is needed because it has a side-effect of automatically activating the virtual environment. Again, this is not needed here we can keep things simple and not duplicate the python version information.
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.
I see thanks for the clarification
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.
Thanks for the work!
There are two big advantages here: 1. Devs to have to have uv installed globally 2. We control uv version automatically.
c5356f0
to
daa3fb5
Compare
# .pre-commit-config.yaml | ||
# .github/actions/install-aiida-core/action.yml | ||
# .readthedocs.yml | ||
required-version = ">=0.5.21" |
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.
Sorry I did not notice this till now: Why do we accept also version 0.5.21 but bump in the other places the version to 0.5.22? I noticed that the version had be increased for some fixes. Are these fixes already included in 0.5.21?
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.
Yes, all the fixes are in 0.5.21. We don't need to bump the minimum supported version unless really needed.
The previous uv hook that checked whether uv lockfile is up-to-date required the developer to have uv installed. Using the official uv-pre-commit hook, this is no longer the case. The hook also updates the lock automatically, instead of just checking its status. Bump minimum version of uv to `0.5.21` fix issue astral-sh/uv#10689 uv does run the build backend for projects with dynamic versioning. Bump astral-sh/setup-uv action to v5.2.1. Change in `.github/workflows/ci-code.yml` (`file` -> `files`) is related to fixing a warning in the CI.
The previous uv hook that checked whether uv lockfile is up-to-date required the developer to have uv installed. Using the official
uv-pre-commit
hook, this is no longer the case. The hook also updates the lock automatically, instead of just checking its status.Here's the output that I got when I bumped the mypy package in pyproject.toml
(the warning is a bit unfortunate interaction between uv and pre-commit, I opened astral-sh/uv-pre-commit#36 and asked if it could be hidden so that it is not confusing for devs)