Skip to content

Commit

Permalink
Merge pull request #280 from gyorilab/flask3
Browse files Browse the repository at this point in the history
Upgrade to `flask_jwt_extended>3`
  • Loading branch information
bgyori authored Jul 19, 2024
2 parents 5578d34 + 5a51960 commit fbfd99f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 22 deletions.
14 changes: 6 additions & 8 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
# Set up postgres
services:
postgres:
image: postgres:9.6
image: postgres:13.13
env:
POSTGRES_PASSWORD: password
POSTGRES_USER: postgres
Expand All @@ -26,21 +26,19 @@ jobs:
key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.py') }}
restore-keys: |
${{ runner.os }}-pip-
# Set up Python 3.7
- name: Set up Python 3.7
# Set up Python 3.9
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.7
python-version: "3.9"
# Install EMMAA/test dependencies
- name: Install dependencies
run: |
sudo apt-get install libpq-dev
psql --no-password -h localhost -c 'create database emmaadb_test;' -U postgres
wget -nv https://files.pythonhosted.org/packages/91/a1/55b8224cbc9986bbad4b8f0f2dd11892845156b759b3495202d457ca0b73/kappy-4.0.94-cp37-cp37m-manylinux2010_x86_64.whl
mv kappy-4.0.94-cp37-cp37m-manylinux2010_x86_64.whl kappy-4.0.94-cp37-cp37m-manylinux2010_x86_64.zip
unzip kappy-4.0.94-cp37-cp37m-manylinux2010_x86_64.zip
sudo apt-get install graphviz libgraphviz-dev pkg-config
python -m pip install --upgrade pip
pip install kappy==4.1.2
pip install nose coverage flask pyyaml boto3 openpyxl
pip install git+https://github.com/sorgerlab/indra.git
pip uninstall -y enum34
Expand All @@ -60,7 +58,7 @@ jobs:
# cd automates
# git checkout claytonm/gromet
# cd ..
pip install boto3 jsonpickle pygraphviz fnvhash inflection pybel==0.15 flask_jwt_extended==3.25.0 gilda tweepy nose coverage moto[iam] sqlalchemy_utils termcolor flask-cors
pip install boto3 jsonpickle pygraphviz fnvhash inflection pybel==0.15 flask_jwt_extended==4.6.0 gilda tweepy nose coverage 'moto[iam]<5' sqlalchemy_utils termcolor flask-cors==4.0.1
pip install --no-dependencies .
pip install -U sqlalchemy==1.3.23
wget "https://github.com/RuleWorld/bionetgen/releases/download/BioNetGen-2.4.0/BioNetGen-2.4.0-Linux.tgz" -O bionetgen.tar.gz -nv
Expand Down
4 changes: 2 additions & 2 deletions emmaa/tests/test_xdd.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

@attr('nonpublic')
def test_document_figures_doi():
doi = '10.1016/j.apsb.2020.09.003'
doi = '10.1136/bmj.n436'
fig_list = get_document_figures(doi, 'DOI')
assert fig_list
# Should be a list of tuples with title and image bytes
assert len(fig_list[0]) == 2
assert len(fig_list[0]) == 8


# This would call database
Expand Down
20 changes: 10 additions & 10 deletions emmaa_service/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from flask_restx import Api, Resource, fields, inputs, abort as restx_abort
from flask_cors import CORS

from flask_jwt_extended import jwt_optional
from flask_jwt_extended import jwt_required
from urllib import parse
from collections import defaultdict, Counter
from copy import deepcopy
Expand Down Expand Up @@ -1146,14 +1146,14 @@ def session_expiration_check():


@app.route('/health')
@jwt_optional
@jwt_required(optional=True)
def health():
return jsonify({'status': 'pass'})


@app.route('/')
@app.route('/home')
@jwt_optional
@jwt_required(optional=True)
def get_home():
loaded = request.args.get('loaded')
loaded = (loaded == 'true')
Expand All @@ -1169,7 +1169,7 @@ def get_home():


@app.route('/dashboard/<model>')
@jwt_optional
@jwt_required(optional=True)
def get_model_dashboard(model):
"""Render model dashboard page."""
loaded = request.args.get('loaded')
Expand Down Expand Up @@ -1691,7 +1691,7 @@ def get_model_tests_page(model):


@app.route('/query')
@jwt_optional
@jwt_required(optional=True)
def get_query_page():
"""Render queries page."""
loaded = request.args.get('loaded')
Expand Down Expand Up @@ -1963,7 +1963,7 @@ def get_all_statements_page(model):


@app.route('/demos')
@jwt_optional
@jwt_required(optional=True)
def get_demos_page():
user, roles = resolve_auth(dict(request.args))
user_email = user.email if user else ""
Expand All @@ -1972,7 +1972,7 @@ def get_demos_page():


@app.route('/chat')
@jwt_optional
@jwt_required(optional=True)
def chat_with_the_model():
model = request.args.get('model', '')
user, roles = resolve_auth(dict(request.args))
Expand Down Expand Up @@ -2057,7 +2057,7 @@ def get_query_tests_page(model):


@app.route('/query/submit', methods=['POST'])
@jwt_optional
@jwt_required(optional=True)
def process_query():
"""Get result for a query."""
# Print inputs.
Expand Down Expand Up @@ -2241,7 +2241,7 @@ def email_unsubscribe_post():


@app.route('/subscribe/<model>', methods=['POST'])
@jwt_optional
@jwt_required(optional=True)
def model_subscription(model):
user, roles = resolve_auth(dict(request.args))
if not roles and not user:
Expand Down Expand Up @@ -2323,7 +2323,7 @@ def get_statement_by_paper(model, paper_id, paper_id_type, date, hash_val):


@app.route('/curation/submit/<hash_val>', methods=['POST'])
@jwt_optional
@jwt_required(optional=True)
def submit_curation_endpoint(hash_val, **kwargs):
user, roles = resolve_auth(dict(request.args))
if not roles and not user:
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
install_requires=['indra', 'boto3', 'jsonpickle', 'kappy==4.1.2',
'pygraphviz', 'fnvhash', 'sqlalchemy<1.4',
'inflection', 'pybel==0.15',
'flask_jwt_extended==3.25.0', 'gilda', 'tweepy'],
extras_require={'test': ['nose', 'coverage', 'moto[iam]',
'flask_jwt_extended', 'gilda', 'tweepy'],
extras_require={'test': ['nose', 'coverage', 'moto[iam]<5',
'sqlalchemy_utils']}
)

0 comments on commit fbfd99f

Please sign in to comment.