Skip to content

Commit

Permalink
Merge pull request #1 from qresp-code-development/qresp-1.1
Browse files Browse the repository at this point in the history
Qresp 1.1
  • Loading branch information
mgovoni-devel authored Jan 25, 2019
2 parents 15a179d + 2ecdb7c commit 4a93841
Show file tree
Hide file tree
Showing 32 changed files with 1,496 additions and 227 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ web/flask_session/
flask_session/
web/dist/
web/project/__pycache__/
web/build/
web/qresp.egg-info/
53 changes: 45 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,50 @@
language: python
python:
- "3.3"
- "3.4"
- "3.5"
- "3.6"
# command to install dependencies
matrix:
include:
- os: linux
python: 3.4
env: TOXENV=py34
- os: linux
python: 3.5
env: TOXENV=py35
- os: linux
python: 3.6
env: TOXENV=py36
- os: osx
env: PYTHON=3.4.4
language: generic

before_install: |
if [ "$TRAVIS_OS_NAME" == "osx" ]; then
brew update
# Per the `pyenv homebrew recommendations <https://github.com/yyuu/pyenv/wiki#suggested-build-environment>`_.
brew install openssl readline
# See https://docs.travis-ci.com/user/osx-ci-environment/#A-note-on-upgrading-packages.
# I didn't do this above because it works and I'm lazy.
brew outdated pyenv || brew upgrade pyenv
# virtualenv doesn't work without pyenv knowledge. venv in Python 3.3
# doesn't provide Pip by default. So, use `pyenv-virtualenv <https://github.com/yyuu/pyenv-virtualenv/blob/master/README.md>`_.
brew install pyenv-virtualenv
pyenv install $PYTHON
# I would expect something like ``pyenv init; pyenv local $PYTHON`` or
# ``pyenv shell $PYTHON`` would work, but ``pyenv init`` doesn't seem to
# modify the Bash environment. ??? So, I hand-set the variables instead.
export PYENV_VERSION=$PYTHON
export PATH="/Users/travis/.pyenv/shims:${PATH}"
pyenv-virtualenv venv
source venv/bin/activate
# A manual check that the correct version of Python is running.
pip install --upgrade setuptools
python --version
fi
install:
- cd web
- pip install -r requirements.txt
- python setup.py install
# command to run tests
#script:
# - pytest
script:
- nose2 --with-coverage -v

after_success:
- coveralls
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[![Build Status](https://travis-ci.org/qresp-code-development/qresp.svg?branch=master)](https://travis-ci.org/qresp-code-development/qresp)
[![Coverage Status](https://coveralls.io/repos/github/qresp-code-development/qresp/badge.svg?branch=master)](https://coveralls.io/github/qresp-code-development/qresp?branch=master)
# Qresp
[Qresp](http://qresp.org) software repository.

Expand Down
2 changes: 1 addition & 1 deletion docker-compose.override.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ services:
- MAIL_PWD=<administrators password>
volumes:
- ./web/:/usr/src/app/web
command: flask run --host=0.0.0.0 --port 8080
command: python run.py --host=0.0.0.0 --port 8080
45 changes: 45 additions & 0 deletions docker-compose.yml.services
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
version: '2'

services:
web:
restart: always
build: ./web
expose:
- 8080
ports:
- "8080:8080"
volumes:
- ./web/:/usr/src/app/web
environment:
- KEY=<insert key>
- GOOGLE_CLIENT_ID=<insert google client id>
- GOOGLE_CLIENT_SECRET=<insert google client secret>
- REDIRECT_URI=<insert redirect uri>
- MAIL_ADDR=<administrators mail address>
- MAIL_PWD=<administrators password>
command: python run.py --host=0.0.0.0 --port 8080

nginx:
restart: always
build: ./nginx
ports:
- "8001:8001"
volumes:
- /www/static
- ./papercollection:/usr/src/files
volumes_from:
- web
depends_on:
- web

mongodb:
image: mongo:latest
container_name: "mongodb"
environment:
- MONGO_DATA_DIR=/usr/data/db
- MONGO_LOG_DIR=/dev/null
volumes:
- ./data/db:/usr/data/db
ports:
- 27017:27017
command: mongod --smallfiles --logpath=/dev/null # --quiet
3 changes: 2 additions & 1 deletion web/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
recursive-include project/templates *
recursive-include project/static *
recursive-include project/static *
include project/swagger.yml
8 changes: 7 additions & 1 deletion web/project/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from flask_session import Session
from flask_wtf import CSRFProtect
from flask_sitemap import Sitemap
import connexion

GOOGLE_CLIENT_ID = os.environ.get("GOOGLE_CLIENT_ID")
GOOGLE_CLIENT_SECRET = os.environ.get("GOOGLE_CLIENT_SECRET")
Expand All @@ -21,9 +22,14 @@
MONGODB_PASSWORD = os.environ.get("MONGODB_PASSWORD")
MONGODB_DB = os.environ.get("MONGODB_DB")

# Create the application instance
connexionapp = connexion.App(__name__, specification_dir='./')

app = Flask(__name__)
# Read the swagger.yml file to configure the endpoints
connexionapp.add_api('swagger.yml')
app = connexionapp.app
app.secret_key = '\\\xfcS\x1e\x8f\xfb]6\x1e.\xa8\xb3\xe1x\xc8\x8e\xc1\xeb5^x\x81\xcc\xd5'

csrf = CSRFProtect(app)
SESSION_TYPE = 'filesystem'
app.config.from_object(__name__)
Expand Down
14 changes: 12 additions & 2 deletions web/project/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@
# For desktop version running from command line

from flask import Flask
app = Flask(__name__,template_folder='project/templates')
import connexion
# Create the application instance
connexionapp = connexion.App(__name__, specification_dir='./')

# Read the swagger.yml file to configure the endpoints
connexionapp.add_api('swagger.yml')
app = connexionapp.app
from .routes import main
main()
import sys
port = 80
if len(sys.argv)>1:
port = sys.argv[1]
main(port)
122 changes: 122 additions & 0 deletions web/project/api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
from .paperdao import *

#edit swagger.yml file for method changes

def search(searchWord=None,paperTitle=None,doi=None,tags=None,collectionList=None,authorsList=None,publicationList=None):
"""
This function responds to a request for /api/search
with the complete lists of papers
:return: list of papers
"""
allpaperslist = []
try:
dao = PaperDAO()
if collectionList:
collectionList = collectionList.split(",")
if authorsList:
authorsList = authorsList.split(",")
if publicationList:
publicationList = publicationList.split(",")
allpaperslist = dao.getAllFilteredSearchObjects(searchWord=searchWord,paperTitle=paperTitle,doi=doi,
tags=tags,collectionList=collectionList,
authorsList=authorsList,publicationList=publicationList)
except Exception as e:
print("Exception in search", e)
return allpaperslist

def collections():
"""
This function responds to a request for /api/collections
with the complete lists of c
:return: list of collections
"""
allcollectionlist = []
try:
dao = PaperDAO()
allcollectionlist = dao.getCollectionList()
except Exception as e:
print("Exception in ", e)
return list(allcollectionlist)

def authors():
"""
This function responds to a request for /api/authors
with the complete lists of authors
:return: list of authors
"""
allauthorlist = []
try:
dao = PaperDAO()
allauthorlist = dao.getAuthorList()
except Exception as e:
print("Exception in ", e)
return list(allauthorlist)

def publications():
"""
This function responds to a request for /api/publications
with the complete lists of publications
:return: list of publications
"""
allpublist = []
try:
dao = PaperDAO()
allpublist = dao.getPublicationList()
except Exception as e:
print("Exception in ", e)
return list(allpublist)

def paper(id):
"""
This function responds to a request for /api/paper/{id}
with the details of paper given id
:return: paper details object
"""
paperdetail = None
try:
dao = PaperDAO()
paperdetail = dao.getPaperDetails(id)
except Exception as e:
msg = "Exception in paper api " + str(e)
print("Exception in paper api ", e)
return e, 400
return paperdetail

def workflow(id):
"""
This function responds to a request for /api/workflow/{id}
with the workflow given id
:return: workflow object
"""
workflowdetail = None
try:
dao = PaperDAO()
workflowdetail = dao.getWorkflowDetails(id)
except Exception as e:
msg = "Exception in workflow api " + str(e)
print("Exception in workflow api ", e)
return msg,400
return workflowdetail

def chart(id,cid):
"""
This function responds to a request for /api/paper/{id}/chart/{cid}
with the chart given id
:return: chart object
"""
chartworkflowdetail = None
try:
dao = PaperDAO()
chartworkflowdetail = dao.getWorkflowForChartDetails(id, cid)
except Exception as e:
msg = "Exception in chart api " + str(e)
print("Exception in chart api ", e)
return msg,400
return chartworkflowdetail
4 changes: 2 additions & 2 deletions web/project/db.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from flask_mongoengine import MongoEngine
from pymongo import errors

from project import app
from project import connexionapp
app = connexionapp.app

class MongoDBConnection():
"""Class representing connection to Mongo database
Expand Down
6 changes: 6 additions & 0 deletions web/project/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,12 @@ def year(self):
def year(self, val):
self.__year = val

def __hash__(self):
return hash(self.__title)

def __eq__(self, other):
return self.__title == other.__title


class PaperDetails(object):
def __init__(self):
Expand Down
Loading

0 comments on commit 4a93841

Please sign in to comment.