Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# app.py
|
| 2 |
+
|
| 3 |
+
import gradio as gr
|
| 4 |
+
import subprocess
|
| 5 |
+
import os
|
| 6 |
+
import time
|
| 7 |
+
|
| 8 |
+
def run_pipeline():
|
| 9 |
+
"""
|
| 10 |
+
Runs the pipeline.sh script and yields its output line by line.
|
| 11 |
+
"""
|
| 12 |
+
# Make sure the script is executable
|
| 13 |
+
os.chmod("pipeline.sh", 0o755)
|
| 14 |
+
|
| 15 |
+
# Start the subprocess
|
| 16 |
+
process = subprocess.Popen(
|
| 17 |
+
["./pipeline.sh"],
|
| 18 |
+
stdout=subprocess.PIPE,
|
| 19 |
+
stderr=subprocess.STDOUT,
|
| 20 |
+
text=True,
|
| 21 |
+
bufsize=1,
|
| 22 |
+
universal_newlines=True,
|
| 23 |
+
)
|
| 24 |
+
|
| 25 |
+
# Yield each line of output from the script
|
| 26 |
+
yield "--- Pipeline Started ---\n"
|
| 27 |
+
for line in process.stdout:
|
| 28 |
+
yield line
|
| 29 |
+
time.sleep(0.05) # Small sleep to make streaming smooth
|
| 30 |
+
|
| 31 |
+
process.wait()
|
| 32 |
+
yield f"\n--- Pipeline Finished with exit code: {process.returncode} ---"
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
with gr.Blocks() as demo:
|
| 36 |
+
gr.Markdown("# 🚀 Bengali-Code LLM - Dev Pipeline Demonstrator")
|
| 37 |
+
gr.Markdown(
|
| 38 |
+
"This Space demonstrates the end-to-end development pipeline for the Bengali-Code LLM. "
|
| 39 |
+
"It runs in **Dev Mode** on a free CPU, using sample data and training a tiny ~1M parameter model. "
|
| 40 |
+
"Click the button below to start the run and see the live logs."
|
| 41 |
+
)
|
| 42 |
+
|
| 43 |
+
start_button = gr.Button("▶️ Start Pipeline Run", variant="primary")
|
| 44 |
+
|
| 45 |
+
console_output = gr.Textbox(
|
| 46 |
+
label="Live Console Output",
|
| 47 |
+
lines=25,
|
| 48 |
+
max_lines=25,
|
| 49 |
+
interactive=False,
|
| 50 |
+
autoscroll=True,
|
| 51 |
+
placeholder="Pipeline output will appear here..."
|
| 52 |
+
)
|
| 53 |
+
|
| 54 |
+
start_button.click(
|
| 55 |
+
fn=run_pipeline,
|
| 56 |
+
inputs=[],
|
| 57 |
+
outputs=[console_output]
|
| 58 |
+
)
|
| 59 |
+
|
| 60 |
+
demo.launch()
|