|
|
|
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 process_command(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 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
with gr.Blocks(theme=gr.themes.Soft()) as operand: |
|
|
|
gr.Markdown("# operand") |
|
gr.Markdown("Data Studio<br><br>") |
|
|
|
with gr.Tab("Data Sources"): |
|
|
|
gr.Markdown("## Source") |
|
|
|
with gr.Accordion("Syntax"): |
|
gr.Markdown("<br>data_source my-ds-name1 my-ds-desc1 my-jira-endpoint1 my-jira-creds1") |
|
|
|
gr.Markdown("Instances of data sources e.g., Jira Cloud endpoint, Trello endpoint, Github endpoint") |
|
|
|
textbox_a = gr.Textbox(label='Command') |
|
output_a = gr.Textbox(label='Output') |
|
button_a = gr.Button("Submit") |
|
button_a.click(dprocess, inputs=[textbox_a], outputs=output_a) |
|
|
|
with gr.Tab("Set"): |
|
gr.Markdown("## Data Set") |
|
gr.Markdown("A data set from a data source.") |
|
textbox_b = gr.Textbox(label='Command') |
|
output_b = gr.Textbox(label='Output') |
|
button_b = gr.Button("Submit") |
|
button_b.click(dprocess, inputs=[textbox_b], outputs=output_b) |
|
|
|
with gr.Tab("Transform"): |
|
gr.Markdown("## Data Transform") |
|
gr.Markdown("A transformation of a data set into a new data set.") |
|
textbox_c = gr.Textbox(label='Command') |
|
output_c = gr.Textbox(label='Output') |
|
button_c = gr.Button("Submit") |
|
button_c.click(dprocess, inputs=[textbox_c], outputs=output_c) |
|
|
|
with gr.Tab("Analysis"): |
|
gr.Markdown("## Data Analysis") |
|
gr.Markdown("Statistical analysis of a data set e.g., slope calculation on feature") |
|
textbox_d = gr.Textbox(label='Command') |
|
output_d = gr.Textbox(label='Output') |
|
button_d = gr.Button("Submit") |
|
button_d.click(dprocess, inputs=[textbox_d], outputs=output_d) |
|
|
|
with gr.Tab("Visualization"): |
|
gr.Markdown("## Data Visualization") |
|
gr.Markdown("A visual insight from a data set or data analysis results e.g., matplotlib, sns, plotly") |
|
textbox_e = gr.Textbox(label='Command') |
|
output_e = gr.Textbox(label='Output') |
|
button_e = gr.Button("Submit") |
|
button_e.click(dprocess, inputs=[textbox_e], outputs=output_e) |
|
|
|
with gr.Tab("Notification"): |
|
gr.Markdown("## Notifications") |
|
gr.Markdown("Scheduled transmission of data set, data analysis or data visualization direct to user device") |
|
textbox_f = gr.Textbox(label='Command') |
|
output_f = gr.Textbox(label='Output') |
|
button_f = gr.Button("Submit") |
|
button_f.click(dprocess, inputs=[textbox_f], outputs=output_f) |
|
|
|
with gr.Tab("Automation"): |
|
gr.Markdown("## Automation") |
|
gr.Markdown("Multistep composition of functional elements") |
|
textbox_g = gr.Textbox(label='Command') |
|
output_g = gr.Textbox(label='Output') |
|
button_g = gr.Button("Submit") |
|
button_g.click(dprocess, inputs=[textbox_g], outputs=output_g) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
operand.queue() |
|
operand.launch() |