Skip to content

Commit e47ca86

Browse files
authored
Revert "TEST - Build and image with new Flask and SQLAlchemy" (#974)
1 parent bbd596b commit e47ca86

File tree

4 files changed

+12
-24
lines changed

4 files changed

+12
-24
lines changed

devops/Dockerfile

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,13 @@ WORKDIR /src
33
COPY . /src
44
RUN npm ci && npm run build
55

6-
FROM tiangolo/meinheld-gunicorn:python3.8
6+
FROM tiangolo/meinheld-gunicorn:python3.7
77
LABEL org.opencontainers.image.source=https://github.com/cmu-delphi/delphi-epidata
88
# use delphi's timezome
99
RUN ln -s -f /usr/share/zoneinfo/America/New_York /etc/localtime
1010

11-
COPY requirements.txt /app/requirements_also.txt
12-
RUN pip install --no-cache-dir -r /tmp/requirements.txt -r requirements_also.txt
13-
# the file /tmp/requirements.txt is created in the parent docker definition. (see:
14-
# https://github.com/tiangolo/meinheld-gunicorn-docker/blob/master/docker-images/python3.8.dockerfile#L5 )
15-
# this combined requirements installation ensures all version constrants are accounted for.
11+
COPY requirements.txt /app
12+
RUN pip install --no-cache-dir -r requirements.txt
1613

1714
# disable python stdout buffering
1815
ENV PYTHONUNBUFFERED 1

requirements.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
itsdangerous<2.1
22
jinja2==3.0.3
3-
werkzeug==2.2.2
4-
Flask==2.2.2
5-
SQLAlchemy==1.4.40
3+
werkzeug<2.1
4+
Flask==1.1.2
5+
SQLAlchemy==1.3.22
66
mysqlclient==2.0.2
77
python-dotenv==0.15.0
88
orjson==3.4.7

src/server/_config.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,7 @@
1111
MAX_COMPATIBILITY_RESULTS = int(3650)
1212

1313
SQLALCHEMY_DATABASE_URI = os.environ.get("SQLALCHEMY_DATABASE_URI", "sqlite:///test.db")
14-
15-
# defaults
16-
SQLALCHEMY_ENGINE_OPTIONS = {
17-
"pool_pre_ping": True, # enable ping test for validity of recycled pool connections on connect() calls
18-
"pool_recycle": 5 # seconds after which a recycled pool connection is considered invalid
19-
}
20-
# update with overrides of defaults or additions from external configs
21-
SQLALCHEMY_ENGINE_OPTIONS.update(
22-
json.loads(os.environ.get("SQLALCHEMY_ENGINE_OPTIONS", "{}")))
23-
14+
SQLALCHEMY_ENGINE_OPTIONS = json.loads(os.environ.get("SQLALCHEMY_ENGINE_OPTIONS", "{}"))
2415
SECRET = os.environ.get("FLASK_SECRET", "secret")
2516
URL_PREFIX = os.environ.get("FLASK_PREFIX", "/")
2617

src/server/_query.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
)
1515

1616
from sqlalchemy import text
17-
from sqlalchemy.engine import Row
17+
from sqlalchemy.engine import RowProxy
1818

1919
from ._common import db, app
2020
from ._db import metadata
@@ -197,7 +197,7 @@ def filter_pair(pair: TimePair, i) -> str:
197197

198198

199199
def parse_row(
200-
row: Row,
200+
row: RowProxy,
201201
fields_string: Optional[Sequence[str]] = None,
202202
fields_int: Optional[Sequence[str]] = None,
203203
fields_float: Optional[Sequence[str]] = None,
@@ -245,7 +245,7 @@ def run_query(p: APrinter, query_tuple: Tuple[str, Dict[str, Any]]):
245245
return db.execution_options(stream_results=True).execute(full_query, **params)
246246

247247

248-
def _identity_transform(row: Dict[str, Any], _: Row) -> Dict[str, Any]:
248+
def _identity_transform(row: Dict[str, Any], _: RowProxy) -> Dict[str, Any]:
249249
"""
250250
identity transform
251251
"""
@@ -257,7 +257,7 @@ def execute_queries(
257257
fields_string: Sequence[str],
258258
fields_int: Sequence[str],
259259
fields_float: Sequence[str],
260-
transform: Callable[[Dict[str, Any], Row], Dict[str, Any]] = _identity_transform,
260+
transform: Callable[[Dict[str, Any], RowProxy], Dict[str, Any]] = _identity_transform,
261261
):
262262
"""
263263
execute the given queries and return the response to send them
@@ -317,7 +317,7 @@ def execute_query(
317317
fields_string: Sequence[str],
318318
fields_int: Sequence[str],
319319
fields_float: Sequence[str],
320-
transform: Callable[[Dict[str, Any], Row], Dict[str, Any]] = _identity_transform,
320+
transform: Callable[[Dict[str, Any], RowProxy], Dict[str, Any]] = _identity_transform,
321321
):
322322
"""
323323
execute the given query and return the response to send it

0 commit comments

Comments
 (0)