File size: 3,999 Bytes
e75a48e
7ba7074
 
 
 
 
 
d52d7a5
7ba7074
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
dfa8bc0
83eb289
7ba7074
 
 
 
dfa8bc0
 
7ba7074
 
dfa8bc0
f961b92
7ba7074
 
48ad9ce
998ddcc
 
 
d52d7a5
7ba7074
ee053e6
 
515fbbc
ee053e6
 
 
2ceea22
 
515fbbc
2ceea22
ece39d2
ee053e6
ece39d2
 
 
 
 
2ceea22
ece39d2
ee053e6
ece39d2
 
 
 
 
2ceea22
ece39d2
ee053e6
ece39d2
 
 
 
 
2ceea22
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7ba7074
ece39d2
 
 
 
 
 
d52d7a5
477fa16
ee053e6
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123

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

# Configure the logging functionality
log_file = Path("logs/") / f"data_{uuid.uuid4()}.json"
log_folder = log_file.parent

repo_id = "operand-logs"

# Create a commit scheduler
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

# Set-up the Gradio UI
textbox = gr.Textbox(label='Command')
# company = gr.Radio(label='Company:',
#                    choices=["aws", "google", "IBM", "Meta", "msft"],
#                    value="aws")

# Create Gradio interface
# Set-up the Gradio UI
textbox = gr.Textbox(label='Command')

# Create Gradio interface with tabs
with gr.Blocks(theme=gr.themes.Soft()) as operand:
    
    gr.Markdown("# operand")
    gr.Markdown("Data Studio")

    with gr.Tab("Data Source"):
        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("Data Set"):
        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("Data Transform"):
        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)

    with gr.Tab("Data Analysis"):
        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)

    with gr.Tab("Data Visualization"):
        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)

    with gr.Tab("Message"):
        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)

    with gr.Tab("Automation"):
        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)
        
# For the inputs parameter of Interface provide [textbox,company] with outputs parameter of Interface provide prediction
# demo = gr.Interface(fn=dprocess,
#                     inputs=[textbox],
#                     outputs="text",
#                     title="operand",
#                     description="Data Workbench CLI",
#                     theme=gr.themes.Soft())


operand.queue()
operand.launch()