Spaces:
Sleeping
Sleeping
Download app.py from upwds/quick-tools: direct link, hf CLI and curl.
- Browser
- Download file 2.66 kB
-
https://huggingface.co/spaces/upwds/quick-tools/resolve/main/app.py
- Command line
-
hf download hf://spaces/upwds/quick-tools/app.py
-
curl -L -o app.py https://huggingface.co/spaces/upwds/quick-tools/resolve/main/app.py
2.66 kB
| import gradio as gr | |
| from json_2_incr_ddl import get_ddl_results | |
| from hive_copyfields_extract import get_extract_fields | |
| def point_2_ddl(topic_name, biz_name, json_example): | |
| return get_ddl_results(topic_name, biz_name, json_example) | |
| def hive_copy_fields_2_str(hive_copy_str): | |
| return get_extract_fields(hive_copy_str) | |
| with gr.Blocks() as demo: | |
| json_str = ''' | |
| { | |
| "Email": "835610010@qq.com", | |
| "UseType": 946, | |
| "Lang": 2, | |
| "Sub": "22", | |
| "HtmlBody": "22", | |
| "HasBody": true | |
| } | |
| ''' | |
| hue_fields = ''' | |
| fid (bigint) | |
| fuserid (bigint) | |
| froomid (bigint) | |
| ftype (int) | |
| fcount (int) | |
| frecordtime (timestamp) | |
| fcreatetime (timestamp) | |
| fmodifytime (timestamp) | |
| ''' | |
| with gr.Tab("根据json生成ddl"): | |
| with gr.Row(): | |
| with gr.Column(): | |
| json_input = [ | |
| gr.Text(label="topic名称", placeholder="Email_Send_Topic"), | |
| gr.Text(label="业务线名称", placeholder="ludo"), | |
| gr.Text(label="Json类埋点单条示例", lines=6, placeholder=json_str) | |
| ] | |
| json_button = gr.Button("Click") | |
| with gr.Column(): | |
| ddl_output = [ | |
| gr.Text(label="incr表", show_copy_button=True, text_align="left"), | |
| gr.Text(label="incr_text表", show_copy_button=True, text_align="left"), | |
| gr.Text(label="incr_explode表", show_copy_button=True, text_align="left"), | |
| gr.Text(label="explode sql", show_copy_button=True, text_align="left"), | |
| gr.Text(label="azkaban job", show_copy_button=True, text_align="left") | |
| ] | |
| json_button.click(point_2_ddl, inputs=json_input, outputs=ddl_output) | |
| with gr.Tab("根据hue复制字段生成特定字串"): | |
| with gr.Row(): | |
| with gr.Column(): | |
| hue_input = gr.Text(label="从hue中复制的字段内容", placeholder=hue_fields, lines=10) | |
| hue_button = gr.Button("Click") | |
| with gr.Column(): | |
| fields_output = [ | |
| gr.Text(label="不带“,”的字段", show_copy_button=True, text_align="left"), | |
| gr.Text(label="带“,”的字段", show_copy_button=True, text_align="left"), | |
| gr.Text(label="没有换行符的字段", show_copy_button=True, text_align="left"), | |
| gr.Text(label="特殊字段", show_copy_button=True, text_align="left") | |
| ] | |
| hue_button.click(hive_copy_fields_2_str, inputs=hue_input, outputs=fields_output) | |
| demo.launch(debug=True) | |