-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Make every example a uv workspace member #6649
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
base: main
Are you sure you want to change the base?
Changes from all commits
e8d4035
8c5a76c
fc81262
8f0c8c6
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 |
|---|---|---|
|
|
@@ -7,7 +7,8 @@ ARG PYTHON_VERSION=3.13 | |
| FROM python:${PYTHON_VERSION}-slim AS base | ||
|
|
||
| ENV PYTHONUNBUFFERED=1 | ||
| ENV PIP_DISABLE_PIP_VERSION_CHECK=1 | ||
|
|
||
| COPY --from=ghcr.io/astral-sh/uv:0.11.6 /uv /usr/local/bin/uv | ||
|
|
||
| ARG UID=10001 | ||
| RUN adduser \ | ||
|
|
@@ -26,16 +27,21 @@ RUN apt-get update && apt-get install -y \ | |
| python3-dev \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| # Enable git-lfs so pip's git installs smudge LFS-tracked binaries | ||
| # Enable git-lfs so git dependencies smudge LFS-tracked binaries | ||
| # (e.g. silero's bundled VAD onnx) instead of leaving pointer files. | ||
| # --system so the unprivileged appuser below inherits the filters. | ||
| RUN git lfs install --system | ||
|
|
||
| WORKDIR /app | ||
| USER appuser | ||
|
|
||
| COPY requirements.txt ./ | ||
| RUN pip install --user --no-cache-dir -r requirements.txt | ||
| # The example directory is the whole build context, so pyproject.toml has to | ||
| # resolve on its own here — no workspace, no lockfile. A deploy from this repo | ||
| # repoints the livekit-* dependencies at the ref being deployed first: | ||
| # python scripts/pin_example_to_ref.py examples/<name> --ref <git-ref> | ||
| COPY pyproject.toml ./ | ||
| RUN uv sync --no-cache | ||
| ENV PATH="/app/.venv/bin:${PATH}" | ||
|
Comment on lines
+42
to
+44
Contributor
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. 🟡 Avatar example image can be broken by a virtual environment left in the copied directory The avatar example builds its dependencies into a virtual environment inside the image ( Missing .dockerignore in examples/avatarEvery other example with a Dockerfile ships a Prompt for agentsWas this helpful? React with 👍 or 👎 to provide feedback. |
||
|
|
||
| # Pre-download model weights plugins ship (silero VAD, turn-detector, …) | ||
| # so the container is ready to take traffic without a cold-download stall. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| [project] | ||
| name = "livekit-example-avatar" | ||
| version = "0" | ||
| requires-python = ">=3.10" | ||
| dependencies = [ | ||
| "livekit-agents>=1.6", | ||
| "livekit-plugins-lemonslice>=1.5.7", | ||
| "livekit-plugins-silero>=1.5.7", | ||
| "livekit-plugins-turn-detector>=1.5.7", | ||
| "python-dotenv>=1.0.0", | ||
| "aiohttp>=3.9.0", | ||
| "numpy>=1.26.0", | ||
| # python:3.13-slim ships no system tzdata; without this, zoneinfo.ZoneInfo | ||
| # raises ZoneInfoNotFoundError at runtime. | ||
| "tzdata>=2024.1", | ||
| ] | ||
|
|
||
| [tool.uv] | ||
| # an example is a script collection, not an installable distribution | ||
| package = false | ||
| # No [tool.uv.sources] here: the workspace root repoints the livekit-* deps at | ||
| # the in-repo copies for members, and staying free of workspace-only references | ||
| # is what lets a copy of this directory resolve on its own, outside the repo. |
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| [project] | ||
| name = "livekit-example-drive-thru" | ||
| version = "0" | ||
| requires-python = ">=3.10" | ||
| dependencies = [ | ||
| "livekit-agents>=1.6", | ||
| "livekit-plugins-silero>=1.5.7", | ||
| "livekit-plugins-turn-detector>=1.5.7", | ||
| "python-dotenv>=1.0.0", | ||
| "pydantic>=2.0.0", | ||
| ] | ||
|
|
||
| [tool.uv] | ||
| # an example is a script collection, not an installable distribution | ||
| package = false | ||
| # No [tool.uv.sources] here: the workspace root repoints the livekit-* deps at | ||
| # the in-repo copies for members, and staying free of workspace-only references | ||
| # is what lets a copy of this directory resolve on its own, outside the repo. |
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| [project] | ||
| name = "livekit-example-frontdesk" | ||
| version = "0" | ||
| requires-python = ">=3.10" | ||
| dependencies = [ | ||
| "livekit-agents>=1.6", | ||
| "livekit-plugins-silero>=1.5.7", | ||
| "livekit-plugins-turn-detector>=1.5.7", | ||
| "python-dotenv>=1.0.0", | ||
| "aiohttp>=3.9.0", | ||
| # python:3.13-slim ships no system tzdata; without this, zoneinfo.ZoneInfo | ||
| # raises ZoneInfoNotFoundError at runtime. | ||
| "tzdata>=2024.1", | ||
| ] | ||
|
|
||
| [tool.uv] | ||
| # an example is a script collection, not an installable distribution | ||
| package = false | ||
| # No [tool.uv.sources] here: the workspace root repoints the livekit-* deps at | ||
| # the in-repo copies for members, and staying free of workspace-only references | ||
| # is what lets a copy of this directory resolve on its own, outside the repo. |
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| [project] | ||
| name = "livekit-example-healthcare" | ||
| version = "0" | ||
| requires-python = ">=3.10" | ||
| dependencies = [ | ||
| "livekit-agents>=1.6", | ||
| "livekit-plugins-openai>=1.5.7", | ||
| "livekit-plugins-silero>=1.5.7", | ||
| "openai>=1.0.0", | ||
| "python-dotenv>=1.0.0", | ||
| "pydantic>=2.0.0", | ||
| ] | ||
|
|
||
| [tool.uv] | ||
| # an example is a script collection, not an installable distribution | ||
| package = false | ||
| # No [tool.uv.sources] here: the workspace root repoints the livekit-* deps at | ||
| # the in-repo copies for members, and staying free of workspace-only references | ||
| # is what lets a copy of this directory resolve on its own, outside the repo. |
This file was deleted.
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.
🟡 Example container images may be built with a downloaded Python instead of the one the image is pinned to
The dependency install step for every example image is run without telling the tool which Python to use (
uv sync --no-cacheatexamples/avatar/Dockerfile:43), so it can fetch and use its own newest Python instead of the version the image is pinned to.Impact: Example deployments can silently run on a different Python than intended, and the image build can fail when a dependency has no prebuilt package for that newer Python.
Why the interpreter is not the image's python3.13
The base image is
python:${PYTHON_VERSION}-slimwithARG PYTHON_VERSION=3.13(examples/avatar/Dockerfile:6-7), but uv's defaultpython-preferenceismanagedwith automatic downloads enabled, which is exactly why Astral's own Docker guide setsUV_PYTHON_DOWNLOADS=0"because we want to use the system interpreter". The examplepyproject.tomlonly declaresrequires-python = ">=3.10"(examples/avatar/pyproject.toml:4) and there is no.python-version, so uv is free to install a managed interpreter (e.g. 3.14, still allowed bylivekit-agents'>=3.10,<3.15) and create/app/.venvfrom it. Consequences: (1)ARG PYTHON_VERSIONno longer controls the runtime interpreter; (2) dependencies are resolved for that interpreter, so packages such asav(alivekit-agentsdependency) orapswmay have no wheel and fall back to an sdist build, which foravneeds ffmpeg dev libraries not installed in the image. All 8 example Dockerfiles are byte-identical, so this applies to avatar, drive-thru, frontdesk, healthcare, homepage, hotel_receptionist, inference and survey.The previous
pip install --user -r requirements.txtalways used the image's interpreter.Was this helpful? React with 👍 or 👎 to provide feedback.