import gradio as gr from gradio_log import Log from pipeline import run log_file = "out-file.txt" def run(): import subprocess import sys with open("out-file.txt", "w") as f: proc = subprocess.Popen( [f"{sys.executable}", "pipeline.py", "burtenshaw/yoga_nistra"], stdout=subprocess.PIPE, ) content = "" for line in proc.stdout: content = content.split("\n") content.append(line.decode("utf-8")) content = content[-10:] content = "\n".join(content) yield content import gradio as gr from huggingface_hub import whoami def hello(profile: gr.OAuthProfile | None) -> str: if profile is None: return "I don't know you." return f"Hello {profile.name}" def list_organizations(oauth_token: gr.OAuthToken | None) -> str: if oauth_token is None: return "Please log in to list organizations." org_names = [org["name"] for org in whoami(oauth_token.token)["orgs"]] return f"You belong to {', '.join(org_names)}." with gr.Blocks() as demo: gr.LoginButton() m1 = gr.Markdown() m2 = gr.Markdown() demo.load(hello, inputs=None, outputs=m1) demo.load(list_organizations, inputs=None, outputs=m2) button = gr.Button("Run pipeline") output = gr.Code(label="Terminal output", interactive=False) button.click(run, outputs=output) demo.launch()