aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Kabui2021-10-05 14:30:39 +0300
committerBonfaceKilz2021-10-25 14:16:21 +0300
commitaff6704cdcaea388f14b71cc013b1a224afb87fc (patch)
tree1c4b44cf791b0b1a4c8afa3d8915855b9f57babe
parenta3d4bc848caa8021e14282bab1a13ca7aadeb82d (diff)
downloadgenenetwork3-aff6704cdcaea388f14b71cc013b1a224afb87fc.tar.gz
add function to capture output in real time
-rw-r--r--gn3/computations/wgcna.py13
1 files changed, 12 insertions, 1 deletions
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