From 27b6f8eb8f08fc4d5117518f69b225adddf74b31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Sp=C3=B6ttel?= <1682504+fspoettel@users.noreply.github.com> Date: Wed, 8 Feb 2023 15:42:31 +0100 Subject: [PATCH] docs: add readme --- .env.test | 4 +-- .gitignore | 3 +- README.md | 58 ++++++++++++++++++++++++++++++++++- app/web/main.py | 6 ++-- docker/dev/docker-compose.yml | 9 +++--- 5 files changed, 69 insertions(+), 11 deletions(-) diff --git a/.env.test b/.env.test index 804db2e..f67e6ff 100644 --- a/.env.test +++ b/.env.test @@ -1,4 +1,4 @@ -DATABASE_URI="sqlite:///memory" -ENVIRONMENT="test" API_SECRET="test_secret" BROKER_URL="memory://" +DATABASE_URI="sqlite:///memory" +ENVIRONMENT="test" diff --git a/.gitignore b/.gitignore index 84f123f..f46baa8 100644 --- a/.gitignore +++ b/.gitignore @@ -161,5 +161,6 @@ cython_debug/ # VS Code .vscode - .DS_Store + +whisperbox.sqlite diff --git a/README.md b/README.md index 04cae39..dbac4e2 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,59 @@ # whisper-api -> Tiny HTTP wrapper around [openai/whisper](https://github.com/openai/whisper). +> HTTP wrapper around [openai/whisper](https://github.com/openai/whisper). + +## API documentation + +OpenAPI documentation can be accessed via `/docs`. + +## Deploy + +// TODO + +## Develop + +It is recommended to setup a virtual environment for python tooling. To install dependencies dependencies in your virtual env, run `pip install -e .[tooling,web,worker]` + +[docker-compose](https://docs.docker.com/get-started/08_using_compose/) is required for local development. Configuration such as `API_SECRET` can be adjusted in `./docker/dev/docker-compose.yml`. + +### Start + +``` +make dev +``` + +Builds and starts the docker containers. + +``` +# Bindings +http://localhost:8000 => API +http://localhost:8000/docs => API docs +http://localhost:5555 => Celery dashboard +./whisperbox.sqlite => Database +``` + +## Destroy + +This removes all containers and attached volumes. + +``` +make clean +``` + +### Test + +``` +make test +``` + +### Lint + +``` +make lint +``` + +### Format + +``` +make fmt +``` diff --git a/app/web/main.py b/app/web/main.py index 19fbd68..bd45949 100644 --- a/app/web/main.py +++ b/app/web/main.py @@ -1,5 +1,5 @@ from asyncio.log import logger -from typing import Dict, List, Optional +from typing import List, Optional from uuid import UUID from fastapi import APIRouter, Depends, FastAPI, HTTPException, Path @@ -29,8 +29,8 @@ def queue_task(job: models.Job) -> None: @api_router.get("/") -def api_root() -> Dict: - return {} +def api_root() -> None: + return None class PostJobPayload(BaseModel): diff --git a/docker/dev/docker-compose.yml b/docker/dev/docker-compose.yml index 422f523..7f38809 100644 --- a/docker/dev/docker-compose.yml +++ b/docker/dev/docker-compose.yml @@ -2,7 +2,7 @@ version: "3.8" x-app-variables: &app-variables API_SECRET: a_very_secret_token - DATABASE_URI: sqlite:////whisperbox.sqlite + DATABASE_URI: sqlite:///./whisperbox.sqlite ENVIRONMENT: development BROKER_URL: redis://redis:6379/0 WHISPER_MODEL: small @@ -15,9 +15,10 @@ services: - 6379:6379 networks: - app - resources: - limits: - memory: 128M + deploy: + resources: + limits: + memory: 128M web: container_name: whisperbox_web_dev