Skip to content

Commit

Permalink
Merge pull request #339 from zganger/update-python-and-deps
Browse files Browse the repository at this point in the history
update python and dependencies
  • Loading branch information
zganger authored Mar 13, 2024
2 parents f547efe + 245fd71 commit 7fc87ef
Show file tree
Hide file tree
Showing 21 changed files with 379 additions and 368 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/python-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:12-alpine
image: postgres:16-alpine
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
Expand All @@ -23,10 +23,10 @@ jobs:
- 5432:5432
steps:
- uses: actions/checkout@v4
- name: Python 3.8 Setup
- name: Python 3.12 Setup
uses: actions/setup-python@v5
with:
python-version: 3.8
python-version: 3.12
- name: Install dependencies
run: |
sudo apt-get update
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ You'll need to replace `police-data-trust-api-1` with the name of the container
docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c0cf******** police-data-trust-api "/bin/sh -c '/wait &…" About a minute ago Up About a minute 0.0.0.0:5001->5001/tcp police-data-trust-api-1
5e6f******** postgres:13.2 "docker-entrypoint.s…" 3 days ago Up About a minute 0.0.0.0:5432->5432/tcp police-data-trust-db-1
5e6f******** postgres:16.1 "docker-entrypoint.s…" 3 days ago Up About a minute 0.0.0.0:5432->5432/tcp police-data-trust-db-1
dacd******** police-data-trust-web "docker-entrypoint.s…" 3 days ago Up About a minute 0.0.0.0:3000->3000/tcp police-data-trust-web-1
```

Expand Down
4 changes: 2 additions & 2 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
FROM python:3.9.5-slim-buster AS base
FROM python:3-slim-buster AS base

RUN apt-get update && apt-get install curl -y && apt-get install g++ libpq-dev gcc -y

ADD https://github.com/ufoscout/docker-compose-wait/releases/download/2.7.3/wait /wait
ADD https://github.com/ufoscout/docker-compose-wait/releases/download/2.12.1/wait /wait
RUN chmod +x /wait


Expand Down
2 changes: 1 addition & 1 deletion backend/Dockerfile.cloud
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# docker build command:
# docker build -t police-data-trust-backend-dev -f backend/Dockerfile.cloud .
FROM python:3.8-slim-buster
FROM python:3-slim-buster

WORKDIR /app/

Expand Down
3 changes: 2 additions & 1 deletion backend/database/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import click
import pandas as pd
import psycopg
import psycopg2.errors
from flask import abort, current_app
from flask.cli import AppGroup, with_appcontext
Expand Down Expand Up @@ -122,7 +123,7 @@ def create_database(

try:
cursor.execute(f"CREATE DATABASE {database};")
except psycopg2.errors.lookup("42P04"):
except (psycopg2.errors.lookup("42P04"), psycopg.errors.DuplicateDatabase):
click.echo(f"Database {database!r} already exists.")
else:
click.echo(f"Created database {database!r}.")
Expand Down
2 changes: 1 addition & 1 deletion backend/routes/healthcheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ class Resp(BaseModel):
def healthcheck():
"""Verifies service health and returns the api version"""
check_db()
return ({"apiVersion": spec.config.VERSION}, 200)
return {"apiVersion": spec.config.version}, 200
4 changes: 2 additions & 2 deletions backend/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from pydantic_sqlalchemy import sqlalchemy_to_pydantic
from spectree import SecurityScheme, SpecTree
from spectree.models import Server
from sqlalchemy.ext.declarative.api import DeclarativeMeta
from sqlalchemy.ext.declarative import DeclarativeMeta

from .database import User
from .database.models.action import Action
Expand Down Expand Up @@ -84,7 +84,7 @@
data={
"type": "http",
"scheme": "bearer",
"bearerFormat": {"JWT": []},
"bearerFormat": "JWT",
},
),
],
Expand Down
3 changes: 2 additions & 1 deletion backend/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import psycopg.errors
import psycopg2.errors
import pytest
from backend.api import create_app
Expand Down Expand Up @@ -37,7 +38,7 @@ def database():

try:
janitor.init()
except psycopg2.errors.lookup("42P04"):
except (psycopg2.errors.lookup("42P04"), psycopg.errors.DuplicateDatabase):
pass

yield
Expand Down
2 changes: 1 addition & 1 deletion backend/tests/test_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def test_auth_test_header(client, example_user):
json={"email": example_user.email, "password": "my_password"},
)

client.set_cookie("localhost", "access_token_cookie", value="")
client.set_cookie(domain="localhost", key="access_token_cookie", value="")

test_res = client.get(
"api/v1/auth/whoami",
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: "3"
services:
db:
image: postgres:13.2 #AWS RDS latest version
image: postgres:16.1 #AWS RDS latest version
env_file:
- ".env"
volumes:
Expand Down
2 changes: 1 addition & 1 deletion docs/src/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Install all of the following programs onto your computer:

**Required:**

- [Python 3.8](https://www.python.org/downloads/)
- [Python 3.12](https://www.python.org/downloads/)
- [Git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) (first time setup guide [here](https://git-scm.com/book/en/v2/Getting-Started-First-Time-Git-Setup))
- [Postgres](https://www.postgresql.org/) _(see installation instructions below)_
- _(OSX only)_ [Homebrew](https://brew.sh/)
Expand Down
4 changes: 2 additions & 2 deletions requirements/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# requirements, so this image starts with the same image as the database
# containers and installs the same version of python as the api containers

FROM postgres:13.2 as base
FROM postgres:16.1 as base

RUN apt-get update && apt-get install -y \
make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev \
Expand All @@ -15,7 +15,7 @@ SHELL ["bash", "-lc"]
RUN curl https://pyenv.run | bash && \
echo 'export PATH="$HOME/.pyenv/shims:$HOME/.pyenv/bin:$PATH"' >> ~/.bashrc

ENV PYTHON_VERSION=3.8.11
ENV PYTHON_VERSION=3.12.2
RUN pyenv install ${PYTHON_VERSION} && pyenv global ${PYTHON_VERSION}
RUN pip install pip-tools

Expand Down
2 changes: 1 addition & 1 deletion requirements/_core.in
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pytest-mock
python-dotenv
flask-user<0.7
wtforms
SQLAlchemy==1.3.23
SQLAlchemy==1.4.51
flask-wtf
flask-babelex
PyYAML
Expand Down
1 change: 1 addition & 0 deletions requirements/dev_unix.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
-r _core.in
psycopg2-binary
psycopg-binary
Loading

0 comments on commit 7fc87ef

Please sign in to comment.