Skip to content

Commit dd8cce4

Browse files
authored
Merge pull request #12 from testdrivenio/updates
updates
2 parents ec51c24 + 6b4cf4b commit dd8cce4

10 files changed

Lines changed: 52 additions & 19 deletions

File tree

.github/workflows/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ jobs:
7878
-p 5003:8765 \
7979
${{ env.IMAGE }}-final:latest
8080
- name: Install requirements
81-
run: docker exec fastapi-tdd pip install black==20.8b1 flake8===3.8.4 isort==5.6.4 pytest==6.2.0
81+
run: docker exec fastapi-tdd pip install black==21.6b0 flake8==3.9.2 isort==5.9.1 pytest==6.2.4
8282
- name: Pytest
8383
run: docker exec fastapi-tdd python -m pytest .
8484
- name: Flake8
@@ -93,7 +93,7 @@ jobs:
9393
runs-on: ubuntu-latest
9494
needs: [build, test]
9595
env:
96-
HEROKU_APP_NAME: secret-crag-02876
96+
HEROKU_APP_NAME: thawing-beach-87010
9797
HEROKU_REGISTRY_IMAGE: registry.heroku.com/${HEROKU_APP_NAME}/summarizer
9898
steps:
9999
- name: Checkout master

project/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# pull official base image
2-
FROM python:3.9.2-slim-buster
2+
FROM python:3.9.6-slim-buster
33

44
# set working directory
55
WORKDIR /usr/src/app

project/Dockerfile.prod

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
###########
44

55
# pull official base image
6-
FROM python:3.8.8-slim-buster as builder
6+
FROM python:3.8.11-slim-buster as builder
77

88
# install system dependencies
99
RUN apt-get update \
@@ -24,7 +24,7 @@ RUN pip wheel --no-cache-dir --no-deps --wheel-dir /usr/src/app/wheels -r requir
2424

2525
# lint
2626
COPY . /usr/src/app/
27-
RUN pip install black==20.8b1 flake8===3.8.4 isort==5.7.0
27+
RUN pip install black==21.6b0 flake8==3.9.2 isort==5.9.1
2828
RUN flake8 .
2929
RUN black --exclude=migrations .
3030
RUN isort .
@@ -35,7 +35,7 @@ RUN isort .
3535
#########
3636

3737
# pull official base image
38-
FROM python:3.8.8-slim-buster
38+
FROM python:3.8.11-slim-buster
3939

4040
# create directory for the app user
4141
RUN mkdir -p /home/app
@@ -65,7 +65,7 @@ COPY --from=builder /usr/src/app/wheels /wheels
6565
COPY --from=builder /usr/src/app/requirements.txt .
6666
RUN pip install --upgrade pip
6767
RUN pip install --no-cache /wheels/*
68-
RUN pip install "uvicorn[standard]==0.13.4"
68+
RUN pip install "uvicorn[standard]==0.14.0"
6969

7070
# add app
7171
COPY . .

project/aerich.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[aerich]
2+
tortoise_orm = app.db.TORTOISE_ORM
3+
location = ./migrations

project/app/api/summaries.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# project/app/api/summaries.py
2+
3+
14
from typing import List
25

36
from fastapi import APIRouter, BackgroundTasks, HTTPException, Path
@@ -12,7 +15,6 @@
1215
SummaryUpdatePayloadSchema,
1316
)
1417

15-
1618
router = APIRouter()
1719

1820

project/app/db.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,17 @@
1111
log = logging.getLogger("uvicorn")
1212

1313

14+
TORTOISE_ORM = {
15+
"connections": {"default": os.environ.get("DATABASE_URL")},
16+
"apps": {
17+
"models": {
18+
"models": ["app.models.tortoise", "aerich.models"],
19+
"default_connection": "default",
20+
},
21+
},
22+
}
23+
24+
1425
def init_db(app: FastAPI) -> None:
1526
register_tortoise(
1627
app,

project/app/summarizer.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# project/app/summarizer.py
2+
3+
14
import nltk
25
from newspaper import Article
36

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
-- upgrade --
2+
CREATE TABLE IF NOT EXISTS "textsummary" (
3+
"id" SERIAL NOT NULL PRIMARY KEY,
4+
"url" TEXT NOT NULL,
5+
"summary" TEXT NOT NULL,
6+
"created_at" TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP
7+
);
8+
CREATE TABLE IF NOT EXISTS "aerich" (
9+
"id" SERIAL NOT NULL PRIMARY KEY,
10+
"version" VARCHAR(255) NOT NULL,
11+
"app" VARCHAR(20) NOT NULL,
12+
"content" JSONB NOT NULL
13+
);

project/requirements-dev.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
black==20.8b1
2-
flake8===3.8.4
3-
isort==5.7.0
4-
pytest==6.2.2
5-
pytest-cov==2.11.1
6-
pytest-xdist==2.2.1
1+
black==21.6b0
2+
flake8==3.9.2
3+
isort==5.9.1
4+
pytest==6.2.4
5+
pytest-cov==2.12.1
6+
pytest-xdist==2.3.0
77

88
-r requirements.txt

project/requirements.txt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
asyncpg==0.22.0
2-
fastapi==0.63.0
3-
gunicorn==20.0.4
1+
aerich==0.5.3
2+
asyncpg==0.23.0
3+
fastapi==0.65.3
4+
gunicorn==20.1.0
45
newspaper3k==0.2.8
56
requests==2.25.1
6-
tortoise-orm==0.16.21
7-
uvicorn==0.13.4
7+
tortoise-orm==0.17.4
8+
uvicorn==0.14.0

0 commit comments

Comments
 (0)