Skip to content

Commit c3ea90d

Browse files
danielmillerpclaude
andcommitted
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 <noreply@anthropic.com>
1 parent 18926e8 commit c3ea90d

2 files changed

Lines changed: 21 additions & 3 deletions

File tree

‎examples/tutorials/10_async/00_base/110_pydantic_ai/Dockerfile‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ RUN apt-get update && apt-get install -y \
2121
RUN uv pip install --system --upgrade pip setuptools wheel
2222

2323
ENV UV_HTTP_TIMEOUT=1000
24+
# Fewer parallel PyPI downloads, so the slow emulated arm64 build drops fewer connections.
25+
ENV UV_CONCURRENT_DOWNLOADS=4
2426

2527
# Copy pyproject.toml and README.md to install dependencies
2628
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
3739
# Copy shared test utilities
3840
COPY test_utils /app/test_utils
3941

40-
# Install the required Python packages with dev dependencies
41-
RUN uv pip install --system .[dev] pytest-asyncio httpx
42+
# Install the required Python packages with dev dependencies.
43+
# Retried because PyPI downloads sometimes drop mid-stream, and this uv
44+
# version doesn't retry that error itself.
45+
RUN for attempt in 1 2 3; do \
46+
uv pip install --system .[dev] pytest-asyncio httpx && exit 0; \
47+
echo "uv pip install failed (attempt $attempt of 3)"; \
48+
[ "$attempt" -lt 3 ] && sleep $((attempt * 10)); \
49+
done; \
50+
exit 1
4251

4352
# Set environment variables
4453
ENV PYTHONPATH=/app

‎examples/tutorials/10_async/10_temporal/110_pydantic_ai/Dockerfile‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ RUN apt-get update && apt-get install -y \
2121
RUN uv pip install --system --upgrade pip setuptools wheel
2222

2323
ENV UV_HTTP_TIMEOUT=1000
24+
# Fewer parallel PyPI downloads, so the slow emulated arm64 build drops fewer connections.
25+
ENV UV_CONCURRENT_DOWNLOADS=4
2426

2527
COPY 10_async/10_temporal/110_pydantic_ai/pyproject.toml /app/110_pydantic_ai/pyproject.toml
2628
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
3133
COPY 10_async/10_temporal/110_pydantic_ai/tests /app/110_pydantic_ai/tests
3234
COPY test_utils /app/test_utils
3335

34-
RUN uv pip install --system .[dev]
36+
# Retried because PyPI downloads sometimes drop mid-stream, and this uv
37+
# version doesn't retry that error itself.
38+
RUN for attempt in 1 2 3; do \
39+
uv pip install --system .[dev] && exit 0; \
40+
echo "uv pip install failed (attempt $attempt of 3)"; \
41+
[ "$attempt" -lt 3 ] && sleep $((attempt * 10)); \
42+
done; \
43+
exit 1
3544

3645
ENV PYTHONPATH=/app
3746

0 commit comments

Comments
 (0)