diff options
author | Muriithi Frederick Muriuki | 2021-08-08 11:06:35 +0300 |
---|---|---|
committer | Muriithi Frederick Muriuki | 2021-08-08 11:06:35 +0300 |
commit | 0ec39e6c5058f4f06bfb5f763f51cd9dc176cb35 (patch) | |
tree | 2c9ea26f67e2a451343f4003fb67478baeb17ec2 | |
parent | a73d1ce388012758ce3b0d789f008e4184e6a38e (diff) | |
parent | e0476d51603432f60b6412b65486166deabe9e08 (diff) | |
download | genenetwork3-0ec39e6c5058f4f06bfb5f763f51cd9dc176cb35.tar.gz |
Merge branch 'main' of github.com:genenetwork/genenetwork3 into heatmap_decompose_db_retrieval
-rw-r--r-- | README.md | 41 | ||||
-rw-r--r-- | gn3/api/general.py | 3 | ||||
-rw-r--r-- | gn3/db/traits.py | 2 | ||||
-rw-r--r-- | guix.scm | 14 | ||||
-rw-r--r-- | main.py | 6 | ||||
-rw-r--r-- | wsgi.py | 11 |
6 files changed, 69 insertions, 8 deletions
@@ -11,7 +11,7 @@ Simply load up the environment (for development purposes): guix environment --load=guix.scm ``` -Also, make sure you have the *guix-bioinformatics* channel set up. +Also, make sure you have the [guix-bioinformatics](https://git.genenetwork.org/guix-bioinformatics/guix-bioinformatics) channel set up. ```bash env GUIX_PACKAGE_PATH=~/guix-bioinformatics/ ~/.config/guix/current/bin/guix environment --load=guix.scm @@ -22,9 +22,21 @@ python3 Better run a proper container ``` -env GUIX_PACKAGE_PATH=~/guix-bioinformatics/ ~/.config/guix/current/bin/guix environment -C --network --load=guix.scm +env GUIX_PACKAGE_PATH=~/guix-bioinformatics/ ~/.config/guix/current/bin/guix environment -C --network --load=guix.scm ``` +If you get a Guix error, such as `ice-9/boot-9.scm:1669:16: In procedure raise-exception: +error: python-sqlalchemy-stubs: unbound variable` it typically means an update to guix latest is required (i.e., guix pull): + +``` +guix pull +source ~/.config/guix/current/etc/profile +``` + +and try again. + +See also instructions in [.guix.scm](.guix.scm). + #### Running Tests (assuming you are in a guix container; otherwise use venv!) @@ -49,12 +61,33 @@ mypy . #### Running the flask app -To spin up the server: +To spin up the server on its own (for development): ```bash env FLASK_DEBUG=1 FLASK_APP="main.py" flask run --port=8080 ``` +And test with + +``` +curl localhost:8080/api/version +"1.0" +``` + +To run with gunicorn + +``` +gunicorn --bind 0.0.0.0:8080 wsgi:app +``` + +consider the following options for development `--bind 0.0.0.0:$SERVER_PORT --workers=1 --timeout 180 --reload wsgi`. + +And for the scalable production version run + +``` +gunicorn --bind 0.0.0.0:8080 --workers 8 --keep-alive 6000 --max-requests 10 --max-requests-jitter 5 --timeout 1200 wsgi:app +``` + ##### Using python-pip IMPORTANT NOTE: we do not recommend using pip tools, use Guix instead @@ -71,7 +104,7 @@ virtualenv --python python3 venv ```bash # The --ignore-installed flag forces packages to -# get installed in the venv even if they existed +# get installed in the venv even if they existed # in the global env pip install -r requirements.txt --ignore-installed ``` diff --git a/gn3/api/general.py b/gn3/api/general.py index cebb2e3..86fb7b7 100644 --- a/gn3/api/general.py +++ b/gn3/api/general.py @@ -11,6 +11,9 @@ from gn3.commands import run_cmd general = Blueprint("general", __name__) +@general.route("/version") +def version(): + return jsonify("1.0") @general.route("/metadata/upload/", methods=["POST"], strict_slashes=False) diff --git a/gn3/db/traits.py b/gn3/db/traits.py index 85cccfa..f66ead3 100644 --- a/gn3/db/traits.py +++ b/gn3/db/traits.py @@ -7,7 +7,7 @@ from gn3.db.datasets import retrieve_trait_dataset def get_trait_csv_sample_data(conn: Any, trait_name: int, phenotype_id: int): """Fetch a trait and return it as a csv string""" - sql = ("SELECT Strain.Id, PublishData.Id, Strain.Name, " + sql = ("SELECT DISTINCT Strain.Id, PublishData.Id, Strain.Name, " "PublishData.value, " "PublishSE.error, NStrain.count FROM " "(PublishData, Strain, PublishXRef, PublishFreeze) " @@ -17,6 +17,17 @@ ;;; You should have received a copy of the GNU General Public License ;;; along with genenetwork3. If not, see https://www.gnu.org/licenses/. +;; To use this file to build HEAD of gemma: +;; +;; env GUIX_PACKAGE_PATH=~/guix-bioinformatics/ guix build -f guix.scm +;; +;; After checking out the git repo +;; cd ~ ; git clone https://git.genenetwork.org/guix-bioinformatics/guix-bioinformatics +;; +;; To get a development container (e.g., run in emacs shell). +;; +;; env GUIX_PACKAGE_PATH=~/guix-bioinformatics/ guix environment -C -l guix.scm + (use-modules (srfi srfi-1) (srfi srfi-26) @@ -71,8 +82,9 @@ #:recursive? #t #:select? git-file?)) (propagated-inputs `(("coreutils" ,coreutils) - ("gemma-wrapper" ,gemma-wrapper) ("csvdiff" ,go-github-com-aswinkarthik-csvdiff) + ("gemma-wrapper" ,gemma-wrapper) + ("gunicorn" ,gunicorn) ("python" ,python-wrapper) ("python-bcrypt" ,python-bcrypt) ("python-flask" ,python-flask) @@ -2,6 +2,8 @@ from gn3.app import create_app - app = create_app() -app.run(host="0.0.0.0") + +if __name__ == '__main__': + print("Starting app...") + app.run() @@ -0,0 +1,11 @@ +# import main + +print("STARTING WSGI APP") + +from gn3.app import create_app + +app = create_app() + +if __name__ == "__main__": + print("Starting wsgi app...") + app.run() |