|
import subprocess |
|
import time |
|
import threading |
|
import gradio as gr |
|
from datetime import datetime |
|
|
|
def log_message(message): |
|
|
|
print(f"{datetime.now().strftime('%Y-%m-%d %H:%M:%S')} - {message}") |
|
|
|
|
|
def run_script_periodically(interval): |
|
|
|
|
|
time.sleep(10) |
|
|
|
while True: |
|
|
|
log_message("Starting Updation") |
|
|
|
|
|
subprocess.run(["python", "update_embeddings.py"]) |
|
|
|
log_message("Finished Updation") |
|
|
|
|
|
time.sleep(interval) |
|
|
|
|
|
def greet(name): |
|
return "Hello " + name + "!!" |
|
|
|
|
|
interval_seconds = 60*60*24*2 |
|
|
|
|
|
script_thread = threading.Thread(target=run_script_periodically, args=(interval_seconds,)) |
|
|
|
|
|
script_thread.start() |
|
|
|
demo = gr.Interface(fn=greet, inputs="text", outputs="text") |
|
demo.launch() |
|
|