|
|
|
from warnings import filterwarnings |
|
filterwarnings('ignore') |
|
|
|
import os |
|
import uuid |
|
import json |
|
import gradio as gr |
|
import pandas as pd |
|
from huggingface_hub import CommitScheduler |
|
from pathlib import Path |
|
|
|
|
|
log_file = Path("logs/") / f"data_{uuid.uuid4()}.json" |
|
log_folder = log_file.parent |
|
|
|
repo_id = "operand-logs" |
|
|
|
|
|
scheduler = CommitScheduler( |
|
repo_id=repo_id, |
|
repo_type="dataset", |
|
folder_path=log_folder, |
|
path_in_repo="data", |
|
every=2 |
|
) |
|
|
|
def dprocess(command, ddddd): |
|
print('foo...') |
|
with scheduler.lock: |
|
with log_file.open("a") as f: |
|
f.write(json.dumps( |
|
{ |
|
'p1': 'foo', |
|
'p2': 100 |
|
} |
|
)) |
|
f.write("\n") |
|
return 42 |
|
|
|
|
|
textbox = gr.Textbox(label='Command') |
|
|
|
|
|
|
|
|
|
|
|
|
|
textbox = gr.Textbox(label='Command') |
|
|
|
|
|
with gr.Blocks(theme=gr.themes.Soft()) as operand: |
|
|
|
gr.Markdown("# Operand CLI") |
|
gr.Markdown("This application allows you to process commands for different companies.") |
|
|
|
with gr.Tab("Tab A"): |
|
gr.Markdown("## This is Tab A") |
|
gr.Markdown("Description for Tab A") |
|
textbox_a = gr.Textbox(label='Command A') |
|
output_a = gr.Textbox(label='Output A') |
|
button_a = gr.Button("Submit A") |
|
button_a.click(dprocess, inputs=[textbox_a], outputs=output_a) |
|
|
|
with gr.Tab("Tab B"): |
|
gr.Markdown("## This is Tab B") |
|
gr.Markdown("Description for Tab B") |
|
textbox_b = gr.Textbox(label='Command B') |
|
output_b = gr.Textbox(label='Output B') |
|
button_b = gr.Button("Submit B") |
|
button_b.click(dprocess, inputs=[textbox_b], outputs=output_b) |
|
|
|
with gr.Tab("Tab C"): |
|
gr.Markdown("## This is Tab C") |
|
gr.Markdown("Description for Tab C") |
|
textbox_c = gr.Textbox(label='Command C') |
|
output_c = gr.Textbox(label='Output C') |
|
button_c = gr.Button("Submit C") |
|
button_c.click(dprocess, inputs=[textbox_c], outputs=output_c) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
operand.queue() |
|
operand.launch() |