-
Notifications
You must be signed in to change notification settings - Fork 72
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
installation: Switch to UV for dependency management #3294
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #3294 +/- ##
==========================================
+ Coverage 90.01% 90.11% +0.10%
==========================================
Files 445 450 +5
Lines 55850 56792 +942
Branches 5372 5478 +106
==========================================
+ Hits 50272 51177 +905
- Misses 4169 4172 +3
- Partials 1409 1443 +34 ☔ View full report in Codecov by Sentry. |
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.
Could you please also migrate the makefile? Maybe with a phony target that checks whether uv is installed, and directs developers to installation instructions. The goal would be for make tests to be runnable outside of an activated venv
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 for the PR!
A few quick questions/requests I have:
- Can we move the removed requirements.txt in the pyproject.toml? That way we can still track them with dependabot, and also this is the only change that's missing to still support virtualenv. I'd personally would like to still continue supporting venv if possible, as for now it is still way more popular than uv.
- Do you think we can automate the update of uv.lock with dependabot? Currently, we get daily automated updates of dependencies with dependabot, and it would quite annoying to have to update the
uv.lock
manually every time. - We will probably have to test pythonpublish after the PR gets merged. Just ping me and I'll try to run it to see if it works or not, but looking at it this should be fine I think.
@@ -1 +0,0 @@ | |||
-e .[gui,jax,riscv,wgpu,onnx,dev] |
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.
Are these dependencies moved to uv.lock
?
I feel that this should rather go to the .toml
file so that we can track them with dependabot, it was also bad before when they were here, but at least we had a list of 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.
No, these are in the pyproject.toml, and are installed via --all-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.
We've been using uv
for our quantum stack recently and it seems to work nicely. I have a couple of comments:
- When to use
uv run
. It seems in the test ci you are activating the venv anyway so I don't see the reason to usuv run
everywhere. - If you did want to use
uv run
everywhere, you would need to make the filecheck tests use it (i.e. everyxdsl-opt
should beuv run xdsl-opt
). You can get most of these by modifyinglit.cfg
. I'm not sure if this is actually worth it? - I've always had problems with the
wgpu
package and had to manually remove it. Will there be an easy way to do that with the new set up? uv
should be added toflake.nix
(I can do this afterwards if necessary)
Ok - I think I see the problem. All the make targets using uv need to have the I assumed that people would be coming in without having cloned it already, make their venv (and install uv then), then do the other targets. In your case, you already have a venv so went straight to the other targets and it failed. I will update the PR tonight when I'm back from a commitment to hopefully fix this. |
Now the Makefile stuff is hopefully fixed, I've also hacked together something which might be able to be a stopgap for Dependabot until it officially supports I've made a demo repo here: https://github.com/EdmundGoodman/update-bot, but the idea is a cron job which runs every week and creates a PR to bump the If it seems reasonable, the change will just be adding that workflow YAML file to this PR |
This is beautiful. If I understand you correctly, the idea would be to loosen the dependabot requirements, and update the dev versions in the lockfile once a week? My understanding is that we are already too fine-grained in our dependency constraints. |
😃 ! I have added the new workflow to the PR now
I think Dependabot doesn't support
I guess some things like |
… passing tests Co-authored-by: Sasha Lopoukhine <[email protected]>
.github/dependabot.yml.bak
Outdated
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.
what is the impact of this 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.
Should we just delete it?
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.
Dependabot will no longer run - as it would do nothing anyway or throw an error as the package ecosystem is no longer pip
as it expects.
An approximation to the behaviour of Dependabot is then supported by the new custom update bot GitHub Action workflow.
When Dependabot (hopefully) eventually supports uv, it can be reverted and the package ecosystem changed to uv
If not disabling Dependabot is a strong constraint (which is fairly reasonable), then moving to uv
is blocked till it offers support for it
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.
Oops, didn't see the follow up comment - this is would make it marginally easier to (remember to?) revert it when support is added, but realistically git revert
would make more sense. I'll just delete it
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.
Yeah I'm pretty sure I'll see on either the twitter or GH when they enable Dependabot for UV, so I don't think it's a big risk.
Co-authored-by: Sasha Lopoukhine <[email protected]>
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.
What's left on the TODO list to open it up for review?
I think mostly just the stuff in the top comment:
It may also be worth ensuring there is buy-in from maintainers and key users before what is a fairly impactful if not large change. |
Hi, I added a commit to update the nix flake, hope that is ok. |
This LGTM, I guess Mathieu will test the release situation once this is merged |
Amazing, thanks! |
Sounds reasonable - if anything explodes for users when it gets merged feel free to ping me here/on Zulip and I can try to help them debug things (but hopefully everything will go smoothly 😄) |
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 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.
Almost good for me, I just want to be sure we are not regressing too much with dependabot, and keep the documentaiton for doing a pip
install.
I'll check the release once it's merged, hopefully it won't break!
.github/dependabot.yml
Outdated
# To get started with Dependabot version updates, you'll need to specify which | ||
# package ecosystems to update and where the package manifests are located. | ||
# Please see the documentation for all configuration options: | ||
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates | ||
|
||
version: 2 | ||
updates: | ||
- package-ecosystem: "pip" # See documentation for possible values | ||
directory: "/" # Location of package manifests | ||
schedule: | ||
interval: "daily" | ||
# Add assignees | ||
assignees: | ||
- "math-fehr" | ||
- "georgebisbas" | ||
commit-message: | ||
prefix: "pip prod" | ||
prefix-development: "pip dev" | ||
include: "scope" |
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.
Could we actually keep dependabot, though maybe making the schedule to "weekly" instead?
I feel that update-bot
is not as strong as dependabot, as it will not update the actual version, it will just update the minor ones (and miss security updates).
Having both at the same time is probably what we want here.
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.
tl;dr, I've just now caught up with you in realising it might be possible to use Dependabot in this case despite the docs saying its not supported. I'll try to make changes to go back to just using Dependabot and see if something breaks
Long chain of thought to justify this to myself when I come back to it tomorrow:
I've just had a further stare at this and am wondering if Dependabot might just work for
uv
despite not being explicitly supported?On modern python projects the requirements are often loosely defined in the
pyproject.toml
file (e.g.package = ^1.2.1
), then the specific versions set in a lock file such asPipenv.lock
/poetry.lock
/uv.lock
- then Dependabot acts on this lock file. Sinceuv
isn't a supported lock file type, Dependabot can't be used like this.However, I've just now realised that since this project is pinning dependency versions in
pyproject.toml
(aspip
doesn't have a lockfile), Dependabot acts on thepyproject.toml
directly -- which I hadn't seen before so didn't think to check. As such if we either: don't commit theuv
lock file; or use Dependabot in conjunction with update-bot to bump the lock file, it should all work correctlyIn future, it might be worth considering using a lock file instead of pinning dependencies in
pyproject.toml
-- but for now I think it saves us from this problem so we can just leave it.
Co-authored-by: Sasha Lopoukhine <[email protected]>
Summary
Adopt
uv
for dependency management, replacing the existingpip
approach.Motivation
uv
is developed by Astral, who also wroteruff
which is already in use in xDSL CI pipelines. It offers the benefits of much faster dependency resolution and installation, along with leveraging the more modernpyproject.toml
configuration format defined in PEPs 518 and 618.Requested by @superlopuh
Changes
This replacement requires the following changes:
venv
target of the Makefile to create the virtual environmentuv
as opposed topip
, including testingci-core.yaml
ci-mlir.yaml
ci-notebooks.yaml
ci-pyright-fails.yaml
code-formatting.yaml
jupyterlite.yaml
(cannot easily be spawned due to workflow triggers)pythonpublish.yaml
(cannot easily be spawned due to required secrets)release-notes.yaml
(requires no changes)Post-merge checklist
Once merged, we should check the following things:
uv
and instructions are clearupdate-bot
workflow creates helpful and correct PRs in a timely manner