From aff6704cdcaea388f14b71cc013b1a224afb87fc Mon Sep 17 00:00:00 2001 From: Alexander Kabui Date: Tue, 5 Oct 2021 14:30:39 +0300 Subject: add function to capture output in real time --- gn3/computations/wgcna.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'gn3/computations') diff --git a/gn3/computations/wgcna.py b/gn3/computations/wgcna.py index fd508fa..0fb56e8 100644 --- a/gn3/computations/wgcna.py +++ b/gn3/computations/wgcna.py @@ -3,8 +3,9 @@ import os import json import uuid -from gn3.settings import TMPDIR +import subprocess +from gn3.settings import TMPDIR from gn3.commands import run_cmd @@ -20,6 +21,16 @@ def dump_wgcna_data(request_data: dict): return temp_file_path +def stream_cmd_output(socket, cmd: str): + """function to stream in realtime""" + # xtodo syncing and closing /edge cases + + results = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + for line in iter(results.stdout.readline, b""): + line = line.decode("utf-8").rstrip() + + def compose_wgcna_cmd(rscript_path: str, temp_file_path: str): """function to componse wgcna cmd""" # (todo):issue relative paths to abs paths -- cgit v1.2.3