Spaces:
Sleeping
Sleeping
File size: 1,837 Bytes
abdabaa 22ee398 abdabaa 22ee398 abdabaa 22ee398 abdabaa 22ee398 abdabaa 22ee398 abdabaa 22ee398 abdabaa 22ee398 abdabaa 22ee398 abdabaa 22ee398 abdabaa 22ee398 abdabaa 22ee398 abdabaa 22ee398 abdabaa 22ee398 abdabaa 22ee398 abdabaa 22ee398 abdabaa 22ee398 abdabaa 22ee398 abdabaa 22ee398 abdabaa 22ee398 abdabaa 22ee398 |
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 |
import subprocess
import warnings, os
warnings.filterwarnings("ignore")
os.environ["CURL_CA_BUNDLE"] = ""
from dotenv import load_dotenv
import gradio as gr
load_dotenv()
hf_token = os.environ["HF_TOKEN"]
SCRIPT_DOC = "tdoc_indexer.py"
SCRIPT_SPEC = "spec_indexer.py"
SCRIPT_BM25 = "bm25_maker.py"
def get_script_output(script_path, current_log=""):
accumulated_output = current_log
process = subprocess.Popen(
["python", script_path],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
bufsize=1,
universal_newlines=True
)
for line in process.stdout:
accumulated_output += line
yield accumulated_output
process.stdout.close()
process.wait()
yield accumulated_output
def index_tdocs():
log_output = "⏳ Indexation en cours...\n"
for log in get_script_output(SCRIPT_DOC):
yield log
log_output = log
log_output += "✅ Terminé.\n"
yield log_output
def index_specifications():
log_output = "⏳ Indexation en cours...\n"
for log in get_script_output(SCRIPT_SPEC):
yield log
log_output = log
for log in get_script_output(SCRIPT_BM25):
yield log
log_output = log
log_output += "✅ Terminé.\n"
yield log_output
with gr.Blocks(theme=gr.themes.Soft()) as demo:
gr.Markdown("# 📄 3GPP Indexer Main Menu")
with gr.Row() as r1:
with gr.Column():
tdocs_btn = gr.Button("Re-index TDocs", variant="primary")
with gr.Column():
spec_btn = gr.Button("Re-index Specifications", variant="primary")
out = gr.Textbox(label="Output", lines=25, autoscroll=True, interactive=False)
tdocs_btn.click(index_tdocs, outputs=[out])
spec_btn.click(index_specifications, outputs=[out])
demo.queue().launch() |