Skip to content

Migrate to uv for backend - #1120

Open
mshriver wants to merge 4 commits into
ibutsu:mainfrom
mshriver:uv-migration
Open

mshriver wants to merge 4 commits into
ibutsu:mainfrom
mshriver:uv-migration

Conversation

@mshriver

@mshriver mshriver commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Summary by Sourcery

Migrate backend development, CI, container builds, and release workflows from Hatch and pip to uv.

Enhancements:

  • Migrate backend dependency management, development environments, and local workflows from Hatch and pip to uv with locked dependency groups.
  • Organize backend dependencies into runtime, server, worker, Flower, development, and test groups with a committed uv lockfile.
  • Update application imports and Celery initialization to defer optional components until they are needed.
  • Update release tooling to use uv for backend version management and stage generated release files.

Build:

  • Replace Hatch configuration and pinned requirements with uv project configuration and lockfile.

CI:

  • Run backend setup, linting, and tests through uv with dependency caching in GitHub Actions.

Deployment:

  • Update backend container builds to install and run services using the new uv-based dependency setup.

Documentation:

  • Replace Hatch usage guidance with uv-based backend development, testing, migration, and deployment instructions.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Sorry @mshriver, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 1 hour and 16 minutes by commenting @sourcery-ai review. Upgrade to get a review now.

@sourcery-ai

sourcery-ai Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Reviewer's Guide

The PR migrates backend dependency management and execution from Hatch/pip to uv, introducing a committed lockfile and dependency groups, updating CI, containers, documentation, and release automation, while lazily loading optional integrations and supplying a bson-free ObjectId fallback.

Sequence diagram for uv-based backend testing

sequenceDiagram
    actor Developer
    participant UV as uv
    participant Backend as Backend environment
    participant Pytest as pytest

    Developer->>UV: run pytest
    UV->>Backend: resolve dependencies from pyproject.toml and uv.lock
    Backend->>Pytest: execute test suite
    Pytest-->>Developer: test results
    Developer->>UV: run pytest with coverage options
    UV->>Pytest: execute coverage-enabled pytest
    Pytest-->>Developer: coverage reports
Loading

Sequence diagram for uv-based release versioning

sequenceDiagram
    actor Maintainer
    participant ReleaseScript as make-release.sh
    participant UV as uv
    participant Backend as backend project
    participant Git as Git

    Maintainer->>ReleaseScript: make-release.sh VERSION
    ReleaseScript->>UV: uv version --short --project backend
    UV-->>ReleaseScript: current version
    ReleaseScript->>UV: uv version VERSION --project backend
    UV->>Backend: update pyproject.toml and uv.lock
    ReleaseScript->>Backend: update OpenAPI and frontend versions
    ReleaseScript->>Git: git add versioned files
Loading

File-Level Changes

Change Details Files
Replace Hatch and pip-based backend setup with uv-managed dependency groups, lockfile, local workflows, and documentation.
  • Define runtime dependencies plus server, worker, flower, test, and development groups in pyproject.toml.
  • Add uv.lock and remove the generated pinned requirements file and Hatch environments.
  • Update CI, developer instructions, and documentation to use uv sync, uv run, and uvx.
  • Enable uv caching in GitHub Actions and update backend container builds for uv-based installation.
backend/pyproject.toml
backend/uv.lock
backend/requirements-pinned.txt
.github/workflows/tests-backend.yaml
AGENTS.md
backend/.dockerignore
backend/docker/Dockerfile.backend
backend/docker/Dockerfile.flower
backend/docker/Dockerfile.scheduler
backend/docker/Dockerfile.worker
docs/source/developer-guide/backend-testing.rst
docs/source/developer-guide/getting-started.rst
docs/source/developer-guide/hatch-usage.rst
docs/source/developer-guide/uv-usage.rst
docs/source/index.rst
docs/source/developer-guide/deployment-architecture.rst
Make optional dependencies and integrations load lazily so the base backend installation can omit server-specific, worker-specific, and MongoDB/XML packages.
  • Move connexion, Starlette CORS, and lxml imports into the code paths that require them.
  • Provide lazy module-level flower_app initialization.
  • Add a fallback ObjectId implementation when pymongo/bson is unavailable.
backend/ibutsu_server/__init__.py
backend/ibutsu_server/celery_utils.py
backend/ibutsu_server/tasks/importers.py
backend/ibutsu_server/util/uuid.py
backend/tests/test_util.py
Adapt release automation to uv version management and stage all generated version artifacts.
  • Use uv version to read and update the backend version and lockfile.
  • Continue updating OpenAPI and frontend versions, optionally generate frontend/public/version.json, and stage changed release files.
scripts/make-release.sh

Possibly linked issues

  • #Remove obsolete pymongo and dnspython dependencies: The PR removes pymongo from pyproject.toml and supports legacy ObjectId conversion without requiring bson.

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@codecov

codecov Bot commented Sep 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.44%. Comparing base (f7850c5) to head (fb68684).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1120      +/-   ##
==========================================
+ Coverage   87.42%   87.44%   +0.02%     
==========================================
  Files          63       63              
  Lines        3737     3745       +8     
  Branches      697      698       +1     
==========================================
+ Hits         3267     3275       +8     
  Misses        262      262              
  Partials      208      208              
Files with missing lines Coverage Δ
backend/ibutsu_server/__init__.py 91.32% <100.00%> (ø)
backend/ibutsu_server/celery_utils.py 100.00% <100.00%> (ø)
backend/ibutsu_server/tasks/importers.py 94.13% <100.00%> (+0.01%) ⬆️

Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f7850c5...fb68684. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mshriver

mshriver commented Sep 9, 2026

Copy link
Copy Markdown
Contributor Author
time="2026-09-09T12:18:28Z" level=info msg="buildah [stdout] STEP 7/19: RUN curl -sSfL \"https://releases.astral.sh/github/uv/releases/download/${UV_VERSION}/uv-x86_64-unknown-linux-gnu.tar.gz\"         -o /tmp/uv.tar.gz &&     tar -xzf /tmp/uv.tar.gz -C /tmp &&     install -m 0755 -t /bin         /tmp/uv-x86_64-unknown-linux-gnu/uv /tmp/uv-x86_64-unknown-linux-gnu/uvx &&     rm -rf /tmp/uv.tar.gz /tmp/uv-x86_64-unknown-linux-gnu"
time="2026-09-09T12:18:29Z" level=info msg="buildah [stderr] /bin/sh: line 1: tar: command not found"

@mshriver
mshriver force-pushed the uv-migration branch 4 times, most recently from c0ab6a6 to bcc9297 Compare September 9, 2026 15:50
mshriver and others added 3 commits September 9, 2026 11:57
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Claude <noreply@anthropic.com>
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.

1 participant