Update run.py
Browse files
run.py
CHANGED
@@ -1,49 +1,47 @@
|
|
1 |
-
import sys
|
2 |
-
root_dir = __file__.rsplit("/", 1)[0]
|
3 |
-
if root_dir not in sys.path:
|
4 |
-
sys.path.append(root_dir)
|
5 |
-
|
6 |
-
import gradio as gr
|
7 |
-
import asyncio
|
8 |
-
import os
|
9 |
-
|
10 |
-
from demo.modules.search import build_search_module
|
11 |
-
from demo.modules.compute_score import build_score_computation
|
12 |
-
from demo.modules.tmalign import build_TMalign
|
13 |
-
|
14 |
-
|
15 |
-
# Build demo
|
16 |
-
with gr.Blocks() as demo:
|
17 |
-
build_search_module()
|
18 |
-
build_score_computation()
|
19 |
-
build_TMalign()
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
stdout=
|
27 |
-
stderr=
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
# Run the demo
|
49 |
-
demo.launch()
|
|
|
1 |
+
import sys
|
2 |
+
root_dir = __file__.rsplit("/", 1)[0]
|
3 |
+
if root_dir not in sys.path:
|
4 |
+
sys.path.append(root_dir)
|
5 |
+
|
6 |
+
import gradio as gr
|
7 |
+
import asyncio
|
8 |
+
import os
|
9 |
+
|
10 |
+
# from demo.modules.search import build_search_module
|
11 |
+
# from demo.modules.compute_score import build_score_computation
|
12 |
+
# from demo.modules.tmalign import build_TMalign
|
13 |
+
|
14 |
+
|
15 |
+
# Build demo
|
16 |
+
with gr.Blocks() as demo:
|
17 |
+
# build_search_module()
|
18 |
+
# build_score_computation()
|
19 |
+
# build_TMalign()
|
20 |
+
|
21 |
+
import gradio as gr
|
22 |
+
import subprocess
|
23 |
+
|
24 |
+
|
25 |
+
def run_command(cmd: str) -> str:
|
26 |
+
p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
27 |
+
stdout, stderr = p.communicate()
|
28 |
+
|
29 |
+
if stdout:
|
30 |
+
return f"[Output]\n{stdout.decode()}"
|
31 |
+
if stderr:
|
32 |
+
return f"[Error]\n{stderr.decode()}"
|
33 |
+
|
34 |
+
|
35 |
+
# Build the block for command line interface
|
36 |
+
gr.Markdown(f"# Input your command and click to run")
|
37 |
+
with gr.Column():
|
38 |
+
cmd = gr.Textbox(label="Input your command", value="echo 'Hello, World!'")
|
39 |
+
btn = gr.Button(value="Run")
|
40 |
+
output = gr.TextArea(label="Output", interactive=False)
|
41 |
+
|
42 |
+
btn.click(run_command, inputs=[cmd], outputs=[output])
|
43 |
+
|
44 |
+
|
45 |
+
if __name__ == '__main__':
|
46 |
+
# Run the demo
|
47 |
+
demo.launch()
|
|
|
|