# app.py import gradio as gr import subprocess import os import time def run_pipeline(): """ Runs the pipeline.sh script and yields its output line by line. """ # Make sure the script is executable os.chmod("pipeline.sh", 0o755) # Start the subprocess process = subprocess.Popen( ["./pipeline.sh"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True, bufsize=1, universal_newlines=True, ) # Yield each line of output from the script yield "--- Pipeline Started ---\n" for line in process.stdout: yield line time.sleep(0.05) # Small sleep to make streaming smooth process.wait() yield f"\n--- Pipeline Finished with exit code: {process.returncode} ---" with gr.Blocks() as demo: gr.Markdown("# 🚀 Bengali-Code LLM - Dev Pipeline Demonstrator") gr.Markdown( "This Space demonstrates the end-to-end development pipeline for the Bengali-Code LLM. " "It runs in **Dev Mode** on a free CPU, using sample data and training a tiny ~1M parameter model. " "Click the button below to start the run and see the live logs." ) start_button = gr.Button("▶️ Start Pipeline Run", variant="primary") console_output = gr.Textbox( label="Live Console Output", lines=25, max_lines=25, interactive=False, autoscroll=True, placeholder="Pipeline output will appear here..." ) start_button.click( fn=run_pipeline, inputs=[], outputs=[console_output] ) demo.launch()