Skip to content

Commit

Permalink
Merge pull request #105 from lsst-sqre/u/jsickcodes/flask2
Browse files Browse the repository at this point in the history
Update to Flask 2
  • Loading branch information
jonathansick authored Mar 18, 2022
2 parents 4e23e66 + 436a489 commit 202555a
Show file tree
Hide file tree
Showing 11 changed files with 133 additions and 667 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ Change log
2.0.0 (Unreleased)
==================

- Add support the testing mysql and postgres databases locally and in GitHub Actions.
- Add support for testing mysql and postgres databases locally and in GitHub Actions.
- Update to Flask 2.

1.20.3 (2020-11-17)
===================
Expand Down
9 changes: 4 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,15 @@ help:
.PHONY: update-deps
update-deps:
pip install --upgrade pip-tools pip setuptools
pip-compile --upgrade --build-isolation --generate-hashes --output-file requirements/main.txt requirements/main.in
pip-compile --upgrade --build-isolation --generate-hashes --output-file requirements/dev.txt requirements/dev.in
pip-compile --upgrade --build-isolation --output-file requirements/main.txt requirements/main.in
pip-compile --upgrade --build-isolation --output-file requirements/dev.txt requirements/dev.in

.PHONY: init
init:
pip install --editable .
pip install --upgrade -r requirements/main.txt -r requirements/dev.txt
pip install --editable .
rm -rf .tox
pip install --upgrade pre-commit tox
pip install --pre --upgrade tox-docker
pip install --upgrade pre-commit tox tox-docker
pre-commit install

.PHONY: update
Expand Down
7 changes: 2 additions & 5 deletions keeper/api/dashboards.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from __future__ import annotations

from typing import TYPE_CHECKING, Dict, Tuple
from typing import Dict, Tuple

from flask_accept import accept_fallback

Expand All @@ -14,15 +14,12 @@

from ._models import QueuedResponse

if TYPE_CHECKING:
from flask import Response


@api.route("/dashboards", methods=["POST"])
@accept_fallback
@token_auth.login_required
@permission_required(Permission.ADMIN_PRODUCT)
def rebuild_all_dashboards() -> Tuple[Response, int, Dict[str, str]]:
def rebuild_all_dashboards() -> Tuple[str, int, Dict[str, str]]:
"""Rebuild the LTD Dasher dashboards for all products.
Note that dashboards are built asynchronously.
Expand Down
4 changes: 1 addition & 3 deletions keeper/api/editions.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
from ._urls import build_from_url, url_for_edition

if TYPE_CHECKING:
from flask import Response

from keeper.models import Build


Expand Down Expand Up @@ -207,7 +205,7 @@ def deprecate_edition(id: int) -> Tuple[str, int]:
@api.route("/products/<slug>/editions/", methods=["GET"])
@accept_fallback
@log_route()
def get_product_editions(slug: str) -> Response:
def get_product_editions(slug: str) -> str:
"""List all editions published for a Product.
**Example request**
Expand Down
4 changes: 2 additions & 2 deletions keeper/api/queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from typing import Dict, Tuple

from flask import abort, jsonify, url_for
from flask import Response, abort, jsonify, url_for
from flask_accept import accept_fallback

from keeper.api import api
Expand All @@ -13,7 +13,7 @@
@api.route("/queue/<id>", methods=["GET"])
@accept_fallback
@log_route()
def get_task_status(id: int) -> Tuple[str, int, Dict[str, str]]:
def get_task_status(id: int) -> Tuple[Response, int, Dict[str, str]]:
try:
if celery_app is not None:
task = celery_app.AsyncResult(id)
Expand Down
3 changes: 2 additions & 1 deletion keeper/appfactory.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ def create_flask_app(profile: Optional[str] = None) -> Flask:
config[_profile].init_app(app) # type: ignore # doesn't recog classmethod

# Add the middleware to respect headers forwarded from the proxy server
# Assigning to the wsgi_app method is recommended by the Flask docs
if app.config["PROXY_FIX"]:
app.wsgi_app = ProxyFix(
app.wsgi_app = ProxyFix( # type: ignore [assignment]
app.wsgi_app,
x_for=app.config["TRUST_X_FOR"],
x_proto=app.config["TRUST_X_PROTO"],
Expand Down
4 changes: 2 additions & 2 deletions keeper/v2api/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from typing import Dict, Tuple

from flask import abort, jsonify
from flask import Response, abort, jsonify
from flask_accept import accept_fallback

from keeper.auth import token_auth
Expand All @@ -19,7 +19,7 @@
@accept_fallback
@log_route()
@token_auth.login_required
def get_task(id: int) -> Tuple[str, int, Dict[str, str]]:
def get_task(id: int) -> Tuple[Response, int, Dict[str, str]]:
try:
if celery_app is not None:
task = celery_app.AsyncResult(id)
Expand Down
2 changes: 1 addition & 1 deletion requirements/dev.in
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ sqlalchemy-stubs
mock
coverage[toml]
mypy
Sphinx<4
Sphinx
sphinx-rtd-theme
numpydoc
sphinxcontrib-httpdomain
Expand Down
322 changes: 56 additions & 266 deletions requirements/dev.txt

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion requirements/main.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
# After editing, update requirements/main.txt by running:
# make update-deps

Flask<2
Flask
itsdangerous<2.1
uWSGI
Flask-SQLAlchemy
SQLAlchemy
Expand Down
Loading

0 comments on commit 202555a

Please sign in to comment.