- install
pyenvfirst to able to usepyenv install 3.10.3 - then use
pyenv shell 3.10.3andpip install poetry poetry installto init your envpoetry run pre-commit run -ato autoformat your code
poetry run test-> runs docker compose containers and then runs testspoetry run server-> runs docker compose and starts dev server with auto reloadpoetry run recreatemigrations-> recreates initial migration, we can use this when service not deployedpoetry run makemigration {description}-> create migration for dbpoetry run migrate-> upgrades to heads migration
- use
poetry add {name}to add package - use
poetry add -D {name}to add package only for development
- for first level module variables use
UPPER_CASE = 1APIetc. - all new features should be placed at
featuresmodule - db tables always lower case
some_table_name, values upper case, for example `CONTENT_TABLE = 'content', not 'contents'
- branch management: -> production branch (last production version with tag of latest release) -> auto commit creates a tag (not pushed into prod, only manually from github workflow -> workflow creates pull request into main rebase) -> hotfix/someshing needs to be fixed -> main branch (all stuff goes here) -> (feature or bugfix)/example-button branch from develop branch (service will create feautre-env -> all from develop + service for feature, all other services auto updated) -> could be fast forward
- add pipeline (python build with deps -> gitlab ci runner + cache)
- init
git branch production
-
New features located at
app.featuresmodule -> to create new feature you can use commandpoetry run feature <name> -
This will create new folder with stub
APIand wired module inside app/init.py -
Feature structure:
__init__.py- includes global instances that could not be initialized by container, likeAPIofFastAPIAPIRouterinstancemodels.py- defines pydantic models for endpoints, DB objects and general object validationtables.py- defines DB tables with keys, relations, indexes etc.services.py- defines incapsulated part of reused or isolated part of logicmanagers.py- defines aggregated flows usingservices,resourcesinto business logiccontainers.py- defines construction of all dependencies (services, managers, tables, etc.)api.py- defines endpoints with injected container dependencies
-
We need coverage report, mypylint