Support modern uv project management (uv init + uv add)#3474
Draft
igorts-git wants to merge 1 commit intomainfrom
Draft
Support modern uv project management (uv init + uv add)#3474igorts-git wants to merge 1 commit intomainfrom
igorts-git wants to merge 1 commit intomainfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
d04ab05 to
902af4e
Compare
- Update MaxText installation scripts to detect 'uv.lock' and use 'uv add --frozen'. - Consolidate uv detection and installation logic into a shared 'uv_utils.py' module. - Improve uv detection robustness by prioritizing 'python -m uv' and path lookup. - Update docs/install_maxtext.md with modern uv workflow instructions and fix outdated paths. - Fix macOS installation by dynamically skipping legacy MaxText directory.
902af4e to
9a2b91a
Compare
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.
Description
Objective
Enable users to use MaxText seamlessly within their own
uv-managed projects. Previously, MaxText's installation scripts relied exclusively onuv pip install, which does not update a project'spyproject.tomloruv.lock. This PR introduces automatic detection ofuvprojects and usesuv addto correctly track "extra" dependencies (like GitHub-based requirements) when applicable.Background
There is a "modern" uv usage mode that is different from the traditional uv pip install flow.
The new mode requires
uv initanduv addcommands instead ofuv pip install.This PR makes it compatible with the new flow.
Key changes:
uv-managed project detection: Added logic toinstall_pre_train_deps.py,install_post_train_deps.py, andsetup.shto check for the presence of auv.lockfile in the current working directory.uv addIntegration:uvproject is detected, the scripts now useuv add --frozen -r <requirements>to add extra dependencies to the user'spyproject.toml.--frozenflag is used to ensure that only the requested dependencies are added/updated without triggering a full environment resolution/sync, which is critical given MaxText's complex optional dependency tree.uv pip installworkflow as a fallback for standard virtual environments, Docker builds, and MaxText development.docs/install_maxtext.mdwith instructions for the modernuvworkflow and corrected several outdated paths and command names.maxtext_venvto.gitignore. This was needed to be able to runpython3 -m buildto build a wheel for testing below.Pair-programmed with Gemini-CLI.
FIXES: #3441
Tests
1. Build a new Wheel
To verify that the package metadata and entry points are correctly defined:
2. Verify Legacy Installation (
uv pip install)Ensures no regressions for existing users installing the package artifact:
3. Verify Modern Installation (
uv add)Tests the new project management workflow using the package artifact:
Checklist
Before submitting this PR, please make sure (put X in square brackets):
gemini-reviewlabel.