From 286027a1c07c0bf6ca113715f87ee7f1380d09e0 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Fri, 16 Jun 2023 12:57:16 +0300 Subject: configs: Fix issues caught by mechanical-rob tests --- wqflask/base/data_set/utils.py | 2 +- wqflask/base/trait.py | 6 ++--- wqflask/base/webqtlConfig.py | 1 + wqflask/scripts/corr_compute.py | 3 ++- wqflask/wqflask/correlation/rust_correlation.py | 14 +++++------ .../wqflask/templates/correlation_error_page.html | 8 +++---- wqflask/wqflask/templates/correlation_page.html | 28 +++++++++++----------- wqflask/wqflask/templates/loading.html | 6 ++--- wqflask/wqflask/templates/loading_corrs.html | 6 ++--- wqflask/wqflask/templates/show_trait_details.html | 4 ++-- wqflask/wqflask/views.py | 2 +- 11 files changed, 41 insertions(+), 39 deletions(-) diff --git a/wqflask/base/data_set/utils.py b/wqflask/base/data_set/utils.py index 465538af..11391d69 100644 --- a/wqflask/base/data_set/utils.py +++ b/wqflask/base/data_set/utils.py @@ -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(get_setting("SQL_URI")) + fetch_db_name = parse_db_url(get_setting(app, "SQL_URI")) cursor.execute( "SELECT UPDATE_TIME FROM " "information_schema.tables " diff --git a/wqflask/base/trait.py b/wqflask/base/trait.py index 70afa2cc..3a52e889 100644 --- a/wqflask/base/trait.py +++ b/wqflask/base/trait.py @@ -172,13 +172,13 @@ class GeneralTrait: alias = 'Not available' if self.symbol: human_response = requests.get( - get_setting("GN2_BASE_URL") + "gn3/gene/aliases/" + + get_setting(app, "GN2_BASE_URL") + "gn3/gene/aliases/" + self.symbol.upper()) mouse_response = requests.get( - get_setting("GN2_BASE_URL") + "gn3/gene/aliases/" + + get_setting(app, "GN2_BASE_URL") + "gn3/gene/aliases/" + self.symbol.capitalize()) other_response = requests.get( - get_setting("GN2_BASE_URL") + "gn3/gene/aliases/" + + get_setting(app, "GN2_BASE_URL") + "gn3/gene/aliases/" + self.symbol.lower()) if human_response and mouse_response and other_response: diff --git a/wqflask/base/webqtlConfig.py b/wqflask/base/webqtlConfig.py index 296bd314..600c6800 100644 --- a/wqflask/base/webqtlConfig.py +++ b/wqflask/base/webqtlConfig.py @@ -93,6 +93,7 @@ def init_app(app): TEMPDIR, child) WEBQTL_TMPDIR = mkdir_with_temp_dir("/gn2/") app.config["WEBQTL_TMPDIR"] = WEBQTL_TMPDIR + app.config["TMPDIR"] = WEBQTL_TMPDIR app.config["WEBQTL_CACHEDIR"] = mkdir_with_temp_dir( f"{WEBQTL_TMPDIR}cache/") diff --git a/wqflask/scripts/corr_compute.py b/wqflask/scripts/corr_compute.py index c98a66a4..c55559cd 100644 --- a/wqflask/scripts/corr_compute.py +++ b/wqflask/scripts/corr_compute.py @@ -8,7 +8,8 @@ import datetime from flask import g -from wqflask import app +from gn2_main import app + from wqflask.user_session import UserSession from wqflask.correlation.show_corr_results import set_template_vars from wqflask.correlation.correlation_gn3_api import compute_correlation diff --git a/wqflask/wqflask/correlation/rust_correlation.py b/wqflask/wqflask/correlation/rust_correlation.py index cd3af26f..1285b740 100644 --- a/wqflask/wqflask/correlation/rust_correlation.py +++ b/wqflask/wqflask/correlation/rust_correlation.py @@ -32,7 +32,7 @@ def query_probes_metadata(dataset, trait_list): if not bool(trait_list) or dataset.type != "ProbeSet": return [] - with database_connection(get_setting("SQL_URI")) as conn: + with database_connection(get_setting(app, "SQL_URI")) as conn: with conn.cursor() as cursor: query = """ @@ -108,7 +108,7 @@ def chunk_dataset(dataset, steps, name): ProbeSetXRef.ProbeSetId = ProbeSet.Id """.format(name) - with database_connection(get_setting("SQL_URI")) as conn: + with database_connection(get_setting(app, "SQL_URI")) as conn: with conn.cursor() as curr: curr.execute(query) traits_name_dict = dict(curr.fetchall()) @@ -132,7 +132,7 @@ def compute_top_n_sample(start_vars, dataset, trait_list): sample_data=json.loads(samples_vals), dataset_samples=dataset.group.all_samples_ordered()) - with database_connection(get_setting("SQL_URI")) as conn: + with database_connection(get_setting(app, "SQL_URI")) as conn: with conn.cursor() as curr: curr.execute( """ @@ -150,7 +150,7 @@ def compute_top_n_sample(start_vars, dataset, trait_list): if len(trait_list) == 0: return {} - with database_connection(get_setting("SQL_URI")) as conn: + with database_connection(get_setting(app, "SQL_URI")) as conn: with conn.cursor() as curr: # fetching strain data in bulk query = ( @@ -186,7 +186,7 @@ def compute_top_n_lit(corr_results, target_dataset, this_trait) -> dict: geneid_dict = {trait_name: geneid for (trait_name, geneid) in geneid_dict.items() if corr_results.get(trait_name)} - with database_connection(get_setting("SQL_URI")) as conn: + with database_connection(get_setting(app, "SQL_URI")) as conn: return reduce( lambda acc, corr: {**acc, **corr}, compute_all_lit_correlation( @@ -260,7 +260,7 @@ def __compute_sample_corr__( return {} if target_dataset.type == "ProbeSet" and start_vars.get("use_cache") == "true": - with database_connection(get_setting("SQL_URI")) as conn: + with database_connection(get_setting(app, "SQL_URI")) as conn: file_path = fetch_text_file(target_dataset.name, conn) if file_path: (sample_vals, target_data) = read_text_file( @@ -341,7 +341,7 @@ def __compute_lit_corr__( (this_trait_geneid, geneid_dict, species) = do_lit_correlation( this_trait, target_dataset) - with database_connection(get_setting("SQL_URI")) as conn: + with database_connection(get_setting(app, "SQL_URI")) as conn: return reduce( lambda acc, lit: {**acc, **lit}, compute_all_lit_correlation( diff --git a/wqflask/wqflask/templates/correlation_error_page.html b/wqflask/wqflask/templates/correlation_error_page.html index 7d11daf0..34f4c601 100644 --- a/wqflask/wqflask/templates/correlation_error_page.html +++ b/wqflask/wqflask/templates/correlation_error_page.html @@ -2,10 +2,10 @@ {%block title%}Correlation Results{%endblock%} {%block css%} - - - - + + + + {%endblock%} diff --git a/wqflask/wqflask/templates/correlation_page.html b/wqflask/wqflask/templates/correlation_page.html index 84fa4648..70b996db 100644 --- a/wqflask/wqflask/templates/correlation_page.html +++ b/wqflask/wqflask/templates/correlation_page.html @@ -1,10 +1,10 @@ {% extends "base.html" %} {% block title %}Correlation Results{% endblock %} {% block css %} - - - - + + + + {% endblock %} @@ -131,16 +131,16 @@ {% endblock %} {% block js %} - - - - - - - - - - + + + + + + + + + + diff --git a/wqflask/wqflask/templates/loading.html b/wqflask/wqflask/templates/loading.html index a6d9ae5e..35a58586 100644 --- a/wqflask/wqflask/templates/loading.html +++ b/wqflask/wqflask/templates/loading.html @@ -1,5 +1,5 @@