|
import gradio as gr |
|
import json |
|
import ast |
|
|
|
def push_queue(CONFIG): |
|
return |
|
|
|
def wirte_config(CONFIG): |
|
CONFIG = ast.literal_eval(CONFIG) |
|
str = f""" |
|
******CONFIG UPDATE****** |
|
start_time: {CONFIG['start_time']} |
|
end_time: {CONFIG['end_time']} |
|
query: {CONFIG['query']} |
|
keywords: {CONFIG['keywords']} |
|
top_cluster: {CONFIG['top_cluster']} |
|
prompt: {CONFIG['prompt']} |
|
check_relevent: {CONFIG['check_relevent']} |
|
max_posts: {CONFIG['max_posts']} |
|
""" |
|
with open('/home2/cuongnguyen2/topic-clustering-global-dashboard/config_periodic.json', 'w') as f: |
|
json.dump(CONFIG, f, ensure_ascii= False) |
|
return str |
|
|
|
demo = gr.Blocks() |
|
|
|
def gradio_function(): |
|
with demo: |
|
gr.Markdown( |
|
""" |
|
# Flip Text! |
|
Start typing below to see the output. |
|
""" |
|
) |
|
with open('/home2/cuongnguyen2/topic-clustering-global-dashboard/config_periodic.json') as f: |
|
CONFIG = json.load(f) |
|
|
|
input1 = gr.Textbox(placeholder="Enter input", value=str(CONFIG)) |
|
|
|
|
|
|
|
output = gr.Textbox() |
|
|
|
|
|
gr.Button("Submit").click(fn=wirte_config, inputs=[input1], outputs=output) |
|
|
|
demo.launch(share=True) |
|
|
|
if __name__ == '__main__': |
|
gradio_function() |