-
Notifications
You must be signed in to change notification settings - Fork 192
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
Update uv.lock + CI tweaks + fix pymatgen issue #6676
Conversation
34bffbf
to
8e66b24
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #6676 +/- ##
=======================================
Coverage 77.94% 77.94%
=======================================
Files 563 563
Lines 41761 41761
=======================================
Hits 32545 32545
Misses 9216 9216 ☔ View full report in Codecov by Sentry. |
8e66b24
to
475cedb
Compare
There's one failing test in test-install with Python 3.9, due to astral-sh/setup-uv#219
EDIT: This was now resolved upstream, but was not release yet. I've added a workaround in the meantime so we can move in with this PR. |
@@ -64,8 +64,7 @@ jobs: | |||
python-version: ${{ matrix.python-version }} | |||
|
|||
- name: Setup environment | |||
# Note: The virtual environment in .venv was created by uv in previous step | |||
run: source .venv/bin/activate && .github/workflows/setup.sh |
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 updated setup-uv action now activates the virtual environment automatically.
568639a
to
77f1481
Compare
77f1481
to
86938af
Compare
@unkcpz @agoscinski this is now ready for review, please take a look, I've written an extended PR description, let me know if anything is not clear. Note in particular:
Regardless if we decide if this is a good solution or not, I think this PR should go in first before #6680 since it fixes the pymatgen issue for everything except Python 3.9. |
|
||
- name: Install dependencies from uv lock | ||
if: ${{ inputs.from-lock == 'true' }} | ||
# NOTE: We're asserting that the lockfile is up to date | ||
# NOTE2: 'pre-commit' extra recursively contains other extras | ||
# needed to run the tests. | ||
run: uv sync --locked --extra pre-commit |
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.
Previously we were not respecting the inputs.extras
when using the lockfile. Now we do (at the expense of very ugly Github Actions syntax :-( )
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 is inspired from JavaScript so at least not completely random.
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.
in CI will inputs.extras
in uv sync --locked ${{ inputs.extras && format('--extra {0}', inputs.extras) || '' }}
always be true
? Because if it is not pass as input it will set to "pre-commit" as default, no? Then this clause can be simplified.
Never mind, I see extra='' below.
shell: bash | ||
|
||
- name: Install aiida-core | ||
if: ${{ inputs.from-lock != 'true' }} | ||
run: uv pip install --system -e .${{ inputs.extras }} |
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.
Since now setup-uv
action activates the virtual environment automatically, we no longer need to install into system python.
run: uv run pytest -n auto --db-backend psql -m 'not nightly' tests/ ${{ matrix.python-version == '3.9' && '--cov aiida' || '' }} | ||
# NOTE2: Unset CI envvar to workaround a pymatgen issue for Python 3.9 | ||
# https://github.com/materialsproject/pymatgen/issues/4243 | ||
# TODO: Remove a workaround for VIRTUAL_ENV once the setup-uv action is updated |
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.
This issue is described in detail in #6676 (comment).
I'll remove the workaround hopefully soon in a subsequent PR.
|
||
- name: Install utils/ dependencies | ||
run: uv pip install --system -r utils/requirements.txt | ||
|
||
- name: Validate uv lockfile | ||
run: uv lock --locked | ||
run: uv lock --check |
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 --check
option is a new alias for --locked
which is more intuitive.
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.
Looks good to me, just need some clarifications with some changes
|
||
- name: Install dependencies from uv lock | ||
if: ${{ inputs.from-lock == 'true' }} | ||
# NOTE: We're asserting that the lockfile is up to date | ||
# NOTE2: 'pre-commit' extra recursively contains other extras | ||
# needed to run the tests. | ||
run: uv sync --locked --extra pre-commit |
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 is inspired from JavaScript so at least not completely random.
@@ -11,6 +11,9 @@ on: | |||
schedule: | |||
- cron: 30 02 * * * # nightly build | |||
|
|||
env: | |||
FORCE_COLOR: 1 |
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 this has to be added in this PR? I just don't see anything related to it. Is it just to ensure that colors are used for visuals? I am asking because I remember that some tests rely on the color and fail when playing with these options but I don't remember the details anymore.
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.
This is just an unrelated improvement to add colors to pytest output in GitHub UI.
I am not aware of any tests that would depend on colors, and we're already using this option in many other workflows (e.g. ci-code) so I think this is a safe change.
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.
There was something that failed in #6434 when I enforced colors but I cannot check it because the CI result already removed it. But when the test pass it should be okay!
from-lock: 'false' | ||
from-lock: 'true' | ||
# NOTE: The `verdi devel check-undesired-imports` fails if | ||
# the 'tui' extra is installed. |
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.
This appears now because with the changes in the install-aiida-core
we install all extras? Isn't this failure something we should fix later on?
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.
So there are two things here:
- The extras parameter was added since the default has changed. So that change is necessary.
- Now that we respect the
extras
parameter when using the lock, I think it is better to use the lockfile. You're right that this change here is not necessary, it just makes things more consistent, since now all jobs in ci-code.yml use the 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.
Ah sorry for being not clear. I am fine with the changes, just would like to know if we should make an issue and fix it in some later PR
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 this is minor enough that it could go in here, but let me know if you disagree.
I can open an issue about converting more CI jobs to use the lockfile though.
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 mean that verdi devel check-undesired-imports
fails when tui is installed sounds undesirable and sounds like this should be fixed like only check for asyncio if tui is not installed
. I am not sure why this happens
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.
Aaah, now I see what you mean. Sorry, I misunderstood your original comment.
Yeah, I'll open an issue for that.
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.
Opened #6691 to follow up on this
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.
In the new uv version, this is not the case, and uv will try to find the newest version of a package for a given python version.
This is nice!
It looks good, thanks @danielholla Just a small question.
|
||
- name: Install dependencies from uv lock | ||
if: ${{ inputs.from-lock == 'true' }} | ||
# NOTE: We're asserting that the lockfile is up to date | ||
# NOTE2: 'pre-commit' extra recursively contains other extras | ||
# needed to run the tests. | ||
run: uv sync --locked --extra pre-commit |
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.
in CI will inputs.extras
in uv sync --locked ${{ inputs.extras && format('--extra {0}', inputs.extras) || '' }}
always be true
? Because if it is not pass as input it will set to "pre-commit" as default, no? Then this clause can be simplified.
Never mind, I see extra='' below.
Thanks for the work @danielhollas this was really helpful! |
Thanks @danielhollas I merge it to not block other PRs on going. |
I've recreated the uv lockfile (
uv.lock
) with a newer uv version that uses an updated resolution strategy, which in particular solves an issue reported by @agoscinski in #6640 (comment)uv produces a "universal" lockfile for all python versions that we support, i.e >=3.9.
Previously, it tried to find a version of the package that would be compatible with all supported Python versions, which in turn meant that if a package dropped support for 3.9 for example, we'd be stuck on an old version.
In the new uv version, this is not the case, and uv will try to find the newest version of a package for a given python version.
Incidentally, this also help partly resolve the pymatgen issue, see #6680. The issue has been fixed in a new version of
monty
package, which however does not support Python 3.9. So in the updated lockfile, the issue is fixed for Python >=3.10.For Python 3.9, I added a workaround suggested in materialsproject/pymatgen#4243 (comment), and unset the CI environmental variable.
Since this woraround is quite targeted (only in two specific job steps, and only for Python 3.9), I believe this is acceptable, and we will be dropping Python 3.9 support sometimes this year anyway.