Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -6,6 +6,7 @@ import gradio as gr
|
|
| 6 |
import huggingface_hub
|
| 7 |
import torch
|
| 8 |
import yaml
|
|
|
|
| 9 |
|
| 10 |
has_gpu = torch.cuda.is_available()
|
| 11 |
|
|
@@ -78,28 +79,10 @@ def merge(
|
|
| 78 |
|
| 79 |
with tempfile.TemporaryDirectory() as tmpdirname:
|
| 80 |
tmpdir = pathlib.Path(tmpdirname)
|
| 81 |
-
output += f"About to start merging in directory {tmpdir}\n\n"
|
| 82 |
-
yield output
|
| 83 |
with open(tmpdir / "config.yaml", "w", encoding="utf-8") as f:
|
| 84 |
f.write(yaml_config)
|
| 85 |
-
|
| 86 |
-
yield
|
| 87 |
-
|
| 88 |
-
cmd = cli.split()
|
| 89 |
-
popen = subprocess.Popen(
|
| 90 |
-
cmd,
|
| 91 |
-
cwd=tmpdir,
|
| 92 |
-
stdout=subprocess.PIPE,
|
| 93 |
-
stderr=subprocess.STDOUT,
|
| 94 |
-
universal_newlines=True,
|
| 95 |
-
)
|
| 96 |
-
for stdout_line in iter(popen.stdout.readline, ""):
|
| 97 |
-
output += stdout_line
|
| 98 |
-
yield output
|
| 99 |
-
popen.stdout.close()
|
| 100 |
-
return_code = popen.wait()
|
| 101 |
-
if return_code:
|
| 102 |
-
raise gr.Error(f"subprocess error: {return_code}")
|
| 103 |
|
| 104 |
## TODO(implement upload at the end of the merge, and display the repo URL)
|
| 105 |
|
|
@@ -128,7 +111,7 @@ demo = gr.Interface(
|
|
| 128 |
placeholder="optional, will create a random name if empty",
|
| 129 |
),
|
| 130 |
],
|
| 131 |
-
outputs=
|
| 132 |
allow_flagging="never",
|
| 133 |
submit_btn="Merge",
|
| 134 |
examples=examples,
|
|
|
|
| 6 |
import huggingface_hub
|
| 7 |
import torch
|
| 8 |
import yaml
|
| 9 |
+
from gradio_logsview import LogsView
|
| 10 |
|
| 11 |
has_gpu = torch.cuda.is_available()
|
| 12 |
|
|
|
|
| 79 |
|
| 80 |
with tempfile.TemporaryDirectory() as tmpdirname:
|
| 81 |
tmpdir = pathlib.Path(tmpdirname)
|
|
|
|
|
|
|
| 82 |
with open(tmpdir / "config.yaml", "w", encoding="utf-8") as f:
|
| 83 |
f.write(yaml_config)
|
| 84 |
+
|
| 85 |
+
yield from LogsView.run_process(cmd=cli.split())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 86 |
|
| 87 |
## TODO(implement upload at the end of the merge, and display the repo URL)
|
| 88 |
|
|
|
|
| 111 |
placeholder="optional, will create a random name if empty",
|
| 112 |
),
|
| 113 |
],
|
| 114 |
+
outputs=LogsView(),
|
| 115 |
allow_flagging="never",
|
| 116 |
submit_btn="Merge",
|
| 117 |
examples=examples,
|