Update app.py
Browse files
app.py
CHANGED
@@ -9,7 +9,7 @@ def log_message(message):
|
|
9 |
print(f"{datetime.now().strftime('%Y-%m-%d %H:%M:%S')} - {message}")
|
10 |
|
11 |
# Function to run update_embeddings.py periodically
|
12 |
-
def run_script_periodically(
|
13 |
|
14 |
# Wait for the Gradio server to start
|
15 |
time.sleep(10)
|
@@ -18,7 +18,7 @@ def run_script_periodically(interval):
|
|
18 |
|
19 |
current_day = datetime.now().weekday() # Monday is 0, Sunday is 6
|
20 |
|
21 |
-
if current_day == 6: # Check if today is
|
22 |
|
23 |
log_message("Starting Updation")
|
24 |
|
@@ -28,24 +28,22 @@ def run_script_periodically(interval):
|
|
28 |
log_message("Finished Updation")
|
29 |
|
30 |
# Wait for the specified interval before running again
|
31 |
-
time.sleep(
|
32 |
|
33 |
else:
|
34 |
|
35 |
-
print("Today is not
|
36 |
|
37 |
-
# Wait
|
38 |
-
time.sleep(60 * 60 *
|
39 |
|
40 |
# Function to greet the user
|
41 |
def greet(name):
|
42 |
return "Hello " + name + "!!"
|
43 |
|
44 |
-
# Specify the interval (in seconds)
|
45 |
-
interval_seconds = 60*60*24*1 # Once updated, sleep for a day
|
46 |
|
47 |
# Create a thread to run the script periodically
|
48 |
-
script_thread = threading.Thread(target=run_script_periodically
|
49 |
|
50 |
# Start the thread
|
51 |
script_thread.start()
|
|
|
9 |
print(f"{datetime.now().strftime('%Y-%m-%d %H:%M:%S')} - {message}")
|
10 |
|
11 |
# Function to run update_embeddings.py periodically
|
12 |
+
def run_script_periodically():
|
13 |
|
14 |
# Wait for the Gradio server to start
|
15 |
time.sleep(10)
|
|
|
18 |
|
19 |
current_day = datetime.now().weekday() # Monday is 0, Sunday is 6
|
20 |
|
21 |
+
if current_day == 6: # Check if today is Monday
|
22 |
|
23 |
log_message("Starting Updation")
|
24 |
|
|
|
28 |
log_message("Finished Updation")
|
29 |
|
30 |
# Wait for the specified interval before running again
|
31 |
+
time.sleep(60 * 60 * 24)
|
32 |
|
33 |
else:
|
34 |
|
35 |
+
print("Today is not Monday, lets check again in some.")
|
36 |
|
37 |
+
# Wait a bit
|
38 |
+
time.sleep(60 * 60 * 1)
|
39 |
|
40 |
# Function to greet the user
|
41 |
def greet(name):
|
42 |
return "Hello " + name + "!!"
|
43 |
|
|
|
|
|
44 |
|
45 |
# Create a thread to run the script periodically
|
46 |
+
script_thread = threading.Thread(target=run_script_periodically)
|
47 |
|
48 |
# Start the thread
|
49 |
script_thread.start()
|