-
Notifications
You must be signed in to change notification settings - Fork 1
Migrate Python CLI template to uv #21
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
base: main
Are you sure you want to change the base?
Conversation
Why these changes are being introduced: This is the first pass in migrating to uv from pipenv. How this addresses that need: * Removes Pipfile and Pipfile.lock * Updates pyproject.toml to be a valid uv project * All dependencies handled via 'uv add' and exist in pyproject.toml * Makefile and pre-commits updated to use uv syntax * Github actions *temporarily* hardcoded in local workflows, with a TODO to move these to a shared workflow when things settle down * Bumps python to 3.13 Side effects of this change: * Many! Hard pivot from Pipenv installation and running of the application. At this time, the largest side effect is the loss of 'pipenv run <appname>'. A future commit will apply a new strategy, but that is not present now. A workaround is 'uv run my_app/cli.py`. Relevant ticket(s): * https://mitlibraries.atlassian.net/browse/IN-1425
Why these changes are being introduced: As we continue to slowly build out this uv driven version of the CLI template, finding little things to update along the way. How this addresses that need: * Updated Dockerfile to use uv in image build * Add convenience docker methods in Makefile, unassociated with AWS ECR (helpful for local testing) * Update dependencies Side effects of this change: * None Relevant ticket(s): * None
95fceb3 to
8331067
Compare
Pull Request Test Coverage Report for Build 21186643805Details
💛 - Coveralls |
ehanson8
left a comment
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.
Looking good but a few questions and comments
I would propose that we keep the Looking at this commit @jonavellecuerdo, I'd propose re-adding it as a commit. |
ghukill
left a comment
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.
Overall, looking great. Did request a couple of small changes, mostly things pointed out by @ehanson8.
I'd also like to propose an update to the README about running the CLI.
Under the section ## Development I'd propose updating this:
- To run the app: `uv run my-app --help` (Note the hyphen `-` vs underscore `_` that matches the `project.scripts` in `pyproject.toml`)
To the following, which shows two options:
- To run the app:
- `my-app`
- utilizes `uv` built entrypoint (see `project.scripts` in `pyproject.toml`)
- does not support loading a `.env` file
- `uv run --env-file .env my-app`
- more verbose, but supports loading with a `.env` file
Thoughts?
|
Thank you both for your reviews, and especially @ehanson8 for catching references to |
ghukill
left a comment
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.
Left a comment about the Makefile and how to run the app. Most of the details in that comment itself.
| ############################## | ||
| # CLI convenience commands | ||
| ############################## | ||
| my-app: # CLI without any arguments, utilizing uv script entrypoint | ||
| uv run my-app |
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.
This is going to be complicated to discuss I fear in comments, but will try. Happy to realtime chat on this if helpful.
If this is related to the README update for how to run the app, my proposal was just my-app. This would work because my-app is built by uv as an entrypoint script here in the pyproject.toml. It would work without this Makefie command.
If possible, I'm feeling like we might benefit from leaning into those uv entrypoint scripts where possible. You can see an example of that in the timdex-embeddings CLI here where the Dockerfile is calling that uv entrypoint script directly. Nothing else.
| - To lint the repo: `make lint` | ||
| - To run the app: `pipenv run my_app --help` | ||
| - To run the app: | ||
| - `make my-app` |
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.
See another comment in the Makefile, where this could be just my-app.
Purpose and background context
Migrate Python CLI template to uv
How can a reviewer manually see the effects of these changes?
The
uv-based GitHub CI workflow has been tested in MITLibraries/timdex-embeddings#33Includes new or updated dependencies?
YES
Changes expectations for external applications?
NO
What are the relevant tickets?
Code review