From e7b52f0ff7ad036f48cca03a5088a2a41087711b Mon Sep 17 00:00:00 2001 From: Daniel Miller Date: Thu, 8 Oct 2026 20:43:18 -0400 Subject: [PATCH] fix(tutorials): retry flaky PyPI fetches in pydantic_ai images Both 110_pydantic_ai image builds failed four times when a PyPI download dropped mid-stream during uv pip install, mostly in the emulated arm64 half. uv 0.6.4 doesn't retry that error. Retry the install up to three times (10s, then 20s backoff) and lower parallel downloads to 4. Co-Authored-By: Claude Opus 5.5 --- .../10_async/00_base/110_pydantic_ai/Dockerfile | 13 +++++++++++-- .../10_async/10_temporal/110_pydantic_ai/Dockerfile | 11 ++++++++++- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/examples/tutorials/10_async/00_base/110_pydantic_ai/Dockerfile b/examples/tutorials/10_async/00_base/110_pydantic_ai/Dockerfile index 906d62068..36c4ac4bb 100644 --- a/examples/tutorials/10_async/00_base/110_pydantic_ai/Dockerfile +++ b/examples/tutorials/10_async/00_base/110_pydantic_ai/Dockerfile @@ -21,6 +21,8 @@ RUN apt-get update && apt-get install -y \ RUN uv pip install --system --upgrade pip setuptools wheel ENV UV_HTTP_TIMEOUT=1000 +# Fewer parallel PyPI downloads, so the slow emulated arm64 build drops fewer connections. +ENV UV_CONCURRENT_DOWNLOADS=4 # Copy pyproject.toml and README.md to install dependencies COPY 10_async/00_base/110_pydantic_ai/pyproject.toml /app/110_pydantic_ai/pyproject.toml @@ -37,8 +39,15 @@ COPY 10_async/00_base/110_pydantic_ai/tests /app/110_pydantic_ai/tests # Copy shared test utilities COPY test_utils /app/test_utils -# Install the required Python packages with dev dependencies -RUN uv pip install --system .[dev] pytest-asyncio httpx +# Install the required Python packages with dev dependencies. +# Retried because PyPI downloads sometimes drop mid-stream, and this uv +# version doesn't retry that error itself. +RUN for attempt in 1 2 3; do \ + uv pip install --system .[dev] pytest-asyncio httpx && exit 0; \ + echo "uv pip install failed (attempt $attempt of 3)"; \ + [ "$attempt" -lt 3 ] && sleep $((attempt * 10)); \ + done; \ + exit 1 # Set environment variables ENV PYTHONPATH=/app diff --git a/examples/tutorials/10_async/10_temporal/110_pydantic_ai/Dockerfile b/examples/tutorials/10_async/10_temporal/110_pydantic_ai/Dockerfile index 17b0db8a0..e5043abab 100644 --- a/examples/tutorials/10_async/10_temporal/110_pydantic_ai/Dockerfile +++ b/examples/tutorials/10_async/10_temporal/110_pydantic_ai/Dockerfile @@ -21,6 +21,8 @@ RUN apt-get update && apt-get install -y \ RUN uv pip install --system --upgrade pip setuptools wheel ENV UV_HTTP_TIMEOUT=1000 +# Fewer parallel PyPI downloads, so the slow emulated arm64 build drops fewer connections. +ENV UV_CONCURRENT_DOWNLOADS=4 COPY 10_async/10_temporal/110_pydantic_ai/pyproject.toml /app/110_pydantic_ai/pyproject.toml COPY 10_async/10_temporal/110_pydantic_ai/README.md /app/110_pydantic_ai/README.md @@ -31,7 +33,14 @@ COPY 10_async/10_temporal/110_pydantic_ai/project /app/110_pydantic_ai/project COPY 10_async/10_temporal/110_pydantic_ai/tests /app/110_pydantic_ai/tests COPY test_utils /app/test_utils -RUN uv pip install --system .[dev] +# Retried because PyPI downloads sometimes drop mid-stream, and this uv +# version doesn't retry that error itself. +RUN for attempt in 1 2 3; do \ + uv pip install --system .[dev] && exit 0; \ + echo "uv pip install failed (attempt $attempt of 3)"; \ + [ "$attempt" -lt 3 ] && sleep $((attempt * 10)); \ + done; \ + exit 1 ENV PYTHONPATH=/app