-
Notifications
You must be signed in to change notification settings - Fork 5
feat: migrate to uv with lockfile for supply chain security #270
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
6fec13f
5cd67d7
63b28bb
e649cfd
f9894a5
158de0e
3e01d30
d84cb2b
bc5c63f
11c2cab
ba86d5e
32389b4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,26 +9,14 @@ on: | |
| jobs: | ||
| test: | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| matrix: | ||
| python-version: ["3.12"] | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | ||
|
|
||
| - name: Set up Python ${{ matrix.python-version }} | ||
| uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 | ||
| with: | ||
| python-version: ${{ matrix.python-version }} | ||
|
|
||
| - name: Install dependencies | ||
| run: | | ||
| python -m pip install pip==26.0.1 | ||
| pip install -e ".[test]" | ||
| - name: Install uv | ||
| uses: astral-sh/setup-uv@e58605a9b6da7c637471fab8847a5e5a6b8df081 # v5 | ||
|
|
||
| - name: Run tests | ||
| run: | | ||
| pytest -xv -m "not slow and not performance" --cov=src --cov-report=xml --cov-report=html | ||
| run: uv run --frozen --extra test pytest -xv -m "not slow and not performance" --cov=src --cov-report=xml --cov-report=html | ||
|
Comment on lines
+15
to
+19
|
||
|
|
||
| - name: Upload coverage to Codecov | ||
| uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2 # v6.0.0 | ||
|
|
@@ -43,13 +31,8 @@ jobs: | |
| steps: | ||
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | ||
|
|
||
| - name: Set up Python | ||
| uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 | ||
| with: | ||
| python-version: "3.12" | ||
| - name: Install uv | ||
| uses: astral-sh/setup-uv@e58605a9b6da7c637471fab8847a5e5a6b8df081 # v5 | ||
|
|
||
| - name: Audit dependencies for known vulnerabilities | ||
| run: | | ||
| python -m pip install pip==26.0.1 | ||
| pip install -e ".[dev,test,performance]" | ||
| pip-audit | ||
| run: uv run --frozen --extra dev --extra test --extra performance pip-audit | ||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -62,3 +62,10 @@ repos: | |||||||||
| types: [python] | ||||||||||
| pass_filenames: true | ||||||||||
| exclude: ^(src/inference_endpoint/openai/openai_types_gen.py)$ | ||||||||||
|
|
||||||||||
| - id: uv-lock-check | ||||||||||
| name: Check uv.lock is up-to-date | ||||||||||
| entry: uv lock --check | ||||||||||
| language: system | ||||||||||
|
||||||||||
| language: system | |
| language: python | |
| additional_dependencies: | |
| - uv |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 3.12 |
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,6 +1,20 @@ | ||||||||||
| [build-system] | ||||||||||
| requires = ["setuptools==78.1.1", "wheel==0.46.3"] | ||||||||||
| build-backend = "setuptools.build_meta" | ||||||||||
| requires = ["uv_build>=0.7.6,<0.8"] | ||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The build system requirement should be
Suggested change
|
||||||||||
| build-backend = "uv_build" | ||||||||||
|
|
||||||||||
| [tool.uv] | ||||||||||
| index-url = "https://pypi.org/simple" | ||||||||||
| environments = [ | ||||||||||
| "sys_platform == 'linux' and platform_machine == 'x86_64'", | ||||||||||
| "sys_platform == 'linux' and platform_machine == 'aarch64'", | ||||||||||
| "sys_platform == 'darwin' and platform_machine == 'x86_64'", | ||||||||||
| "sys_platform == 'darwin' and platform_machine == 'arm64'", | ||||||||||
| ] | ||||||||||
|
|
||||||||||
| [tool.uv.build] | ||||||||||
| module-root = "src" | ||||||||||
| data = {"inference_endpoint" = ["config/templates/*.yaml"]} | ||||||||||
| exclude = ["evaluation/livecodebench/_server.py"] | ||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The exclude path should be relative to the project root to ensure the file is correctly identified and excluded from the build. Since
Suggested change
|
||||||||||
| exclude = ["evaluation/livecodebench/_server.py"] | |
| exclude = ["inference_endpoint/evaluation/livecodebench/_server.py"] |
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -5,20 +5,25 @@ | |||||||||
|
|
||||||||||
| FROM python:3.12.11-slim | ||||||||||
|
|
||||||||||
| # Copy uv binary from official image | ||||||||||
| COPY --from=ghcr.io/astral-sh/uv:0.7.6 /uv /uvx /bin/ | ||||||||||
|
Comment on lines
+8
to
+9
|
||||||||||
| # Copy uv binary from official image | |
| COPY --from=ghcr.io/astral-sh/uv:0.7.6 /uv /uvx /bin/ | |
| # Copy uv binary from an immutable official image reference | |
| COPY --from=ghcr.io/astral-sh/uv:0.7.6@sha256:<verified-digest-for-0.7.6> /uv /uvx /bin/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To optimize Docker layer caching, it is recommended to install dependencies before copying the full source code. This prevents the uv sync step from re-running every time a source file is modified. You can use uv sync --no-install-project to install only the dependencies first.
COPY pyproject.toml uv.lock .python-version ./
RUN uv sync --frozen --no-install-project --extra dev --extra test
COPY src/ ./src/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When running the container with a volume mount (as suggested in the file header: -v $(pwd):/mnt/inference-endpoint), the .venv directory created here will be obscured by the host directory. This will result in the installed dependencies being unavailable in the running container. To resolve this, consider setting UV_PROJECT_ENVIRONMENT to a location outside the project root (e.g., /opt/venv) and adding that location to the PATH.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This workflow now relies on whatever Python happens to be on the runner. To avoid non-reproducible pre-commit results, explicitly set up the intended Python version (3.12) or configure the uv setup step accordingly.