diff options
| author | Frederick Muriuki Muriithi | 2025-10-22 13:27:54 -0500 |
|---|---|---|
| committer | Frederick Muriuki Muriithi | 2025-10-22 13:27:54 -0500 |
| commit | 05013c13710eccadb69746bf186eb672c2af69c4 (patch) | |
| tree | 71a706fd30bf0d535a0fab737bb0e42a1667e60b /gn3/computations/rust_correlation.py | |
| parent | 977efbb54da284fb3e8476f200206d00cb8e64cd (diff) | |
| download | genenetwork3-05013c13710eccadb69746bf186eb672c2af69c4.tar.gz | |
Fetch configs from app setting and pass them down
Fix the code to avoid using global variables holding configuration variables to avoid the failures caused by action-at-a-distance effects due to change of a value elsewhere. This way, all code consistently receives the same configuration values passed on from callers. We pass on the following configuration settings: * TMPDIR * SQL_URI * TEXTDIR
Diffstat (limited to 'gn3/computations/rust_correlation.py')
| -rw-r--r-- | gn3/computations/rust_correlation.py | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/gn3/computations/rust_correlation.py b/gn3/computations/rust_correlation.py index d1ad3bc..359b73a 100644 --- a/gn3/computations/rust_correlation.py +++ b/gn3/computations/rust_correlation.py @@ -13,11 +13,10 @@ from flask import current_app from gn3.computations.qtlreaper import create_output_directory from gn3.chancy import random_string -from gn3.settings import TMPDIR -def generate_input_files(dataset: list[str], - output_dir: str = TMPDIR) -> tuple[str, str]: +def generate_input_files( + dataset: list[str], output_dir: str) -> tuple[str, str]: """function generates outputfiles and inputfiles""" tmp_dir = f"{output_dir}/correlation" create_output_directory(tmp_dir) @@ -50,17 +49,23 @@ def generate_json_file( def run_correlation( - dataset, trait_vals: str, method: str, delimiter: str, - corr_type: str = "sample", top_n: int = 500): + dataset, + trait_vals: str, + method: str, + delimiter: str, + tmpdir: str, + corr_type: str = "sample", + top_n: int = 500 +): """entry function to call rust correlation""" # pylint: disable=[too-many-arguments, too-many-positional-arguments] correlation_command = current_app.config["CORRELATION_COMMAND"] # make arg? - (tmp_dir, tmp_file) = generate_input_files(dataset) + (tmp_dir, tmp_file) = generate_input_files(dataset, tmpdir) (output_file, json_file) = generate_json_file( tmp_dir=tmp_dir, tmp_file=tmp_file, method=method, delimiter=delimiter, x_vals=trait_vals) - command_list = [correlation_command, json_file, TMPDIR] + command_list = [correlation_command, json_file, tmpdir] try: subprocess.run(command_list, check=True, capture_output=True) except subprocess.CalledProcessError as cpe: |
