Skip to content

Uv dependency management#31

Merged
fmoorhof merged 7 commits intomainfrom
uv-dependency-management
Apr 2, 2026
Merged

Uv dependency management#31
fmoorhof merged 7 commits intomainfrom
uv-dependency-management

Conversation

@fmoorhof
Copy link
Copy Markdown
Owner

@fmoorhof fmoorhof commented Apr 1, 2026

Summary by Sourcery

Adopt uv-based dependency and application management in the Docker image and refresh project metadata accordingly.

New Features:

  • Introduce uv lockfile to capture resolved Python dependencies.
  • Embed the SelectZyme logo image in the repository and surface it in the README.
  • Add a formal citation section to the README for the associated SelectZyme manuscript.

Enhancements:

  • Update the Dockerfile to use uv for dependency installation, syncing, and running application commands instead of plain pip.
  • Adjust the requirements generation comment to reference requirements.txt as the compile output.

Documentation:

  • Document the project logo in the README and provide citation details for the published manuscript.

@fmoorhof fmoorhof added this to the deployment milestone Apr 1, 2026
@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai bot commented Apr 1, 2026

Reviewer's Guide

Migrates the Docker image to use uv-based dependency management with pyproject/uv.lock, updates runtime commands accordingly, and enhances documentation with branding and citation details.

Sequence diagram for container startup with uv run gunicorn

sequenceDiagram
    actor Operator
    participant DockerEngine
    participant Container
    participant UV
    participant Gunicorn
    participant App

    Operator->>DockerEngine: docker run selectzyme-app
    DockerEngine->>Container: Start container with ENTRYPOINT
    Container->>Container: ulimit -s 11040
    Container->>UV: uv run gunicorn app:server --bind 0.0.0.0:8050 --workers 1
    UV->>Gunicorn: Execute gunicorn inside uv-managed environment
    Gunicorn->>App: Import app and get server
    App-->>Gunicorn: Return WSGI server instance
    Gunicorn-->>Operator: Listen on port 8050 for HTTP requests
Loading

Flow diagram for Docker build using uv dependency management

flowchart TD
    A[Start Docker build] --> B[apt-get update and install git]
    B --> C[COPY pyproject.toml and requirements.txt into /app]
    C --> D[pip install --upgrade pip]
    D --> E[pip install uv]
    E --> F[uv sync<br/>create environment from pyproject.toml and uv.lock]
    F --> G[uv pip install --no-cache-dir --no-deps SelectZyme from GitHub]
    G --> H[uv run python -c snapshot_download from huggingface_hub]
    H --> I[COPY full source tree into /app]
    I --> J[uv pip install .<br/>install app into uv environment]
    J --> K[Set ENTRYPOINT: uv run gunicorn app:server]
    K --> L[Expose port 8050]
    L --> M[End Docker build]
Loading

File-Level Changes

Change Details Files
Switch container dependency management and runtime to uv instead of plain pip.
  • Copy both pyproject.toml and requirements.txt into the image build context so uv can resolve dependencies.
  • Install latest pip and uv in the image, then run uv sync to create the environment based on pyproject/lockfile.
  • Install the SelectZyme Git dependency using uv pip with no-deps and no-cache options.
  • Execute the dataset download script via uv run to ensure it uses the uv-managed environment.
  • Install the local package with uv pip install instead of pip install .
  • Wrap the gunicorn entrypoint with uv run so the app runs inside the uv-managed environment.
Dockerfile
Document branding assets and add formal citation information for the application.
  • Embed the SelectZyme logo image near the top of the README for visual branding.
  • Add a Citation section describing the hosted application, associated manuscript, authors, journal details, DOI, and affiliations.
README.md
assets/selectzyme_logo.svg
Align requirements generation comments and add uv lockfile to the repo.
  • Update the auto-generation comment in requirements.txt to indicate it is the primary requirements file output by pip-compile.
  • Add uv.lock to version control so uv can reproduce the Python environment deterministically.
requirements.txt
uv.lock

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

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've found 1 issue, and left some high level feedback:

  • Consider copying uv.lock into the image and running uv sync against it so your Docker build uses the fully locked dependency set rather than only the pyproject.toml.
  • Since you no longer use requirements.txt in the Docker build (you call uv sync instead), you can drop it from the COPY pyproject.toml requirements.txt /app/ line to avoid copying unused files into the image.
  • After installing dependencies with uv pip install, calling uv run gunicorn ... in the ENTRYPOINT is likely redundant; invoking gunicorn directly would simplify the runtime path and avoid extra uv overhead.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider copying `uv.lock` into the image and running `uv sync` against it so your Docker build uses the fully locked dependency set rather than only the `pyproject.toml`.
- Since you no longer use `requirements.txt` in the Docker build (you call `uv sync` instead), you can drop it from the `COPY pyproject.toml requirements.txt /app/` line to avoid copying unused files into the image.
- After installing dependencies with `uv pip install`, calling `uv run gunicorn ...` in the `ENTRYPOINT` is likely redundant; invoking `gunicorn` directly would simplify the runtime path and avoid extra `uv` overhead.

## Individual Comments

### Comment 1
<location path="Dockerfile" line_range="14-16" />
<code_context>
-    pip install -r requirements.txt && \
-    pip install --no-dependencies git+https://github.com/ipb-halle/SelectZyme.git@f16adbc && \
-    python -c "from huggingface_hub import snapshot_download; snapshot_download(repo_id='davari-group/selectzyme-app-data', repo_type='dataset')"
+    pip install --upgrade pip && \
+    pip install uv && \
+    uv sync && \
+    uv pip install --no-cache-dir --no-deps git+https://github.com/ipb-halle/SelectZyme.git@f16adbc && \
+    uv run python -c "from huggingface_hub import snapshot_download; snapshot_download(repo_id='davari-group/selectzyme-app-data', repo_type='dataset')"
</code_context>
<issue_to_address>
**suggestion:** Consider tightening `uv sync` behavior and avoiding redundant tooling during the build.

Since `uv` fully manages the environment, upgrading `pip` beforehand is redundant and adds unnecessary build work. Once `uv.lock` is checked in and copied into the image, consider removing `pip install --upgrade pip` and using `uv sync --frozen` so the build strictly respects the lockfile and fails fast if dependencies drift.

Suggested implementation:

```
COPY pyproject.toml requirements.txt uv.lock /app/

```

```
RUN \
    pip install uv && \
    uv sync --frozen && \
    uv pip install --no-cache-dir --no-deps git+https://github.com/ipb-halle/SelectZyme.git@f16adbc && \
    uv run python -c "from huggingface_hub import snapshot_download; snapshot_download(repo_id='davari-group/selectzyme-app-data', repo_type='dataset')"

```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

fmoorhof added 3 commits April 1, 2026 13:35
chore: .png version of logo to avoid browser rendering and missing fonts issues
chore: .png version of logo to avoid browser rendering and missing fonts issues
critical: no removal of selectzyme no-deps easily possible. also selectzyme[app] profile without any dependencies very difficult
…ing during the build.

Since uv fully manages the environment, upgrading pip beforehand is redundant and adds unnecessary build work. Once uv.lock is checked in and copied into the image, consider removing pip install --upgrade pip and using uv sync --frozen so the build strictly respects the lockfile and fails fast if dependencies drift.
@fmoorhof fmoorhof merged commit 9ed5e22 into main Apr 2, 2026
4 checks passed
@fmoorhof fmoorhof deleted the uv-dependency-management branch April 2, 2026 08:07
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