Skip to content

Commit 848cd91

Browse files
committed
🎨 makefile and poetry done
1 parent fb7fb3a commit 848cd91

34 files changed

+1421
-358
lines changed

.env.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
DEFAULT_MODEL_PATH=./sample_model/lin_reg_california_housing_model.joblib
2+
IS_DEBUG=False

Dockerfile

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
1-
FROM python:3.7-stretch
2-
RUN pip install pipenv
3-
COPY . ./app
1+
FROM python:3.6.13 as base
2+
3+
# copy our project code
4+
COPY ./requirements.txt /app/requirements.txt
5+
46
WORKDIR /app
5-
RUN pipenv install
6-
EXPOSE 3000
7-
CMD ["pipenv", "run", "uvicorn", "fastapi_scaffolding.main:app", "--host=0.0.0.0", "--port=3000", "--workers=10"]
7+
# install our dependencies
8+
RUN pip3 install -r requirements.txt
9+
10+
COPY . /app
11+
12+
# expose the port 8000
13+
EXPOSE 8000
14+
15+
# define the default command to run when starting the container
16+
CMD ["uvicorn", "--host", "0.0.0.0", "--port", "8000", "--workers", "4", "app.main:app"]

Makefile

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
PROJECT=fastapi-ml-scaffolding
2+
PYTHON_VERSION=3.6.13
3+
4+
SOURCE_OBJECTS=app tests
5+
6+
deploy.requirements:
7+
poetry export -f requirements.txt -o requirements.txt
8+
poetry export --dev -f requirements.txt -o requirements-dev.txt
9+
deploy:
10+
poetry build
11+
12+
format.black:
13+
poetry run black ${SOURCE_OBJECTS}
14+
format.isort:
15+
poetry run isort --atomic ${SOURCE_OBJECTS}
16+
format: format.isort format.black
17+
18+
lints.format.check:
19+
poetry run black --check ${SOURCE_OBJECTS}
20+
poetry run isort --check-only ${SOURCE_OBJECTS}
21+
lints.flake8:
22+
git diff --diff-filter=d --name-only origin/development -- '*.py' | xargs poetry run flake8 --ignore=DAR,E203,W503
23+
lints.flake8.strict:
24+
poetry run flake8
25+
lints.mypy:
26+
poetry run mypy ${SOURCE_OBJECTS}
27+
lints.pylint:
28+
poetry run pylint --rcfile pyproject.toml ${SOURCE_OBJECTS}
29+
lints: lints.flake8
30+
lints.strict: lints lints.pylint lints.flake8.strict lints.mypy
31+
32+
33+
setup: setup.python setup.sysdep.poetry setup.project
34+
setup.uninstall: setup.python
35+
poetry env remove ${PYTHON_VERSION} || true
36+
setup.ci: setup.ci.poetry setup.project
37+
setup.ci.poetry:
38+
pip install poetry
39+
setup.project:
40+
@poetry env use $$(python -c "import sys; print(sys.executable)")
41+
@echo "Active interpreter path: $$(poetry env info --path)/bin/python"
42+
poetry install
43+
setup.python.activation:
44+
@pyenv local ${PYTHON_VERSION} >/dev/null 2>&1 || true
45+
@asdf local python ${PYTHON_VERSION} >/dev/null 2>&1 || true
46+
47+
setup.python: setup.python.activation
48+
@echo "Active Python version: $$(python --version)"
49+
@echo "Base Interpreter path: $$(python -c 'import sys; print(sys.executable)')"
50+
@test "$$(python --version | cut -d' ' -f2)" = "${PYTHON_VERSION}" \
51+
|| (echo "Please activate python ${PYTHON_VERSION}" && exit 1)
52+
setup.sysdep.poetry:
53+
@command -v poetry \&> /dev/null \
54+
|| (echo "Poetry not found. \n Installation instructions: https://python-poetry.org/docs/" \
55+
&& exit 1)
56+
57+
test:
58+
docker-compose up unit-tests
59+
test.clean:
60+
docker-compose down
61+
-docker images -a | grep ${PROJECT} | awk '{print $3}' | xargs docker rmi
62+
-docker image prune -f
63+
test.shell:
64+
docker-compose run unit-tests /bin/bash
65+
test.shell.debug:
66+
docker-compose run --entrypoint /bin/bash unit-tests
67+
test.local: setup
68+
poetry run coverage run -m pytest

Pipfile

Lines changed: 0 additions & 26 deletions
This file was deleted.

Pipfile.lock

Lines changed: 0 additions & 245 deletions
This file was deleted.
File renamed without changes.

fastapi_scaffolding/api/routes/heartbeat.py renamed to app/api/routes/heartbeat.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
21
from fastapi import APIRouter
32

4-
from fastapi_scaffolding.data_models.heartbeat import HearbeatResult
3+
from app.data_models.heartbeat import HearbeatResult
54

65
router = APIRouter()
76

0 commit comments

Comments
 (0)