Skip to content

Commit 87b146d

Browse files
authored
Smokeshow coverage (#52)
1 parent aea25e3 commit 87b146d

File tree

3 files changed

+51
-8
lines changed

3 files changed

+51
-8
lines changed

.github/workflows/ci.yml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,16 @@ jobs:
123123
enable-cache: true
124124

125125
- run: uv run --frozen coverage combine coverage
126-
# - run: uv run --frozen coverage xml
127-
# - uses: codecov/codecov-action@v4
128-
# with:
129-
# token: ${{ secrets.CODECOV_TOKEN }}
130-
# file: ./coverage.xml
126+
127+
- run: uv run --frozen coverage html --show-contexts --title "PydanticAI coverage for ${{ github.sha }}"
128+
129+
- name: Store coverage html
130+
uses: actions/upload-artifact@v4
131+
with:
132+
name: coverage-html
133+
path: htmlcov
134+
include-hidden-files: true
135+
131136
- run: uv run --frozen coverage report --fail-under 95
132137

133138
# https://github.com/marketplace/actions/alls-green#why used for branch protection checks

.github/workflows/coverage.yaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Smokeshow
2+
3+
on:
4+
workflow_run:
5+
workflows: [CI]
6+
types: [completed]
7+
8+
permissions:
9+
statuses: write
10+
11+
jobs:
12+
smokeshow:
13+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- uses: actions/setup-python@v5
18+
with:
19+
python-version: '3.12'
20+
21+
- run: pip install smokeshow
22+
23+
- uses: dawidd6/action-download-artifact@v6
24+
with:
25+
workflow: ci.yml
26+
commit: ${{ github.event.workflow_run.head_sha }}
27+
28+
- run: smokeshow upload coverage-html
29+
env:
30+
SMOKESHOW_GITHUB_STATUS_DESCRIPTION: Coverage {coverage-percentage}
31+
SMOKESHOW_GITHUB_COVERAGE_THRESHOLD: 95
32+
SMOKESHOW_GITHUB_CONTEXT: coverage
33+
SMOKESHOW_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34+
SMOKESHOW_GITHUB_PR_HEAD_SHA: ${{ github.event.workflow_run.head_sha }}
35+
SMOKESHOW_AUTH_KEY: ${{ secrets.SMOKESHOW_AUTH_KEY }}

pydantic_ai/models/__init__.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from functools import cache
1414
from typing import TYPE_CHECKING, Protocol, Union
1515

16-
from httpx import AsyncClient as AsyncHTTPClient
16+
import httpx
1717

1818
from ..messages import Message, ModelAnyResponse, ModelStructuredResponse
1919

@@ -234,11 +234,14 @@ class AbstractToolDefinition(Protocol):
234234

235235

236236
@cache
237-
def cached_async_http_client() -> AsyncHTTPClient:
237+
def cached_async_http_client(timeout: int = 600, connect: int = 5) -> httpx.AsyncClient:
238238
"""Cached HTTPX async client so multiple agents and calls can share the same client.
239239
240240
There are good reasons why in production you should use a `httpx.AsyncClient` as an async context manager as
241241
described in [encode/httpx#2026](https://github.com/encode/httpx/pull/2026), but when experimenting or showing
242242
examples, it's very useful not to, this allows multiple Agents to use a single client.
243+
244+
The default timeouts match those of OpenAI,
245+
see <https://github.com/openai/openai-python/blob/v1.54.4/src/openai/_constants.py#L9>.
243246
"""
244-
return AsyncHTTPClient(timeout=30)
247+
return httpx.AsyncClient(timeout=httpx.Timeout(timeout=timeout, connect=connect))

0 commit comments

Comments
 (0)