Skip to content

Commit 3ea13c6

Browse files
fix: pin fasthtml streaming examples to working versions and verify in CI (#750)
python-fasthtml==0.5.1 fails to import on python:3.12-slim (ModuleNotFoundError: sqlite_minutils). Bump both response-streaming examples to 0.13.4; the image example also needs anthropic 0.40.0 because fasthtml 0.13.4 pulls httpx>=0.28 which dropped the 'proxies' kwarg that anthropic 0.34.1 passes. Add a test-stream CI job that builds and runs each app (these use Lambda Function URL RESPONSE_STREAM, which sam local start-api can't drive). Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent f9cebb9 commit 3ea13c6

3 files changed

Lines changed: 88 additions & 3 deletions

File tree

.github/workflows/examples.yaml

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,3 +303,88 @@ jobs:
303303
- name: Stop local API
304304
if: always()
305305
run: kill $SAM_PID 2>/dev/null || true
306+
307+
# Response-streaming examples verified by building and running the real app,
308+
# then curling /. These use a Lambda Function URL with RESPONSE_STREAM and have
309+
# no API Gateway events, so sam local start-api (used by test-image/test-zip)
310+
# cannot drive them. Without this job they were only lint-validated, which let
311+
# a broken python-fasthtml pin (ModuleNotFoundError: sqlite_minutils) ship.
312+
test-stream:
313+
needs: [build-layer]
314+
runs-on: ubuntu-24.04
315+
strategy:
316+
fail-fast: false
317+
matrix:
318+
example:
319+
- fasthtml-response-streaming
320+
- fasthtml-response-streaming-zip
321+
steps:
322+
- uses: actions/checkout@v4
323+
324+
- uses: actions/setup-python@v4
325+
with:
326+
python-version: "3.12"
327+
328+
- uses: actions/download-artifact@v4
329+
with:
330+
name: layer-x86_64
331+
path: /tmp/layer-x86_64
332+
333+
- name: Build local adapter image
334+
run: |
335+
chmod +x /tmp/layer-x86_64/lambda-adapter
336+
printf 'FROM scratch\nCOPY --chmod=755 lambda-adapter /lambda-adapter\n' | \
337+
docker build -t public.ecr.aws/awsguru/aws-lambda-adapter:1.0.0 -f- /tmp/layer-x86_64
338+
339+
- name: Build and start app
340+
working-directory: examples/${{ matrix.example }}
341+
run: |
342+
if [ "${{ matrix.example }}" = "fasthtml-response-streaming" ]; then
343+
# Image example: build the app image (its Dockerfile COPYs the local
344+
# adapter image built above) and run it. The app serves on 8080;
345+
# map it to host 8000 so the verify step is port-agnostic. AWS_REGION
346+
# lets AnthropicBedrock() construct without real creds; GET / only
347+
# renders a form and never calls Bedrock.
348+
docker build -t fasthtml-stream app
349+
docker run -d --name fasthtml-stream \
350+
-e AWS_REGION=us-east-1 -e AWS_DEFAULT_REGION=us-east-1 \
351+
-p 8000:8080 fasthtml-stream
352+
else
353+
# Zip example: run the app directly. run.sh only adds Lambda-layer
354+
# paths needed at runtime on Lambda, not locally.
355+
pip install -r app/requirements.txt
356+
PORT=8000 nohup python app/main.py > /tmp/app.log 2>&1 &
357+
echo "APP_PID=$!" >> $GITHUB_ENV
358+
fi
359+
360+
- name: Verify
361+
run: |
362+
echo "Waiting for app to start..."
363+
for i in $(seq 1 90); do
364+
if curl -s -o /dev/null -w "%{http_code}" http://127.0.0.1:8000/ 2>/dev/null | grep -q "^[2345]"; then
365+
echo "App is ready after ${i}s"
366+
break
367+
fi
368+
if [ "$i" -eq 90 ]; then
369+
echo "App failed to start within 90s"
370+
docker logs fasthtml-stream 2>/dev/null || cat /tmp/app.log 2>/dev/null || true
371+
exit 1
372+
fi
373+
sleep 1
374+
done
375+
376+
status=$(curl -s -o /dev/null -w "%{http_code}" http://127.0.0.1:8000/)
377+
echo "HTTP status: $status"
378+
if [[ "$status" -ge 200 && "$status" -lt 500 ]]; then
379+
echo "OK: Got valid response"
380+
else
381+
echo "FAIL: Unexpected status $status"
382+
docker logs fasthtml-stream 2>/dev/null || cat /tmp/app.log 2>/dev/null || true
383+
exit 1
384+
fi
385+
386+
- name: Stop app
387+
if: always()
388+
run: |
389+
docker rm -f fasthtml-stream 2>/dev/null || true
390+
kill $APP_PID 2>/dev/null || true
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
python-fasthtml==0.5.1
1+
python-fasthtml==0.13.4
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
python-fasthtml==0.5.1
2-
anthropic==0.34.1
1+
python-fasthtml==0.13.4
2+
anthropic==0.40.0
33
botocore==1.35.10
44
boto3==1.35.10

0 commit comments

Comments
 (0)