From 0ca5f01422883d97e42dd37e59ffacdcf9a65af9 Mon Sep 17 00:00:00 2001 From: Alexander Kabui Date: Thu, 23 Sep 2021 15:58:25 +0300 Subject: Return r error if returncode!=0 --- gn3/computations/wgcna.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'gn3/computations/wgcna.py') diff --git a/gn3/computations/wgcna.py b/gn3/computations/wgcna.py index 689bc2d..e9b76e8 100644 --- a/gn3/computations/wgcna.py +++ b/gn3/computations/wgcna.py @@ -22,6 +22,7 @@ def dump_wgcna_data(request_data: dict): def compose_wgcna_cmd(rscript_path: str, temp_file_path: str): """function to componse wgcna cmd""" + # (todo):issue relative paths to abs paths cmd = f"Rscript ./scripts/{rscript_path} {temp_file_path}" return cmd @@ -33,8 +34,16 @@ def call_wgcna_script(rscript_path: str, request_data: dict): try: - run_cmd(cmd) + run_cmd_results = run_cmd(cmd) + with open(generated_file, "r") as outputfile: - return results + + if run_cmd_results["code"] != 0: + return run_cmd_results + return { + "data": json.load(outputfile), + **run_cmd_results + } + # return json.load(outputfile) except Exception as error: raise error -- cgit v1.2.3