NDA...
- Create env file:
cp envs/.env.example envs/.env- If you use
pyenv, create and activate environment. You can read this article to get familiar with pyenv. Or you can just omit this step, and poetry will install venv for you.
pyenv install 3.11
pyenv virtualenv 3.11 my_awesome_app
pyenv local my_awesome_app- If you don't have
Poetryinstalled run:
make poetry-download- Initialize poetry and install
pre-commithooks:
make install
make pre-commit-install- Run formatters, and linters. Make sure there is no errors.
make format lint- Run supporting services
docker compose --profile infra up -d- Run the API
make api- Run the task worker
make workerYou can open:
- API Documentation at http://localhost:8000/docs
- Minio at http://localhost:9001 (user, password)
- RabbitMQ at http://localhost:15672/ (guest, guest)
To stop all services run:
docker compose --profile dev --profile test down- Create env file:
cp envs/.env.docker.example envs/.env.docker- Build an image:
docker compose --profile dev build- Run the app:
docker compose --profile dev up -d- Run formatters and linters. Make sure there is no errors.
docker compose exec web make format lintYou can open:
- API Documentation at http://localhost:8000/docs
- Minio at http://localhost:9001 (user, password)
- RabbitMQ at http://localhost:15672/ (guest, guest)
To stop all services run:
docker compose --profile dev --profile test downRun supporting services for testing:
docker compose --profile test-infra up -dRun tests:
make test
Stop all services:
docker compose --profile test-infra downdocker compose --profile test builddocker compose run test-runnerAs simple as that
Create migration:
alembic revision --autogenerate -m "Message"Apply migrations:
alembic upgrade headRevert last migration:
alembic downgrade -1Makefile contains a lot of functions for
faster development.
1. Download and remove Poetry
To download and install Poetry run:
make poetry-downloadTo uninstall
make poetry-remove2. Install all dependencies and pre-commit hooks
Install requirements:
make installPre-commit hooks could be installed after git init via
make pre-commit-install3. Codestyle
Automatic formatting uses ruff.
make codestyle
# or use synonym
make formatCodestyle checks only, without rewriting files:
make check-codestyleUpdate all dev libraries to the latest version using one comand
make update-dev-deps4. Code security
make check-securityThis command identifies security issues with Safety and Bandit.
make check-securityTo validate pyproject.toml use
make check-poetry5. Linting and type checks
Run static linting with pylint and mypy:
make static-lint6. Tests with coverage
Run pytest
make test7. All linters
Of course there is a command to rule run all linters in one:
make lintthe same as:
make test && make check-codestyle && make static-lint && make check-safety8. Docker
make docker-buildwhich is equivalent to:
make docker-build VERSION=latestRemove docker image with
make docker-removeMore information about docker.
9. Cleanup
Delete pycache files
make pycache-removeRemove package build
make build-removeDelete .DS_STORE files
make dsstore-removeRemove .mypycache
make mypycache-removeOr to remove all above run:
make cleanupThis project was generated with python-package-template