Skip to content

feat: Migrate package manager to uv#1553

Open
FallenDeity wants to merge 7 commits into
PokeAPI:masterfrom
FallenDeity:feat/migrate-to-uv
Open

feat: Migrate package manager to uv#1553
FallenDeity wants to merge 7 commits into
PokeAPI:masterfrom
FallenDeity:feat/migrate-to-uv

Conversation

@FallenDeity

@FallenDeity FallenDeity commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Change description

First set of pr for migrating and adopting modern python tooling ecosystem, this pr attempts to migrate from pip to uv for package management as discussed in #1391 & #1521 it breaks down the changes @phalt initially made to smaller more iterative parts

cc: @phalt @Naramsim

AI coding assistance disclosure

Used a bit for reviewing the changes and coverage if I missed any transitive command update

Contributor check list

  • I have written a description of the contribution and explained its motivation.
  • I have written tests for my code changes (if applicable).
  • I have read and understood the AI Assisted Contribution guidelines.
  • I will own this change in production, and I am prepared to fix any bugs caused by my code change.

@FallenDeity FallenDeity marked this pull request as ready for review June 10, 2026 19:19
Comment thread .circleci/config.yml
Comment thread .python-version
Comment thread docker-compose.yml
environment:
HASURA_GRAPHQL_DATABASE_URL: postgres://${POSTGRES_USER:-ash}:${POSTGRES_PASSWORD:-pokemon}@db:5432/${POSTGRES_DB:-pokeapi}
HASURA_GRAPHQL_ENABLE_CONSOLE: "true"
HASURA_GRAPHQL_ENABLE_CONSOLE: "false"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why false?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I moved all the dev settings to the -dev compose file and left this as barebones base compose file, the graphql console is not really a recommended setting to be enabled to be in prod/ is a local/dev based setting so figured overriding it in the dev compose file is a more suitable location for it

is there any particular reason for us to have it globally set to true I am not that familiar with graphql but shouldnt the console be enabled in a much more limited manner or does it not matter in our case?

Comment thread .github/workflows/database.yml Outdated
Comment thread Resources/docker/app/Dockerfile Outdated
Comment thread .python-version
Comment thread Makefile
@FallenDeity FallenDeity requested review from Naramsim and jemarq04 June 17, 2026 15:58
@Naramsim

Copy link
Copy Markdown
Member

I want to review this PR, don't merge please. I'm slow I know, bear with me

Comment thread Makefile Outdated
Comment thread pyproject.toml Outdated
with:
submodules: recursive
- name: Build
- name: Build and start services

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is not building anymore, just starting the services.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

docker compose up does build the image too if it dosent exist (which it dosent when this task first runs) but ill also add a --build flag to be explicit

docker compose exec -T db psql -U ash -d postgres -c "DROP DATABASE pokeapi WITH (FORCE);"
docker compose exec -T db psql -U ash -d postgres -c "CREATE DATABASE pokeapi;"
- name: Import database
run: docker compose exec -T db pg_restore -U ash -d pokeapi < pokeapi.dump

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we put back -h localhost? I like the commands to be descriptive, so that anyone can see the pipeline and use it as a piece of documentation.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

the default behavior for dump and restore for postgresql isnt localhost or the local loopback address instead it uses the unix socket (file based) which is faster without the tcp/ip overhead I can force it to use localhost if required though but imo there is no particular reason to go through localhost

previously the docker invocation was using -u postgres (os system user) and the the command was using -u ash which likely touched upon this auth permission rule with unix socket file perms vs tcp/ip bypass https://www.postgresql.org/docs/current/auth-trust.html due to differing users in the command and db role access

Local TCP/IP connections are not restricted by file-system permissions

docker compose exec -T -u postgres db sh -c "cd /tmp && pg_restore -h localhost -U ash -d pokeapi pokeapi.dump"

in the new workflow the commands run as the container default execution user so we dont run into any permission misalignments for file r/w

Comment thread .github/workflows/database.yml Outdated
Comment thread .github/workflows/docker-k8s.yml Outdated
RUN apk add --no-cache --virtual .build-deps gcc g++ musl-dev \
postgresql-dev binutils rust cargo && \
python3 -m pip install -r requirements.txt --no-cache-dir
RUN --mount=type=cache,target=/root/.cache/uv \

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

same here, let's remove the cache mount and add it later in a separate PR.

@FallenDeity FallenDeity Jun 30, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

lets leave this cache here? since its a uv or a requirements dependency cache ensuring uv dosent have to reach out to pypi and redownload all packages if there is a change in pyproject or uv lock its recommended in their docs too https://docs.astral.sh/uv/guides/integration/docker/#caching

Ill remove the ci/cd or workflow layer image caching mentioned above though for a future pr

Comment thread docker-compose.yml Outdated
Comment thread pyproject.toml Outdated
@FallenDeity

FallenDeity commented Jun 30, 2026

Copy link
Copy Markdown
Contributor Author

was on vacation last week 🏖️ so changes/followup were bit delayed

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.

4 participants