Spaces:
Paused
Paused
Added restart every 12 hours so logs don't get huge
Browse files- app.py +11 -1
- src/envs.py +1 -1
app.py
CHANGED
@@ -7,12 +7,21 @@ from apscheduler.schedulers.background import BackgroundScheduler
|
|
7 |
logging.basicConfig(level=logging.ERROR)
|
8 |
|
9 |
from src.logging import LOGGER, read_logs
|
|
|
10 |
|
11 |
sys.stdout = LOGGER
|
12 |
sys.stderr = LOGGER
|
13 |
|
|
|
14 |
def launch_backend():
|
|
|
15 |
_ = subprocess.run(["python", "main_backend_lighteval.py"])
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
|
17 |
demo = gr.Blocks()
|
18 |
with demo:
|
@@ -22,4 +31,5 @@ with demo:
|
|
22 |
scheduler = BackgroundScheduler()
|
23 |
scheduler.add_job(launch_backend, "interval", seconds=60) # will only allow one job to be run at the same time
|
24 |
scheduler.start()
|
25 |
-
demo.queue(default_concurrency_limit=40).launch()
|
|
|
|
7 |
logging.basicConfig(level=logging.ERROR)
|
8 |
|
9 |
from src.logging import LOGGER, read_logs
|
10 |
+
from src.envs import API, REPO_ID
|
11 |
|
12 |
sys.stdout = LOGGER
|
13 |
sys.stderr = LOGGER
|
14 |
|
15 |
+
COUNTER = 0
|
16 |
def launch_backend():
|
17 |
+
global COUNTER
|
18 |
_ = subprocess.run(["python", "main_backend_lighteval.py"])
|
19 |
+
COUNTER += 1
|
20 |
+
# every 720 seconds = 12 hours, restart the space
|
21 |
+
if COUNTER == 720:
|
22 |
+
COUNTER = 0
|
23 |
+
API.restart_space(repo_id=REPO_ID)
|
24 |
+
|
25 |
|
26 |
demo = gr.Blocks()
|
27 |
with demo:
|
|
|
31 |
scheduler = BackgroundScheduler()
|
32 |
scheduler.add_job(launch_backend, "interval", seconds=60) # will only allow one job to be run at the same time
|
33 |
scheduler.start()
|
34 |
+
demo.queue(default_concurrency_limit=40).launch()
|
35 |
+
|
src/envs.py
CHANGED
@@ -18,7 +18,7 @@ REGION = "us-east-1"
|
|
18 |
VENDOR = "aws"
|
19 |
# ----------------------------------
|
20 |
|
21 |
-
|
22 |
QUEUE_REPO = f"{OWNER}/requests"
|
23 |
RESULTS_REPO = f"{OWNER}/private-results"
|
24 |
|
|
|
18 |
VENDOR = "aws"
|
19 |
# ----------------------------------
|
20 |
|
21 |
+
REPO_ID = f"{OWNER}/backend"
|
22 |
QUEUE_REPO = f"{OWNER}/requests"
|
23 |
RESULTS_REPO = f"{OWNER}/private-results"
|
24 |
|