Repository navigation
149 lines (143 loc) · 5.9 KB
/
Copy pathpython-examples.yml
File metadata and controls
149 lines (143 loc) · 5.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
name: Python application examples
on:
push:
paths:
- '.github/workflows/python-examples.yml'
- 'examples/python-fastapi/**'
- 'examples/python-agent/**'
- 'crates/cellar-python/**'
- 'crates/cellar/**'
- 'tools/python/**'
- 'Cargo.toml'
- 'Cargo.lock'
pull_request:
paths:
- '.github/workflows/python-examples.yml'
- 'examples/python-fastapi/**'
- 'examples/python-agent/**'
- 'crates/cellar-python/**'
- 'crates/cellar/**'
- 'tools/python/**'
- 'Cargo.toml'
- 'Cargo.lock'
workflow_dispatch:
permissions:
contents: read
concurrency:
group: cellar-python-examples-${{ github.ref }}
cancel-in-progress: true
env:
RUST_VERSION: 1.98.1
CARGO_INCREMENTAL: '0'
CARGO_BUILD_JOBS: '2'
CARGO_PROFILE_DEV_DEBUG: '0'
CARGO_PROFILE_TEST_DEBUG: '0'
jobs:
fastapi:
name: FastAPI deployment (${{ matrix.runtime }})
runs-on: ubuntu-22.04
timeout-minutes: 40
strategy:
fail-fast: false
matrix:
include:
- runtime: '3.14.5'
smoke_flags: ''
- runtime: '3.14.5t'
smoke_flags: '--expect-free-threaded'
env:
CARGO_TARGET_DIR: ${{ github.workspace }}/target
PYTHONDONTWRITEBYTECODE: '1'
steps:
- uses: actions/checkout@v6
with:
persist-credentials: false
- uses: actions/setup-python@v6
with:
python-version: '3.14'
- name: Install build tools
run: |
rustup toolchain install "$RUST_VERSION" --profile minimal
rustup default "$RUST_VERSION"
python -m pip install uv==0.11.19
- name: Package the application and its Python dependencies
run: |
mkdir -p "$RUNNER_TEMP/fastapi"
python examples/python-fastapi/package.py --runtime '${{ matrix.runtime }}' \
--prefix "$RUNNER_TEMP/fastapi/environment" --output "$RUNNER_TEMP/fastapi/package"
- name: Test buffered ASGI boundaries
run: |
export PYO3_PYTHON="$(UV_PYTHON_INSTALL_DIR="$RUNNER_TEMP/fastapi/environment/runtime" uv python find --managed-python '${{ matrix.runtime }}')"
PYTHONPATH="$RUNNER_TEMP/fastapi/environment/site" \
"$PYO3_PYTHON" -B examples/python-fastapi/test_app.py
- name: Restore and exercise the deployed application
run: |
cargo run -p cellar --example python-fastapi-deployment --locked -- \
"$RUNNER_TEMP/fastapi/package" "$RUNNER_TEMP/fastapi" "$(command -v python)" ${{ matrix.smoke_flags }}
- name: Check performance harness correctness
run: |
python -B examples/python-fastapi/perf.py --cellar "$CARGO_TARGET_DIR/debug/cellar" \
--project "$RUNNER_TEMP/fastapi/environment/project.json" \
--output "$RUNNER_TEMP/fastapi/perf-smoke" \
--concurrency 1 8 --repetitions 1 --read-seconds .5 --writes 32
- name: Check independent-arrival reads and failure accounting
run: |
cargo build -p cellar-python --example python-offered-load --no-default-features --locked
python -B tools/python/test_offered.py "$CARGO_TARGET_DIR/debug/examples/python-offered-load"
python -B examples/python-fastapi/offered_perf.py \
--client "$CARGO_TARGET_DIR/debug/examples/python-offered-load" --client-profile dev \
--cellar "$CARGO_TARGET_DIR/debug/cellar" \
--project "python=$RUNNER_TEMP/fastapi/environment/project.json" \
--output "$RUNNER_TEMP/fastapi/offered-smoke" \
--rates 100 --duration-ms 500 --warmup-ms 100 --repetitions 1
python - "$RUNNER_TEMP/fastapi/offered-smoke/results.json" <<'PY'
import json, sys
with open(sys.argv[1]) as stream:
report = json.load(stream)
for case in report["cases"]:
for phase in case["phases"]:
for name in ("warmup", "measurement"):
outcomes = phase[name]["outcomes"]
if not outcomes.get("success") or set(outcomes) - {"success", "client_late", "client_capacity"}:
raise RuntimeError(f"FastAPI read smoke failed: {outcomes}")
PY
agent:
name: Durable PydanticAI agent (${{ matrix.runtime }})
runs-on: ubuntu-22.04
timeout-minutes: 40
strategy:
fail-fast: false
matrix:
include:
- runtime: '3.14.5'
smoke_flags: ''
- runtime: '3.14.5t'
smoke_flags: '--expect-free-threaded'
env:
CARGO_TARGET_DIR: ${{ github.workspace }}/target
PYTHONDONTWRITEBYTECODE: '1'
PYDANTIC_AI_NO_BANNER: '1'
steps:
- uses: actions/checkout@v6
with:
persist-credentials: false
- uses: actions/setup-python@v6
with:
python-version: '3.14'
- name: Install build tools
run: |
rustup toolchain install "$RUST_VERSION" --profile minimal
rustup default "$RUST_VERSION"
python -m pip install uv==0.11.19
- name: Package the agent with its pinned runtime and dependencies
run: |
mkdir -p "$RUNNER_TEMP/agent"
python examples/python-agent/package.py --runtime '${{ matrix.runtime }}' \
--prefix "$RUNNER_TEMP/agent/environment" --output "$RUNNER_TEMP/agent/package"
- name: Test durable agent boundaries and real host restart
run: |
export PYO3_PYTHON="$(UV_PYTHON_INSTALL_DIR="$RUNNER_TEMP/agent/environment/runtime" uv python find --managed-python '${{ matrix.runtime }}')"
export CELLAR_PYTHON_SITE_PACKAGES="$RUNNER_TEMP/agent/environment/site"
PYTHONPATH="$CELLAR_PYTHON_SITE_PACKAGES" "$PYO3_PYTHON" -B examples/python-agent/test_app.py
python -B examples/python-agent/smoke.py --cellar "$CARGO_TARGET_DIR/debug/cellar" \
--project "$RUNNER_TEMP/agent/environment/project.json" ${{ matrix.smoke_flags }}