Skip to content

Commit

Permalink
feat: add test for the fastapi example to the notebook runner
Browse files Browse the repository at this point in the history
  • Loading branch information
NiklasKoehneckeAA committed Apr 25, 2024
1 parent 2c46184 commit 210138e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
14 changes: 14 additions & 0 deletions scripts/fastapi_example_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env -S bash -eu -o pipefail

# start the server in the background
hypercorn src/examples/fastapi_example:app --bind localhost:8000 &
my_pid=$!

trap 'kill $my_pid' EXIT SIGINT
# waiting for server startup
sleep 3
curl -X GET http://localhost:8000 --fail-with-body
curl -X POST http://localhost:8000/summary --fail-with-body -H "Content-Type: application/json" -d '{"chunk": "<your text to summarize here>", "language": {"iso_639_1": "en"}}'

# kill happens at the end with the trap command
exit 0
2 changes: 2 additions & 0 deletions scripts/notebook_runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ rm -rf src/examples/how_tos/.ipynb_checkpoints
find src/examples -name "*.nbconvert.ipynb" -type f -delete
find src/examples -name "*.ipynb" ! -name "performance_tips.ipynb" | xargs --max-args 1 --max-procs 6 poetry run jupyter nbconvert --to notebook --execute
find src/examples -name "*.nbconvert.ipynb" -type f -delete

./scripts/fastapi_example_test.sh

0 comments on commit 210138e

Please sign in to comment.