bluuebunny commited on
Commit
e615cdd
·
verified ·
1 Parent(s): d3c1ddf

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +34 -0
app.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import subprocess # Run update_embeddings.py as subprocess
2
+ import time # Run update_embeddings.py periodically
3
+ import threading # in a separate thread
4
+ import gradio as gr # Create a Gradio interface so spaces doesnt timeout
5
+
6
+ # Function to run update_embeddings.py periodically
7
+ def run_script_periodically(interval):
8
+
9
+ # Wait for the Gradio server to start
10
+ time.sleep(10)
11
+
12
+ while True:
13
+
14
+ # Run run.py as a subprocess
15
+ subprocess.run(["python", "update_embeddings.py"]) # Use "python3" if needed
16
+
17
+ # Wait for the specified interval before running again
18
+ time.sleep(interval)
19
+
20
+ # Function to greet the user
21
+ def greet(name):
22
+ return "Hello " + name + "!!"
23
+
24
+ # Specify the interval (in seconds)
25
+ interval_seconds = 60*60*24*1 # Run run.py every day
26
+
27
+ # Create a thread to run the script periodically
28
+ script_thread = threading.Thread(target=run_script_periodically, args=(interval_seconds,))
29
+
30
+ # Start the thread
31
+ script_thread.start()
32
+
33
+ demo = gr.Interface(fn=greet, inputs="text", outputs="text")
34
+ demo.launch()