diff options
author | Frederick Muriuki Muriithi | 2023-06-15 14:40:37 +0300 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2023-06-20 13:36:50 +0300 |
commit | aa4d213692cb27a903fe1593e2dd3387e638b350 (patch) | |
tree | f41cfdf7e369cae767af5534cfc02c9998b9e4a2 /wqflask/base/data_set/utils.py | |
parent | a56d857dc1f6dbc25819a4af116139a2f3e14a68 (diff) | |
download | genenetwork2-aa4d213692cb27a903fe1593e2dd3387e638b350.tar.gz |
Configs: Introduce Blueprints. Refactor configs in webqtlConfig.
* Introduce flask Blueprints to help with decoupling the various
modules from the `wqflask/__init__.py` module
* Refactor settings: Create a function
`base.webqtlConfig.init_app(...)` to handle setting up the
configurations on the app correctly. Call this function at app
creation time.
* Move configuration utility functions from `utility.tools` module to
`utility.configuration` module.
* Use the `get_setting(...)` function to retrieve configuration
settings from the application.
Diffstat (limited to 'wqflask/base/data_set/utils.py')
-rw-r--r-- | wqflask/base/data_set/utils.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/wqflask/base/data_set/utils.py b/wqflask/base/data_set/utils.py index 703fee04..465538af 100644 --- a/wqflask/base/data_set/utils.py +++ b/wqflask/base/data_set/utils.py @@ -6,9 +6,9 @@ import json import hashlib from typing import List +from flask import current_app as app -from utility.tools import SQL_URI -from base.webqtlConfig import TMPDIR +from utility.configuration import get_setting from wqflask.database import parse_db_url, database_connection def geno_mrna_confidentiality(ob): @@ -27,7 +27,7 @@ def query_table_timestamp(dataset_type: str): # computation data and actions with database_connection() as conn, conn.cursor() as cursor: - fetch_db_name = parse_db_url(SQL_URI) + fetch_db_name = parse_db_url(get_setting("SQL_URI")) cursor.execute( "SELECT UPDATE_TIME FROM " "information_schema.tables " @@ -57,7 +57,7 @@ def cache_dataset_results(dataset_name: str, dataset_type: str, samplelist: List samplelist_as_str = ",".join(samplelist) file_name = generate_hash_file(dataset_name, dataset_type, table_timestamp, samplelist_as_str) - file_path = os.path.join(TMPDIR, f"{file_name}.json") + file_path = os.path.join(app.config["WEBQTL_TMPDIR"], f"{file_name}.json") with open(file_path, "w") as file_handler: json.dump(query_results, file_handler) @@ -70,7 +70,7 @@ def fetch_cached_results(dataset_name: str, dataset_type: str, samplelist: List) samplelist_as_str = ",".join(samplelist) file_name = generate_hash_file(dataset_name, dataset_type, table_timestamp, samplelist_as_str) - file_path = os.path.join(TMPDIR, f"{file_name}.json") + file_path = os.path.join(app.config["WEBQTL_TMPDIR"], f"{file_name}.json") try: with open(file_path, "r") as file_handler: |