feat: Migrate dependency management from pip to uv workspaces#202
Open
haroon0x wants to merge 2 commits intokubeflow:mainfrom
Open
feat: Migrate dependency management from pip to uv workspaces#202haroon0x wants to merge 2 commits intokubeflow:mainfrom
haroon0x wants to merge 2 commits intokubeflow:mainfrom
Conversation
Signed-off-by: haroon0x <haroonbmc0@gmail.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Signed-off-by: haroon0x <haroonbmc0@gmail.com>
Contributor
Author
|
/assign @franciscojavierarceo |
Contributor
Author
|
@franciscojavierarceo when you have a moment, could you please review this PR and merge if everything looks good? Thank you! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR replaces the per-directory
requirements.txtfiles withpyproject.tomlfiles managed byuvas a workspace. The three Python components (server,server-https,pipelines) are now workspace members under a single root configuration. Dependencies are resolved together, locked into a singleuv.lockfile, and installed into a shared venv at the root.Motivation
The existing setup had each component managing its own
requirements.txtwith no lockfile and no cross-component dependency resolution. This meant:serverandserver-https(which share most of their dependency tree) were using compatible versions of shared packages likepymilvus,sentence-transformers, ortorch.pip installon two different days could produce different dependency trees.pipresolves dependencies at install time.uvsolves all three problems. It resolves dependencies across the entire workspace in a single pass, produces a deterministic lockfile, and installs packages faster thanpip(10-20x in practice).Over the coming months, the codebase will include:
agent/layer with Kagnet for multi-tool routing and stateful reasoningfrontend/chat UI with feedback loops and golden dataset constructionEach of these additions will introduce its own set of Python dependencies. Without a workspace-level dependency manager and a deterministic lockfile, the dependency graph will become unmanageable as the repository scales. Migrating to
uvnow, while the codebase is still small, avoids a much more painful migration later when there are five or six workspace members instead of three.What changed
New files
pyproject.toml(root)requires-python >= 3.11.server/pyproject.tomlwebsockets,httpx,pymilvus,sentence-transformers,torch,numpy.server-https/pyproject.tomlfastapi,uvicorn[standard],pydantic,httpx,pymilvus,sentence-transformers,torch,numpy.pipelines/pyproject.tomlkfp,requests,beautifulsoup4,sentence-transformers,langchain-text-splitters,torch,feast[milvus],pandas,numpy..python-versionuv.lockModified files
server/Dockerfilepip install -r requirements.txtwithuv pip install -r pyproject.toml. Theuvbinary is pulled in as a multi-stage copy fromghcr.io/astral-sh/uv:latest.server-https/Dockerfile.gitignoretest-venv-swfs/(stale test virtual environment that should not be tracked).Deleted files
server/requirements.txtserver/pyproject.toml.server-https/requirements.txtserver-https/pyproject.toml.pipelines/requirements.txtpipelines/pyproject.toml.PyTorch CPU index
The root
pyproject.tomlconfigures a PyTorch CPU-only index:This replicates the
--extra-index-url https://download.pytorch.org/whl/cputhat was previously in therequirements.txtfiles. The servers do not run inference locally (they call KServe), so CUDA support is unnecessary. The CPU-only wheel is ~180 MB versus ~2 GB for the full CUDA build.The Dockerfiles also pass
--extra-index-urlexplicitly since they runuv pip installoutside the workspace context.What does NOT change
deployment.yaml,service.yaml, etc.) are unchanged. They reference Docker image names, which have not changed.docker build -t <image> server/works exactly as before.uv run python pipelines/kubeflow-pipeline.pyproduces the same YAML output.@dsl.componentdecorators still specify their ownpackages_to_installlists, which are resolved independently inside the KFP container runtime.kagent-feast-mcp/is not part of this migration. It retains its own dependency management.How to use
# Install all workspace member dependencies into .venv at root uv sync --all-packagesOnce synced, there are two equivalent ways to run scripts:
Option A: Activate the venv (recommended for active development)
source .venv/bin/activate python server/app.py python pipelines/kubeflow-pipeline.pyOption B: Use
uv run(useful for one-off commands and CI)uv runis a shortcut that temporarily activates the.venvfor a single command. For day-to-day work where you are running things repeatedly, activating the venv is simpler.Managing dependencies:
Verification
All of the following were tested and pass:
uv lockuv sync --all-packagesserver(websockets, httpx, pymilvus, sentence-transformers, numpy)server-https(fastapi, uvicorn, pydantic, httpx, pymilvus, sentence-transformers, numpy)pipelines(kfp, requests, bs4, langchain-text-splitters, feast, pandas, numpy)2.11.0+cpu)kubeflow-pipeline.py)serverserver-https