|
import subprocess |
|
import time |
|
import threading |
|
import gradio as gr |
|
from datetime import datetime |
|
import math |
|
|
|
def log_message(message): |
|
|
|
print(f"{datetime.now().strftime('%Y-%m-%d %H:%M:%S')} - {message}") |
|
|
|
|
|
def useless_computation(): |
|
for i in range(1000): |
|
math.sqrt(i) |
|
|
|
|
|
def run_script_periodically(): |
|
|
|
|
|
time.sleep(10) |
|
|
|
while True: |
|
|
|
current_day = datetime.now().weekday() |
|
|
|
if current_day == 5: |
|
|
|
log_message("Starting Updation") |
|
|
|
|
|
subprocess.run(["python", "update_embeddings.py"]) |
|
|
|
log_message("Finished Updation") |
|
|
|
|
|
time.sleep(60 * 60 * 24) |
|
|
|
else: |
|
|
|
print("Today is not Monday, lets check again in some.") |
|
|
|
useless_computation() |
|
|
|
|
|
time.sleep(60 * 60 * 1) |
|
|
|
|
|
def greet(name): |
|
return "Hello " + name + "!!" |
|
|
|
|
|
|
|
script_thread = threading.Thread(target=run_script_periodically) |
|
|
|
|
|
script_thread.start() |
|
|
|
demo = gr.Interface(fn=greet, inputs="text", outputs="text") |
|
demo.launch() |
|
|