aiidateam / aiida-core

The official repository for the AiiDA code
https://aiida-core.readthedocs.io
Other
413 stars 185 forks source link

CI: Use uv installer #6363

Closed danielhollas closed 2 months ago

danielhollas commented 2 months ago

uv is the new cool kid in the town of Python packaging, from the creators of ruff. It currently serves as a (much) faster drop-in replacement for pip.

We've been using it for a couple of repos in AiiDAlab and it works great. For aiida-core, it cuts installation time from ~1m30s to ~10s, so it seems worthwhile.

So far I've only touched jobs in ci-code.yml. If desired, I can make similar changes to other workflows that would benefit (e.g. pre-commit)

danielhollas commented 2 months ago

Hmm, this check failure is strange and seems unrelated to this PR?

https://github.com/aiidateam/aiida-core/actions/runs/8775766327/job/24078477856

(detected asyncio module being loaded in verdi during tab completion? But only for version 3.9, not 3.12?)

EDIT: I also don't understand the pre-commit job failure? Maybe uv flake? https://github.com/aiidateam/aiida-core/actions/runs/8775766331/job/24078477013?pr=6363 (but is the pre-commit workflow even needed given that we use pre-commit.ci app anyway?

sphuber commented 2 months ago

EDIT: I also don't understand the pre-commit job failure? Maybe uv flake? https://github.com/aiidateam/aiida-core/actions/runs/8775766331/job/24078477013?pr=6363

It seems to be a straigh-up error in uv indeed. That would be worrying. Not really interested in adding a flaky installer. A quick search comes up with this: https://github.com/astral-sh/uv/issues/2941 Seems it was a real bug in 0.1.30, but should have been fixed in the version you are currently using.

Finally, we should also see if we can use a cache for downlaoded packages. This is currently done through the setup-python action, but not sure if they support uv already.

sphuber commented 2 months ago

Things are going well I see :joy:

danielhollas commented 2 months ago

Things are going well I see 😂

:sob: I hate GHA more and more...

Anyway, I think this is now ready. :tada:

It seems to be a straigh-up error in uv indeed. That would be worrying. Not really interested in adding a flaky installer. A quick search comes up with this: https://github.com/astral-sh/uv/issues/2941

Turns out this was largely my error, I was trying to install pre-commit extras with --no-deps, you can easily reproduce this by

uv venv
uv pip install  --no-deps -e .[pre-commit]

pip in this case simply ignores the extras (which tbh is a fishy behaviour), I'll open an issue to uv to catch this. Opened an issue: https://github.com/astral-sh/uv/issues/3184

Finally, we should also see if we can use a cache for downlaoded packages. This is currently done through the setup-python action, but not sure if they support uv already.

Given uv's speed I don't think its worth it, also uv's cache is not really space efficient (uncompressed) so it takes non-trivial amount of time to fetch. See some discussions on this: https://github.com/astral-sh/uv/issues/2231#issuecomment-2024065841

This comment indicates that having cache might be worthwhile if uv needs to do expensive source dist builds, not sure if that's the case here. https://github.com/astral-sh/uv/issues/1386#issuecomment-1975194002

Anyway, I'd leave that for a follow-up PR. :stuck_out_tongue: