Page MenuHomePhabricator

Adding uv as a package manager on Lift Wing/blubber
Open, LowPublic

Description

As an engineer,
I'd like to investigate the usage of UV as a package manager for services hosted on Lift Wing which would decrease the time our CI pipelines take to complete.
uv can act as a drop in replacement for pip and it is blazingly fast. Additionally, in some cases that poetry dependency solving takes too much time or fails, uv seems to do the job.
In order for us to be able to use uv while building production images we would need to have it available as an option in blubber.

A potential approach would be the following:
Blubber already has support for pip and poetry in the python.go config file and we could extend that to make uv available as well.

Details

Related Changes in GitLab:
TitleReferenceAuthorSource BranchDest Branch
Draft: uv_testing: uv package manager implementation in blubber.repos/releng/blubber!119gkyziridisuv_testingmain
Customize query in GitLab

Event Timeline

isarantopoulos renamed this task from Research on UV python manager. to Adding uv as a package manage on Lift Wing/blubber.Jan 23 2025, 4:09 PM
isarantopoulos updated the task description. (Show Details)
isarantopoulos moved this task from In Progress to Unsorted on the Machine-Learning-Team board.

@dduvall Hi! Just wanted to get your thought on this:

  • is this something that you have explored already?
  • have other users requested uv as a package manager?

We wanted to get your thoughts before providing an MR with a potential implementation

isarantopoulos renamed this task from Adding uv as a package manage on Lift Wing/blubber to Adding uv as a package manager on Lift Wing/blubber.Jan 28 2025, 3:58 PM

@dduvall Hi! Just wanted to get your thought on this:

  • is this something that you have explored already?
  • have other users requested uv as a package manager?

We wanted to get your thoughts before providing an MR with a potential implementation

Hi Ilias! Contributions are always welcome in Blubber (and elsewhere in our CI and deployment toolchain). I haven't used uv before so I can't speak to its benefits. (@bd808 or @dancy have thoughts perhaps?)

Having briefly scanned the README, is the pip compatible interface (uv pip) what you had in mind for the implementation?

@dduvall Hi! Just wanted to get your thought on this:

  • is this something that you have explored already?
  • have other users requested uv as a package manager?

We wanted to get your thoughts before providing an MR with a potential implementation

Hi Ilias! Contributions are always welcome in Blubber (and elsewhere in our CI and deployment toolchain). I haven't used uv before so I can't speak to its benefits. (@bd808 or @dancy have thoughts perhaps?)

Having briefly scanned the README, is the pip compatible interface (uv pip) what you had in mind for the implementation?

Hi @dduvall, thank you for your comment.
Regarding the implementation, we were thinking to have uv as an extra choice along with poetry and pip. Uv is really fast and flexible so it can work with pip as you mentioned above, but we were thinking to have it as a separate choice and use it with its pyproject.toml (exactly like poetry). So something like uv sync which installs the packages from the uv.lock which is generated based on the pyproject.toml.
Please check the cucumber feature example of python-builder it has one scenario for poetry and one for the uv accordingly.
A mockup code snippet of the python.go file could be found here.
I did not achieve to test it yet, I have some issues using the $ buildctl build in my macbook, so I am not sure how to test the changes.
Please share your thoughts about it.

Regarding the implementation, we were thinking to have uv as an extra choice along with poetry and pip. Uv is really fast and flexible so it can work with pip as you mentioned above, but we were thinking to have it as a separate choice and use it with its pyproject.toml (exactly like poetry). So something like uv sync which installs the packages from the uv.lock which is generated based on the pyproject.toml.

Make sense and sounds good to me.

Please check the cucumber feature example of python-builder it has one scenario for poetry and one for the uv accordingly.

I am delighted that you wrote a Cucumber scenario for it already. Amazing. :)

A mockup code snippet of the python.go file could be found here.

Seems like the right track so far. I'll look at it more thoroughly once you push an MR.

I did not achieve to test it yet, I have some issues using the $ buildctl build in my macbook, so I am not sure how to test the changes.
Please share your thoughts about it.

Hmm, yeah, buildctl can be a little finicky at times. I suggest using docker buildx build to test it. Just be sure to add this syntax line at the top of your blubber.yaml:

# syntax = docker-registry.wikimedia.org/repos/releng/blubber/buildkit:v1.0.1

With that you can simply do: docker buildx build -f .pipeline/blubber.yaml --target {variant} .

Hey @dduvall thank you for checking this out.
I cannot use the syntax: # syntax = docker-registry.wikimedia.org/repos/releng/blubber/buildkit:v1.0.1 in my blubber.yaml because this image does not contain any instructions for uv so it throws an error.

Based on what I understood:

  1. I need to build a new docker image with my current changes including the instructions for the uv
  2. push it to a registry
  3. then add the link of that new pushed image as syntax in my blubber.yaml
  4. then I can test it.

I haven't achieved to test it tho and I am not sure if this is the correct way to test it.
Furthermore, I am also trying to push the changes to blubber repo but I receive: The requested URL returned error: 403 can you maybe add me? I would like to open a draft-PR to discuss things over there.

Hey @dduvall thank you for checking this out.
I cannot use the syntax: # syntax = docker-registry.wikimedia.org/repos/releng/blubber/buildkit:v1.0.1 in my blubber.yaml because this image does not contain any instructions for uv so it throws an error.

Right! Sorry about that.

You are correct in that the blubber buildkit gateway image needs to be built and live somewhere that is accessible by the buildkitd instance performing the build. Usually the following should be sufficient so long as docker is using its built-in buildkitd:

  1. Run make blubber-buildkit-docker under the blubber project to build the blubber buildkit gateway image and tag it localhost/blubber-buildkit.
  2. Add # syntax = localhost/blubber-buildkit to the blubber.yaml in your python project.
  3. Build a target variant using either docker build -f .pipeline/blubber.yaml --target {variant} . or docker buildx build -f .pipeline/blubber.yaml --target {variant} ..

If you get an error that the localhost/blubber-buildkit image cannot be found, try publishing it to a public registry (such as ttl.sh).

make blubber-buildkit-docker
docker tag localhost/blubber-buildkit ttl.sh/blubber-python-uv-testing:2d
docker push ttl.sh/blubber-python-uv-testing:2d

(In this case, you would use # syntax = ttl.sh/blubber-python-uv-testing:2d.)

Furthermore, I am also trying to push the changes to blubber repo but I receive: The requested URL returned error: 403 can you maybe add me? I would like to open a draft-PR to discuss things over there.

I've added you as a developer to the project, so you should be able to push an MR now.