Skip to content

Feat: migrate to uv from pip#75

Open
fujikosu wants to merge 33 commits intomainfrom
feat/migrate-to-uv-from-pip
Open

Feat: migrate to uv from pip#75
fujikosu wants to merge 33 commits intomainfrom
feat/migrate-to-uv-from-pip

Conversation

@fujikosu
Copy link
Copy Markdown
Member

@fujikosu fujikosu commented Mar 17, 2025

Purpose

This PR switches the package management system from pip to uv. uv is a new package manager that is way faster than pip.
uv is built in Rust, enabling it to outperform pip significantly. Benchmarks indicate that uv runs way faster than pip (https://github.com/astral-sh/uv/blob/main/BENCHMARKS.md). This speed is achieved through parallel downloads, efficient caching mechanisms, and by downloading only necessary metadata instead of entire package files.
Unlike pip, uv uses a lockfile (uv.lock) alongside pyproject.toml to ensure consistent and reproducible installations across different environments. This approach minimizes dependency conflicts and enhances reliability, similar to the functionality provided by tools like Poetry.

To support this switch, the following code changes were made:

  • CI (GitHub Actions migrated to astral-sh/setup-uv and uvx; Azure DevOps pipelines updated)
  • Dockerfiles (all 3 rewritten to use uv sync --locked with bind mounts)
  • requirements.txtpyproject.toml + uv.lock in each .devcontainer
  • requirements-dev.txt removed — dev dependencies are now included in each individual pyproject.toml
  • src/common/ removed — shared dependencies are now managed per-project in pyproject.toml. The common module pattern was rarely needed in practice across multiple projects, and uv works best with all dependencies in a single pyproject.toml per environment
  • Dependabot (pip ecosystem replaced with uv)
  • README.md updated with uv instructions, new "How to update python packages" section, CI badge, and updated directory tree
  • src/sample_pytorch_gpu_project/README.md updated (requirements.txtpyproject.toml)
  • PR templates (both GitHub and Azure DevOps) updated to reference pyproject.toml
  • devcontainer.json updated: build context narrowed from repo root to each .devcontainer/ directory, remoteEnv with UV_PROJECT added
  • create-env.yaml comment clarified for build context
  • .gitignore updated (added .DS_Store)
  • .dockerignore removed (no longer needed since build context changed from repo root to each .devcontainer/ directory)
  • Deprecated/unmaintained VS Code extensions removed from all devcontainer.json files (github.copilot-chat, donjayamanne.python-environment-manager, donjayamanne.githistory, njpwerner.autodocstring, donjayamanne.vscode-default-python-kernel, marchiore.csvtomarkdown)
  • Added .github/copilot-instructions.md for repo-wide Copilot custom instructions (Google-style docstrings, uv for dependency management)

Does this introduce a breaking change?

  • Yes
  • No

Author pre-publish checklist

  • No PII in logs or output
  • Made corresponding changes to the documentation
  • All new packages used are included in pyproject.toml
  • Functions use type hints, and there are no type hint errors

Pull Request Type

What kind of change does this Pull Request introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Documentation content changes
  • Experiment notebook

@fujikosu fujikosu changed the title Feat/migrate to uv from pip Feat: migrate to uv from pip Apr 13, 2025
@fujikosu fujikosu requested review from bhavikm and Copilot April 13, 2025 08:43
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 15 out of 21 changed files in this pull request and generated no comments.

Files not reviewed (6)
  • notebooks/.devcontainer/Dockerfile: Language not supported
  • notebooks/.devcontainer/requirements.txt: Language not supported
  • requirements-dev.txt: Language not supported
  • src/sample_cpu_project/.devcontainer/Dockerfile: Language not supported
  • src/sample_pytorch_gpu_project/.devcontainer/Dockerfile: Language not supported
  • src/sample_pytorch_gpu_project/.devcontainer/requirements.txt: Language not supported
Comments suppressed due to low confidence (4)

src/sample_pytorch_gpu_project/.devcontainer/pyproject.toml:2

  • [nitpick] The 'name' field is empty; consider providing a descriptive project name for clarity in the GPU project configuration.
name = ""

src/sample_cpu_project/.devcontainer/pyproject.toml:2

  • [nitpick] The 'name' field is empty; a meaningful project name can help differentiate configurations in the CPU project settings.
name = ""

notebooks/.devcontainer/pyproject.toml:2

  • [nitpick] The project name is not specified; consider adding a descriptive name for better clarity in the notebooks environment.
name = ""

src/sample_pytorch_gpu_project/README.md:137

  • [nitpick] The placeholder version 'x.x.x' for mlflow may be unclear to users; consider using a valid version or indicating explicitly that it is a placeholder.
    mlflow==x.x.x

@fujikosu fujikosu marked this pull request as ready for review April 14, 2025 00:44
@fujikosu fujikosu requested a review from meciwo April 14, 2025 04:04
Copy link
Copy Markdown

@meciwo meciwo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed all files. It looks good to me except src/common/requirements.txt

As you mentioned

This part can be potentially improved by https://docs.astral.sh/uv/concepts/projects/workspaces/#when-not-to-use-workspaces to move away from requirements.txt and gets its own lock file

What about trying to use workspaces?

fujikosu added 5 commits July 19, 2025 06:25
- Simplified instructions in README regarding environment updates by removing redundant information about dependencies in requirements.txt.
- Adjusted the build context in create-env.yaml to use the repository root for Dockerfile compatibility, ensuring correct path resolution for dependencies.
@fujikosu
Copy link
Copy Markdown
Member Author

fujikosu commented Apr 9, 2026

Reviewed all files. It looks good to me except src/common/requirements.txt

As you mentioned

This part can be potentially improved by https://docs.astral.sh/uv/concepts/projects/workspaces/#when-not-to-use-workspaces to move away from requirements.txt and gets its own lock file

What about trying to use workspaces?

Thanks for your comment! After all, I decided to remove this common module pattern. The common module pattern was rarely needed in practice across multiple projects, and uv works best with all dependencies in a single pyproject.toml per environment

…flow dep. Get rid of venv creation for azdo linter
@fujikosu fujikosu requested a review from junkataoka April 13, 2026 12:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants