Skip to content

Commit 63e0d9d

Browse files
authored
Merge pull request #37 from testdrivenio/updates
updates
2 parents ede52f0 + ed7a335 commit 63e0d9d

File tree

12 files changed

+119
-75
lines changed

12 files changed

+119
-75
lines changed

.github/workflows/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ jobs:
8383
-p 5003:8765 \
8484
${{ env.IMAGE }}-final:latest
8585
- name: Install requirements
86-
run: docker exec fastapi-tdd pip install black==23.1.0 flake8==6.0.0 isort==5.12.0 pytest==7.2.2
86+
run: docker exec fastapi-tdd pip install black==23.12.1 flake8==7.0.0 isort==5.13.2 pytest==7.4.4
8787
- name: Pytest
8888
run: docker exec fastapi-tdd python -m pytest .
8989
- name: Flake8
@@ -98,7 +98,7 @@ jobs:
9898
runs-on: ubuntu-latest
9999
needs: [build, test]
100100
env:
101-
HEROKU_APP_NAME: radiant-everglades-49858
101+
HEROKU_APP_NAME: quiet-citadel-80656
102102
HEROKU_REGISTRY_IMAGE: registry.heroku.com/${HEROKU_APP_NAME}/summarizer
103103
steps:
104104
- name: Checkout

project/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# pull official base image
2-
FROM python:3.11.2-slim-buster
2+
FROM python:3.12.1-slim-bookworm
33

44
# set working directory
55
WORKDIR /usr/src/app
@@ -10,7 +10,7 @@ ENV PYTHONUNBUFFERED 1
1010

1111
# install system dependencies
1212
RUN apt-get update \
13-
&& apt-get -y install netcat gcc postgresql \
13+
&& apt-get -y install netcat-traditional gcc postgresql \
1414
&& apt-get clean
1515

1616
# install python dependencies

project/Dockerfile.prod

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

55
# pull official base image
6-
FROM python:3.11.2-slim-buster as builder
6+
FROM python:3.12.1-slim-bookworm as builder
77

88
# install system dependencies
99
RUN apt-get update \
10-
&& apt-get -y install gcc postgresql \
10+
&& apt-get -y install netcat-traditional gcc postgresql \
1111
&& apt-get clean
1212

1313
# set work directory
@@ -24,18 +24,18 @@ 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==23.1.0 flake8==6.0.0 isort==5.12.0
27+
RUN pip install black==23.12.1 flake8==7.0.0 isort==5.13.2
2828
RUN flake8 .
29-
RUN black --exclude=migrations .
30-
RUN isort .
29+
RUN black --exclude=migrations . --check
30+
RUN isort . --check-only
3131

3232

3333
#########
3434
# FINAL #
3535
#########
3636

3737
# pull official base image
38-
FROM python:3.11.2-slim-buster
38+
FROM python:3.12.1-slim-bookworm
3939

4040
# create directory for the app user
4141
RUN mkdir -p /home/app
@@ -57,15 +57,15 @@ ENV TESTING 0
5757

5858
# install system dependencies
5959
RUN apt-get update \
60-
&& apt-get -y install netcat gcc postgresql \
60+
&& apt-get -y install netcat-traditional gcc postgresql \
6161
&& apt-get clean
6262

6363
# install python dependencies
6464
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.21.1"
68+
RUN pip install "uvicorn[standard]==0.26.0"
6969

7070
# add app
7171
COPY . .

project/app/api/crud.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@
44
from app.models.tortoise import TextSummary
55

66

7-
async def get_all() -> List:
8-
summaries = await TextSummary.all().values()
9-
return summaries
10-
11-
127
async def get(id: int) -> Union[dict, None]:
138
summary = await TextSummary.filter(id=id).first().values()
149
if summary:
1510
return summary
1611
return None
1712

1813

14+
async def get_all() -> List:
15+
summaries = await TextSummary.all().values()
16+
return summaries
17+
18+
1919
async def post(payload: SummaryPayloadSchema) -> int:
2020
summary = TextSummary(url=payload.url, summary="")
2121
await summary.save()

project/app/api/summaries.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,6 @@
1515
router = APIRouter()
1616

1717

18-
@router.get("/", response_model=List[SummarySchema])
19-
async def read_all_summaries() -> List[SummarySchema]:
20-
return await crud.get_all()
21-
22-
2318
@router.get("/{id}/", response_model=SummarySchema)
2419
async def read_summary(id: int = Path(..., gt=0)) -> SummarySchema:
2520
summary = await crud.get(id)
@@ -29,13 +24,18 @@ async def read_summary(id: int = Path(..., gt=0)) -> SummarySchema:
2924
return summary
3025

3126

27+
@router.get("/", response_model=List[SummarySchema])
28+
async def read_all_summaries() -> List[SummarySchema]:
29+
return await crud.get_all()
30+
31+
3232
@router.post("/", response_model=SummaryResponseSchema, status_code=201)
3333
async def create_summary(
3434
payload: SummaryPayloadSchema, background_tasks: BackgroundTasks
3535
) -> SummaryResponseSchema:
3636
summary_id = await crud.post(payload)
3737

38-
background_tasks.add_task(generate_summary, summary_id, payload.url)
38+
background_tasks.add_task(generate_summary, summary_id, str(payload.url))
3939

4040
response_object = {"id": summary_id, "url": payload.url}
4141
return response_object

project/app/config.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import logging
22
from functools import lru_cache
33

4-
from pydantic import AnyUrl, BaseSettings
4+
from pydantic import AnyUrl
5+
from pydantic_settings import BaseSettings
56

67
log = logging.getLogger("uvicorn")
78

project/db/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 postgres:15
2+
FROM postgres:16
33

44
# run create.sql on init
55
ADD create.sql /docker-entrypoint-initdb.d

project/requirements-dev.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
black==23.1.0
2-
flake8==6.0.0
3-
isort==5.12.0
4-
pytest==7.2.2
5-
pytest-cov==4.0.0
6-
pytest-xdist==3.2.1
1+
black==23.12.1
2+
flake8==7.0.0
3+
isort==5.13.2
4+
pytest==7.4.4
5+
pytest-cov==4.1.0
6+
pytest-xdist==3.5.0
77

88
-r requirements.txt

project/requirements.txt

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
aerich==0.7.1
2-
asyncpg==0.27.0
3-
fastapi==0.94.1
4-
gunicorn==20.1.0
5-
httpx==0.23.3
1+
aerich==0.7.2
2+
asyncpg==0.29.0
3+
fastapi==0.109.0
4+
gunicorn==21.0.1
5+
httpx==0.26.0
66
newspaper3k==0.2.8
7-
tortoise-orm==0.19.3
8-
uvicorn==0.21.1
7+
pydantic-settings==2.1.0
8+
tortoise-orm==0.20.0
9+
uvicorn==0.26.0

0 commit comments

Comments
 (0)