Skip to content

Conversation

@jonavellecuerdo
Copy link
Contributor

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#33

Includes new or updated dependencies?

YES

Changes expectations for external applications?

NO

What are the relevant tickets?

Code review

  • Code review best practices are documented here and you are encouraged to have a constructive dialogue with your reviewers about their preferences and expectations.

@jonavellecuerdo jonavellecuerdo requested review from a team, ehanson8 and ghukill January 16, 2026 15:46
@jonavellecuerdo
Copy link
Contributor Author

Question for @ehanson8 and @ghukill : Should we exclude the uv.lock file similar to how we excluded the Pipfile.lock so as to avoid pinning dependencies for the template?

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
@coveralls
Copy link

coveralls commented Jan 16, 2026

Pull Request Test Coverage Report for Build 21072504558

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 100.0%

Totals Coverage Status
Change from base Build 17270497594: 0.0%
Covered Lines: 35
Relevant Lines: 35

💛 - Coveralls

@ehanson8 ehanson8 self-assigned this Jan 16, 2026
@ehanson8
Copy link
Contributor

Question for @ehanson8 and @ghukill : Should we exclude the uv.lock file similar to how we excluded the Pipfile.lock so as to avoid pinning dependencies for the template?

We don't seem to be excluding Pipfile.lock here, was that a recent decision?

Copy link
Contributor

@ehanson8 ehanson8 left a 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


COPY Pipfile* /
RUN pipenv install
# Install package into system python, includes "marimo-launcher" script
Copy link
Contributor

Choose a reason for hiding this comment

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

This docstring probably shouldn't have the marimo-launcher reference

# Docker
####################################
docker-build: # Build local image for testing
docker build -t python-cli-template:latest .
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason this is python-cli-template rather than my-app? It would simplify the find/replace if they were the same

Copy link
Contributor

Choose a reason for hiding this comment

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

Seconded! Sort of...

While we're on this block, I might propose fully removing this # Docker section. I just recently removed it from the timdex-embeddings project.

It was helpful for a bit, whilst experimenting with uv deployments, but I don't think we need it. Until InfraEng adds the makd dist-dev style commands to a project, I think it's reasonable we could figure out how to build and test docker containers. The maintenance of this section feels like it outweighs the benefits.

# https://mitlibraries.atlassian.net/wiki/spaces/IN/pages/3432415247/Python+Project+Linters#Template-for-pyproject.toml

[project]
name = "python-cli-template"
Copy link
Contributor

Choose a reason for hiding this comment

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

Again, could this be my-app?

[project]
name = "python-cli-template"
version = "2.0.0"
requires-python = ">=3.12"
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we want ~=3.12.0 rather than >=3.12 to avoid inadvertently upgrading to 3.13, ~=3.12.0 keeps it in 3.12 but gets the newest patch version

Copy link
Contributor

Choose a reason for hiding this comment

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

Smart. Agreed.

I could find links, but it's Google-able: uv takes the position of upgrading where possible but not downgrading. It's a little surprising at first, but it seems pretty well established. For libraries within the project, I think that's okay. But python versions we do control pretty closely.

I'm not 100% sure that behavior is applied at this python version level, but I feel like I've almost encountered it myself, and would believe it.

Nice catch @ehanson8!

@ghukill
Copy link
Contributor

ghukill commented Jan 20, 2026

Question for @ehanson8 and @ghukill : Should we exclude the uv.lock file similar to how we excluded the Pipfile.lock so as to avoid pinning dependencies for the template?

I would propose that we keep the uv.lock file. My understanding has always been that version controlling the lock files is good practice. That way, without a dependency update we know the Docker CI build will be identical. A little unsure why we were formerly excluding the Pipfile.lock files.

Looking at this commit @jonavellecuerdo, I'd propose re-adding it as a commit.

Copy link
Contributor

@ghukill ghukill left a 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?

# Docker
####################################
docker-build: # Build local image for testing
docker build -t python-cli-template:latest .
Copy link
Contributor

Choose a reason for hiding this comment

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

Seconded! Sort of...

While we're on this block, I might propose fully removing this # Docker section. I just recently removed it from the timdex-embeddings project.

It was helpful for a bit, whilst experimenting with uv deployments, but I don't think we need it. Until InfraEng adds the makd dist-dev style commands to a project, I think it's reasonable we could figure out how to build and test docker containers. The maintenance of this section feels like it outweighs the benefits.

[project]
name = "python-cli-template"
version = "2.0.0"
requires-python = ">=3.12"
Copy link
Contributor

Choose a reason for hiding this comment

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

Smart. Agreed.

I could find links, but it's Google-able: uv takes the position of upgrading where possible but not downgrading. It's a little surprising at first, but it seems pretty well established. For libraries within the project, I think that's okay. But python versions we do control pretty closely.

I'm not 100% sure that behavior is applied at this python version level, but I feel like I've almost encountered it myself, and would believe it.

Nice catch @ehanson8!

## App Setup (delete this section and above after initial application setup)

1. Rename "my_app" to the desired app name across the repo. (May be helpful to do a project-wide find-and-replace).
1. Rename "my_app" and "python-cli-template" to the desired app name across the repo. (May be helpful to do a project-wide find-and-replace).
Copy link
Contributor

Choose a reason for hiding this comment

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

If taking Eric's suggestions to defaultg to my_app, then probably want to update this.

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.

5 participants