From 8a65f26a5a7b907fa20f646fe987870f062f6b15 Mon Sep 17 00:00:00 2001 From: Andreas Hasenkopf Date: Tue, 7 Feb 2023 15:30:20 +0100 Subject: [PATCH] Update tech stack (closes #119) * Use Py3.10 instead of Py3.9 * Use SQLAlchemy v2 --- .github/workflows/default.yml | 8 ++++---- backend/Dockerfile | 2 +- backend/database.py | 3 +-- backend/requirements.txt | 2 +- backend/tests/conftest.py | 8 +++++--- 5 files changed, 12 insertions(+), 11 deletions(-) diff --git a/.github/workflows/default.yml b/.github/workflows/default.yml index dc01da3..dfff33c 100644 --- a/.github/workflows/default.yml +++ b/.github/workflows/default.yml @@ -17,10 +17,10 @@ jobs: options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 steps: - uses: actions/checkout@v2 - - name: Set up Python 3.9 + - name: Set up Python 3.10 uses: actions/setup-python@v2 with: - python-version: 3.9 + python-version: "3.10" - name: Cache pip uses: actions/cache@v2 with: @@ -47,10 +47,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - name: Set up Python 3.9 + - name: Set up Python 3.10 uses: actions/setup-python@v2 with: - python-version: 3.9 + python-version: "3.10" - name: Cache pip uses: actions/cache@v2 with: diff --git a/backend/Dockerfile b/backend/Dockerfile index 06441cd..42dc174 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.9-slim +FROM python:3.10-slim COPY . /opt/aimaas RUN pip3 install -r /opt/aimaas/requirements.txt; \ diff --git a/backend/database.py b/backend/database.py index 56eb7d8..913fab6 100644 --- a/backend/database.py +++ b/backend/database.py @@ -1,8 +1,7 @@ from fastapi import HTTPException from starlette.status import HTTP_503_SERVICE_UNAVAILABLE from sqlalchemy import create_engine, text -from sqlalchemy.ext.declarative import declarative_base -from sqlalchemy.orm import sessionmaker +from sqlalchemy.orm import declarative_base, sessionmaker from .config import SQLALCHEMY_DATABASE_URL diff --git a/backend/requirements.txt b/backend/requirements.txt index ad3a30f..9cc40cb 100644 --- a/backend/requirements.txt +++ b/backend/requirements.txt @@ -9,5 +9,5 @@ pydantic<1.9.1 python-dotenv python-jose[cryptography] python-multipart -SQLAlchemy<2 +SQLAlchemy uvicorn diff --git a/backend/tests/conftest.py b/backend/tests/conftest.py index 27c65d9..2079fd0 100644 --- a/backend/tests/conftest.py +++ b/backend/tests/conftest.py @@ -4,7 +4,7 @@ from alembic.config import Config from httpx._client import USE_CLIENT_DEFAULT import pytest -from sqlalchemy import create_engine +from sqlalchemy import create_engine, text from sqlalchemy.orm import sessionmaker from fastapi.testclient import TestClient @@ -304,14 +304,16 @@ def engine(): pool_timeout=5) Base.metadata.drop_all(engine) with engine.connect() as conn: - conn.execute("drop table if exists alembic_version") + conn.execute(text("drop table if exists alembic_version")) + conn.commit() cfg = Config("alembic.ini") command.upgrade(cfg, "head") yield engine Base.metadata.drop_all(engine) with engine.connect() as conn: - conn.execute("drop table if exists alembic_version") + conn.execute(text("drop table if exists alembic_version")) + conn.commit() engine.dispose()