diff options
author | BonfaceKilz | 2021-03-03 10:59:32 +0300 |
---|---|---|
committer | BonfaceKilz | 2021-03-08 21:09:58 +0300 |
commit | b7a57dc5a97403906ee43e2fecac641611cf5ab8 (patch) | |
tree | b7da01ae33f984f571dad31ed5b1e31ce4b920b3 | |
parent | 9dff9888f81b7eec0e698466518ce4cb55b8bd8c (diff) | |
download | genenetwork3-b7a57dc5a97403906ee43e2fecac641611cf5ab8.tar.gz |
Replace APP_DEFAULTS dict with actual conf params
-rw-r--r-- | gn3/api/gemma.py | 6 | ||||
-rw-r--r-- | gn3/api/general.py | 2 | ||||
-rw-r--r-- | gn3/file_utils.py | 1 | ||||
-rw-r--r-- | gn3/settings.py | 15 | ||||
-rw-r--r-- | tests/integration/test_gemma.py | 12 |
5 files changed, 16 insertions, 20 deletions
diff --git a/gn3/api/gemma.py b/gn3/api/gemma.py index 7c76f2f..a351ab1 100644 --- a/gn3/api/gemma.py +++ b/gn3/api/gemma.py @@ -19,7 +19,7 @@ gemma = Blueprint("gemma", __name__) @gemma.route("/version") def get_version(): """Display the installed version of gemma-wrapper""" - gemma_cmd = current_app.config['APP_DEFAULTS'].get('GEMMA_WRAPPER_CMD') + gemma_cmd = current_app.config["GEMMA_WRAPPER_CMD"] return jsonify( run_cmd(f"{gemma_cmd} -v | head -n 1")) @@ -34,7 +34,7 @@ file output is returned. """ data = request.get_json() - app_defaults = current_app.config.get('APP_DEFAULTS') + app_defaults = current_app.config __hash = generate_hash_of_string( f"{data.get('genofile_name')}_" ''.join(data.get("values", ""))) @@ -52,7 +52,7 @@ file output is returned. if data.get("loco"): gemma_wrapper_kwargs["loco"] = f"--input {data.get('loco')}" k_computation_cmd = generate_gemma_computation_cmd( - gemma_cmd=app_defaults.get("GEMMA_WRAPPER_CMD") + "_haha", + gemma_cmd=app_defaults.get("GEMMA_WRAPPER_CMD"), gemma_wrapper_kwargs={"loco": f"--input {data.get('loco')}"}, gemma_kwargs=gemma_kwargs, output_file=(f"{app_defaults.get('TMPDIR')}/gn2/" diff --git a/gn3/api/general.py b/gn3/api/general.py index 91a113c..d05d6f4 100644 --- a/gn3/api/general.py +++ b/gn3/api/general.py @@ -25,7 +25,7 @@ week. If a TOKEN is not provided, generate a token for the new user. status = 201 results = extract_uploaded_file( gzipped_file=file_, - target_dir=current_app.config["APP_DEFAULTS"].get("TMPDIR"), + target_dir=current_app.config["TMPDIR"], token=token) if results.get("status") > 0: status = 500 diff --git a/gn3/file_utils.py b/gn3/file_utils.py index ca80373..d5177b0 100644 --- a/gn3/file_utils.py +++ b/gn3/file_utils.py @@ -9,7 +9,6 @@ import tarfile from functools import partial from typing import Dict from werkzeug.utils import secure_filename -from gn3.settings import APP_DEFAULTS def get_dir_hash(directory: str) -> str: diff --git a/gn3/settings.py b/gn3/settings.py index ddff766..f5988bb 100644 --- a/gn3/settings.py +++ b/gn3/settings.py @@ -3,11 +3,10 @@ import tempfile import os -APP_DEFAULTS = { - "BCRYPT_SALT": "$2b$12$mxLvu9XRLlIaaSeDxt8Sle", # Change this! - "GEMMA_WRAPPER_CMD": os.environ.get("GEMMA_WRAPPER", "gemma-wrapper"), - "TMPDIR": os.environ.get("TMPDIR", tempfile.gettempdir()), - "GENODIR": "", - "REDIS_URI": "redis://localhost:6379/0", - "REDIS_JOB_QUEUE": "GN3::job-queue" -} +BCRYPT_SALT = "$2b$12$mxLvu9XRLlIaaSeDxt8Sle" # Change this! +DATA_DIR = "" +GEMMA_WRAPPER_CMD = os.environ.get("GEMMA_WRAPPER", "gemma-wrapper") +GENODIR = "" +REDIS_URI = "redis://localhost:6379/0" +REDIS_JOB_QUEUE = "GN3::job-queue" +TMPDIR = os.environ.get("TMPDIR", tempfile.gettempdir()) diff --git a/tests/integration/test_gemma.py b/tests/integration/test_gemma.py index deabcc4..e434dab 100644 --- a/tests/integration/test_gemma.py +++ b/tests/integration/test_gemma.py @@ -20,13 +20,11 @@ class GemmaAPITest(unittest.TestCase): """Test cases for the Gemma API""" def setUp(self): self.app = create_app({ - "APP_DEFAULTS": { - "GENODIR": os.path.abspath( - os.path.join(os.path.dirname(__file__), - "test_data/")), - "TMPDIR": "/tmp", - "REDIS_JOB_QUEUE": "GN3::job-queue", - "GEMMA_WRAPPER_CMD": "gemma-wrapper"}}).test_client() + "GENODIR": os.path.abspath( + os.path.join(os.path.dirname(__file__), + "test_data/")), + "REDIS_JOB_QUEUE": "GN3::job-queue", + "GEMMA_WRAPPER_CMD": "gemma-wrapper"}).test_client() @mock.patch("gn3.api.gemma.run_cmd") def test_get_version(self, mock_run_cmd): |