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/wgcna.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/wgcna.py')
| -rw-r--r-- | gn3/computations/wgcna.py | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/gn3/computations/wgcna.py b/gn3/computations/wgcna.py index d1f7b32..3229a0e 100644 --- a/gn3/computations/wgcna.py +++ b/gn3/computations/wgcna.py @@ -7,17 +7,16 @@ import subprocess from pathlib import Path -from gn3.settings import TMPDIR from gn3.commands import run_cmd -def dump_wgcna_data(request_data: dict): +def dump_wgcna_data(request_data: dict, tmpdir: str): """function to dump request data to json file""" filename = f"{str(uuid.uuid4())}.json" - temp_file_path = os.path.join(TMPDIR, filename) + temp_file_path = os.path.join(tmpdir, filename) - request_data["TMPDIR"] = TMPDIR + request_data["TMPDIR"] = tmpdir with open(temp_file_path, "w", encoding="utf-8") as output_file: json.dump(request_data, output_file) @@ -65,9 +64,9 @@ def compose_wgcna_cmd(rscript_path: str, temp_file_path: str): return cmd -def call_wgcna_script(rscript_path: str, request_data: dict): +def call_wgcna_script(rscript_path: str, request_data: dict, tmpdir: str): """function to call wgcna script""" - generated_file = dump_wgcna_data(request_data) + generated_file = dump_wgcna_data(request_data, tmpdir) cmd = compose_wgcna_cmd(rscript_path, generated_file) # stream_cmd_output(request_data, cmd) disable streaming of data |
