项目作者: kmjawadurrahman

项目描述 :
Text summarization service with Python, FastAPI, and Docker.
高级语言: Python
项目地址: git://github.com/kmjawadurrahman/fastapi-tdd-docker.git
创建时间: 2020-08-31T16:19:45Z
项目社区:https://github.com/kmjawadurrahman/fastapi-tdd-docker

开源协议:

下载


Test-Driven Development with FastAPI and Docker

Learn how to build, test, and deploy a text summarization microservice with Python, FastAPI and Docker.

Continuous Integration and Delivery

Table of contents

About

fastapi-tdd-docker is a code-along to the course Test-Driven Development with FastAPI and Docker by Michael Herman.

Link to original repo.

Tools and technologies

  • Python
  • FastAPI
  • Docker & Docker Compose
  • Postgres
  • Tortoise ORM
  • Pytest
  • Uvicorn
  • Coverage.py
  • flake8
  • Black
  • isort
  • HTTPie
  • GitHub Actions
  • GitHub Packages
  • Gunicorn
  • Heroku
  • Swagger/OpenAPI

Project structure

  1. ├── .github
  2. └── workflows
  3. └── main.yml
  4. ├── .gitignore
  5. ├── README.md
  6. ├── docker-compose.yml
  7. ├── project
  8. ├── .coverage
  9. ├── .coveragerc
  10. ├── .dockerignore
  11. ├── Dockerfile
  12. ├── Dockerfile.prod
  13. ├── app
  14. ├── __init__.py
  15. ├── api
  16. ├── __init__.py
  17. ├── crud.py
  18. ├── ping.py
  19. └── summaries.py
  20. ├── config.py
  21. ├── db.py
  22. ├── main.py
  23. ├── models
  24. ├── __init__.py
  25. ├── pydantic.py
  26. └── tortoise.py
  27. └── summarizer.py
  28. ├── db
  29. ├── Dockerfile
  30. └── create.sql
  31. ├── entrypoint.sh
  32. ├── htmlcov
  33. ├── requirements-dev.txt
  34. ├── requirements.txt
  35. ├── setup.cfg
  36. └── tests
  37. ├── __init__.py
  38. ├── conftest.py
  39. ├── test_ping.py
  40. ├── test_summaries.py
  41. └── test_summaries_unit.py
  42. └── release.sh

Installation

Prerequisites:

1. Clone the repository

  1. $ git clone https://github.com/kmjawadurrahman/fastapi-tdd-docker.git && cd fastapi-tdd-docker

2. Use Docker and Docker Compose

  1. $ docker-compose up -d --build

3. Create the database

  1. $ docker-compose exec web python app/db.py

Usage

  1. $ docker-compose up -d

Docs

Go to http://localhost:8002/docs.

Access the database via psql

  1. $ docker-compose exec web-db psql -U postgres

Tests

  1. $ docker-compose exec web python -m pytest

Unit Tests with Monkey-patching:

  1. $ docker-compose exec web pytest -k "unit" -n auto