Example Project
Describe the project.
If you want to see...
- ⚡ Fast: X.
- 🐳 Easy to deploy: X.
- 🔥 Batch requests: X.
- 💸 Cost-effective: X.
- 🫶 Easy-to-use API: X.
- 🤗 MIT License: X.
- Linux (tested on Ubuntu Server 20.04/22.04)
- Python >=3.10, <3.12
X
- Docker (optional for deployment)
- NVIDIA GPU + NVIDIA Container Toolkit (optional for deployment)
Build the image.
docker build -t my-project:latest .
Run the container.
docker run -d --name wordcab-transcribe \
--gpus all \
--shm-size 1g \
--restart unless-stopped \
-p 5001:5001 \
-v ~/.cache:/root/.cache \
my-project:latest
You can run the API behind a reverse proxy like Nginx. We have included a nginx.conf
file to help you get started.
# Create a docker network and connect the api container to it
docker network create example-network
docker network connect example-network my-project
# Replace /absolute/path/to/nginx.conf with the absolute path to the nginx.conf
# file on your machine (e.g. /home/user/wordcab-transcribe/nginx.conf).
docker run -d \
--name nginx \
--network transcribe \
-p 80:80 \
-v /absolute/path/to/nginx.conf:/etc/nginx/nginx.conf:ro \
nginx
# Check everything is working as expected
docker logs nginx
⏱️ Profile the API
You can profile the process executions using py-spy
as a profiler.
# Launch the container with the cap-add=SYS_PTRACE option
docker run -d --name my-project \
--gpus all \
--shm-size 1g \
--restart unless-stopped \
--cap-add=SYS_PTRACE \
-p 5001:5001 \
-v ~/.cache:/root/.cache \
my-project:latest
# Enter the container
docker exec -it my-project /bin/bash
# Install py-spy
pip install py-spy
# Find the PID of the process to profile
top # 28 for example
# Run the profiler
py-spy record --pid 28 --format speedscope -o profile.speedscope.json
# Launch any task on the API to generate some profiling data
# Exit the container and copy the generated file to your local machine
exit
docker cp my-project:/app/profile.speedscope.json profile.speedscope.json
# Go to https://www.speedscope.app/ and upload the file to visualize the profile
X.
- Before you start:
- Clone the repo
git clone
cd my-project
- Install dependencies and start coding
pip install -r requirements.txt
- Run tests
- Create an issue for the feature or bug you want to work on.
- Create a branch using the left panel on GitHub.
git fetch
andgit checkout
the branch.- Make changes and commit.
- Push the branch to GitHub.
- Create a pull request and ask for review.
- Merge the pull request when it's approved and CI passes.
- Delete the branch.
- Update your local repo with
git fetch
andgit pull
.