Skip to content

Conversation

@zachflanders-frb
Copy link
Contributor

@zachflanders-frb zachflanders-frb commented Jun 13, 2025

Description:
This is a draft PR for discussion around adding uv as a dependency manager.
This PR updated the project to use uv as the python project/package manager.

  • The Dockerfile is updated to install uv and to sync the project dependencies.
  • The dependencies are now defined in pyproject.toml (including extra dependency groups for dev, server, ansible, etc.)
  • The makefile is updated to use uv run for tests and to allow uv to manage the environment.
  • The uv.lock file is added to the repo to ensure reproducibility of the environment.
  • The readme is updated to reflect changes including instructions for running tests locally.

Jira: DEV-12320

Copy link
Contributor Author

@zachflanders-frb zachflanders-frb left a comment

Choose a reason for hiding this comment

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

We will need to update the README.md, especially regarding running tests not in a container. I think we should include instructions for settings up a venv with the python version using uv to run tests locally, e.g. uv venv --python 3.10.12 usaspending-api. I have not tested this yet.

I updated the readme to include install python with uv and running tests locally.

@printf "\n==== Environment Variables ====\n\n"
@printenv

.python-version: ## Attempt to setup python using pyenv
Copy link
Contributor Author

@zachflanders-frb zachflanders-frb Jun 13, 2025

Choose a reason for hiding this comment

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

Let the docker container handle setting the python version. Added a note about installing the python version with uv if running locally to the readme.

fi; \
fi;

.venv: ## Ensure a virtual environment is established at .venv
Copy link
Contributor Author

@zachflanders-frb zachflanders-frb Jun 13, 2025

Choose a reason for hiding this comment

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

No need for a venv since we are already in a container or if running locally uv will handle the environment.

image: usaspending-testing # when an image by this name is not found in the local repo, and it is forced to build, it will use this as the tag
build:
context: .
dockerfile: Dockerfile.testing
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The Dockerfile filename should be .Dockerfile by convention:

Some projects may need distinct Dockerfiles for specific purposes. A common convention is to name these <something>.Dockerfile.

https://docs.docker.com/build/concepts/dockerfile/#filename

This will enable IDEs and github to highlight the syntax.

dependencies = [
"asyncpg==0.29.*",
"attrs==23.2.*",
"boto3>=1.34,<1.36",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

boto3 was set to 1.34.* I loosened this a bit because it was conflicting with the ansible and/or awscli requirements. In the Dockerfile these are pip installed as a subsequent step, so it was likely installing a different version of boto3 into the image during that step.

@zachflanders-frb zachflanders-frb self-assigned this Jun 13, 2025
@zachflanders-frb zachflanders-frb marked this pull request as ready for review July 7, 2025 19:07
Copy link
Contributor

@sethstoudenmier sethstoudenmier left a comment

Choose a reason for hiding this comment

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

Small change for the duplicate reference to Django, but mostly questions for OPS around if some of the files are referenced directly


FROM python:3.10.12-slim-bullseye

COPY --from=ghcr.io/astral-sh/uv:0.7.19 /uv /uvx /bin/
Copy link
Contributor

Choose a reason for hiding this comment

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

Need to follow up with OPS to make sure that pulling from GitHub container registry is alright with some of the planned changes.

local-dev-setup: uv-sync check-dependencies .ivy2 ## Setup virtual environment and pip dependencies, then check version info

.PHONY: check-dependencies
check-dependencies: ## Prints out the versions of dependencies in use
Copy link
Contributor

Choose a reason for hiding this comment

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

If I am following correctly, uv will be managing the virtual environment and remove the need for us doing it ourself?

Copy link
Contributor

Choose a reason for hiding this comment

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

Need to work with OPS to see where this file is used

Copy link
Contributor

Choose a reason for hiding this comment

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

The fact that it calls out the requirements-server.txt makes me wonder if it was used directly

Copy link
Contributor

Choose a reason for hiding this comment

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

Similar to the caching requirements above, we need to double check if this is used directly anywhere

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