|
import subprocess |
|
import time |
|
import threading |
|
import gradio as gr |
|
from datetime import datetime |
|
import math |
|
from gradio_client import Client |
|
|
|
def log_message(message): |
|
|
|
print(f"{datetime.now().strftime('%Y-%m-%d %H:%M:%S')} - {message}") |
|
|
|
|
|
def useless_computation(): |
|
client = Client("bluuebunny/update_arxiv_embeddings") |
|
result = client.predict( |
|
name="Hello!!", |
|
api_name="/predict" |
|
) |
|
print(result) |
|
|
|
|
|
def run_script_periodically(): |
|
|
|
|
|
time.sleep(10) |
|
|
|
while True: |
|
|
|
current_day = datetime.now().weekday() |
|
|
|
if current_day == 0: |
|
|
|
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() |
|
|