Skip to content

Optimize Dockerfile dependency installation: Replace uv pip install with uv pip sync for pylock.toml #2150

@coderabbitai

Description

@coderabbitai

Problem Description

During PR #2145 migration from requirements.txt to pylock.toml across multiple notebooks and runtimes, all Dockerfiles currently use:

uv pip install --strict --no-deps --no-cache --no-config --no-progress --verify-hashes --compile-bytecode --index-strategy=unsafe-best-match --requirements=./pylock.toml

This approach has several suboptimal characteristics when working with lock files:

  1. Drift Risk: uv pip install allows additional packages beyond those in the lock file
  2. Redundant Flags: --no-deps is unnecessary when installing from a complete lock file
  3. Inexact Environment: Does not enforce the exact locked environment state

Current State Analysis

Affected Files (34+ Dockerfiles migrated in PR #2145):

  • jupyter/minimal/ubi9-python-3.12/Dockerfile.cpu
  • jupyter/minimal/ubi9-python-3.12/Dockerfile.cuda
  • jupyter/minimal/ubi9-python-3.12/Dockerfile.rocm
  • jupyter/datascience/ubi9-python-3.12/Dockerfile.cpu
  • jupyter/pytorch+llmcompressor/ubi9-python-3.12/Dockerfile.cuda
  • jupyter/pytorch/ubi9-python-3.12/Dockerfile.cuda
  • jupyter/rocm/pytorch/ubi9-python-3.12/Dockerfile.rocm
  • jupyter/rocm/tensorflow/ubi9-python-3.12/Dockerfile.rocm
  • jupyter/tensorflow/ubi9-python-3.12/Dockerfile.cuda
  • jupyter/trustyai/ubi9-python-3.12/Dockerfile.cpu
  • codeserver/ubi9-python-3.12/Dockerfile.cpu
  • rstudio/c9s-python-3.11/Dockerfile.cpu
  • rstudio/c9s-python-3.11/Dockerfile.cuda
  • rstudio/rhel9-python-3.11/Dockerfile.cpu
  • rstudio/rhel9-python-3.11/Dockerfile.cuda
  • runtimes/datascience/ubi9-python-3.12/Dockerfile.cpu
  • runtimes/minimal/ubi9-python-3.12/Dockerfile.cpu
  • runtimes/pytorch+llmcompressor/ubi9-python-3.12/Dockerfile.cuda
  • runtimes/pytorch/ubi9-python-3.12/Dockerfile.cuda
  • runtimes/rocm-pytorch/ubi9-python-3.12/Dockerfile.rocm
  • runtimes/rocm-tensorflow/ubi9-python-3.12/Dockerfile.rocm
  • runtimes/tensorflow/ubi9-python-3.12/Dockerfile.cuda

Solution

Replace uv pip install --requirements= with uv pip sync for exact lock file enforcement:

- uv pip install --strict --no-deps --no-cache --no-config --no-progress --verify-hashes --compile-bytecode --index-strategy=unsafe-best-match --requirements=./pylock.toml
+ uv pip sync --strict --no-cache --no-config --no-progress --verify-hashes --compile-bytecode --index-strategy=unsafe-best-match ./pylock.toml

Benefits of uv pip sync:

  • Exact Environment: Installs precisely what's in the lock file, no more, no less
  • Drift Prevention: Removes any packages not specified in the lock file
  • Cleaner Syntax: No need for --no-deps or --requirements flags
  • Lock File Semantics: Designed specifically for lock file consumption

Acceptance Criteria

  • All 34+ Dockerfiles from PR RHAIENG-304: add uv pyproject.tomls for multiple notebooks and runtimes across Jupyter, RStudio, and VSCode #2145 updated to use uv pip sync instead of uv pip install --requirements=
  • Remove --no-deps and --requirements= flags (unnecessary with sync)
  • Retain all other flags (--strict, --no-cache, --no-config, --no-progress, --verify-hashes, --compile-bytecode, --index-strategy=unsafe-best-match)
  • Verify no remaining requirements.txt references in affected files
  • Test build success for representative samples (CPU, CUDA, ROCm variants)
  • Confirm exact dependency installation behavior matches expectations

Context

Implementation Notes

This optimization should be applied systematically across all Dockerfiles migrated in PR #2145. Consider creating a script to automate the replacement pattern for consistency.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

📋 Backlog

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions