From 84f5c8a4384f29dfcb187ac5eed43551860b182b Mon Sep 17 00:00:00 2001 From: Alexander Kabui Date: Tue, 5 Oct 2021 16:57:13 +0300 Subject: fix issues serializing byte string --- gn3/computations/wgcna.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'gn3') diff --git a/gn3/computations/wgcna.py b/gn3/computations/wgcna.py index 421e09c..4dd0985 100644 --- a/gn3/computations/wgcna.py +++ b/gn3/computations/wgcna.py @@ -33,8 +33,10 @@ def stream_cmd_output(socket, cmd: str): for line in iter(results.stdout.readline, b""): line = line.decode("utf-8").rstrip() + # xtodo emit the data -def process_image(image_loc: str) ->bytes: + +def process_image(image_loc: str) -> bytes: """encode the image""" try: @@ -65,8 +67,9 @@ def call_wgcna_script(rscript_path: str, request_data: dict): with open(generated_file, "r") as outputfile: output_file_data = json.load(outputfile) - output_file_data["image_data"] = process_image( - output_file_data["output"]["imageLoc"]) + # json format only supports unicode string// to get image data reconvert + output_file_data["output"]["image_data"] = process_image( + output_file_data["output"]["imageLoc"]).decode("ascii") if run_cmd_results["code"] != 0: return run_cmd_results -- cgit v1.2.3