Spaces:
Running
Running
admin
commited on
Commit
·
ad841e1
1
Parent(s):
0a7ac7a
simplify envs
Browse files- modules/restart.py +10 -16
- modules/smtp.py +2 -2
- utils.py +1 -3
modules/restart.py
CHANGED
@@ -1,15 +1,7 @@
|
|
1 |
import requests
|
2 |
from huggingface_hub import HfApi
|
3 |
from modules.smtp import send_email
|
4 |
-
from utils import
|
5 |
-
HF_DOMAIN,
|
6 |
-
MS_DOMAIN,
|
7 |
-
HF_TK,
|
8 |
-
MS_HEADER,
|
9 |
-
TIMEOUT,
|
10 |
-
PUB_REPOS,
|
11 |
-
PRI_REPOS,
|
12 |
-
)
|
13 |
|
14 |
HF_API = HfApi(token=HF_TK)
|
15 |
|
@@ -25,8 +17,8 @@ def restart_private_studio(repo: str):
|
|
25 |
|
26 |
|
27 |
def restart_repos():
|
28 |
-
if
|
29 |
-
repos =
|
30 |
for repo in repos:
|
31 |
private_repo = repo.strip()
|
32 |
print(f"Restarting {private_repo} space & studio...")
|
@@ -34,12 +26,14 @@ def restart_repos():
|
|
34 |
HF_API.restart_space(private_repo)
|
35 |
|
36 |
|
37 |
-
def self_restart():
|
38 |
try:
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
HF_API.restart_space(
|
|
|
|
|
43 |
|
44 |
except Exception as e:
|
45 |
send_email(f"Failed to self-restart: {e}")
|
|
|
1 |
import requests
|
2 |
from huggingface_hub import HfApi
|
3 |
from modules.smtp import send_email
|
4 |
+
from utils import HF_DOMAIN, MS_DOMAIN, HF_TK, MS_HEADER, TIMEOUT, REPOS
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
HF_API = HfApi(token=HF_TK)
|
7 |
|
|
|
17 |
|
18 |
|
19 |
def restart_repos():
|
20 |
+
if REPOS:
|
21 |
+
repos = REPOS.split(";")
|
22 |
for repo in repos:
|
23 |
private_repo = repo.strip()
|
24 |
print(f"Restarting {private_repo} space & studio...")
|
|
|
26 |
HF_API.restart_space(private_repo)
|
27 |
|
28 |
|
29 |
+
def self_restart(me="kakamond/keeps_alive"):
|
30 |
try:
|
31 |
+
spaces = HF_API.list_spaces(author=me.split("/")[0])
|
32 |
+
for space in spaces:
|
33 |
+
if space.id != me:
|
34 |
+
HF_API.restart_space(space.id)
|
35 |
+
|
36 |
+
HF_API.restart_space(me)
|
37 |
|
38 |
except Exception as e:
|
39 |
send_email(f"Failed to self-restart: {e}")
|
modules/smtp.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
import requests
|
2 |
-
from utils import EMAIL, SMTP, TAG, HOST, PORT
|
3 |
|
4 |
|
5 |
def email_api(
|
@@ -21,7 +21,7 @@ def email_api(
|
|
21 |
</html>
|
22 |
"""
|
23 |
response = requests.get(
|
24 |
-
|
25 |
params={
|
26 |
"host": host,
|
27 |
"Port": port,
|
|
|
1 |
import requests
|
2 |
+
from utils import EMAIL, SMTP, TAG, HOST, PORT
|
3 |
|
4 |
|
5 |
def email_api(
|
|
|
21 |
</html>
|
22 |
"""
|
23 |
response = requests.get(
|
24 |
+
"http://api.mmp.cc/api/mail",
|
25 |
params={
|
26 |
"host": host,
|
27 |
"Port": port,
|
utils.py
CHANGED
@@ -2,9 +2,7 @@ import os
|
|
2 |
|
3 |
PERIOD = os.getenv("period")
|
4 |
USERS = os.getenv("users")
|
5 |
-
|
6 |
-
PRI_REPOS = os.getenv("pri_repos")
|
7 |
-
API = os.getenv("api")
|
8 |
EMAIL = os.getenv("email")
|
9 |
SMTP = os.getenv("smtp")
|
10 |
HF_TK = os.getenv("hftk")
|
|
|
2 |
|
3 |
PERIOD = os.getenv("period")
|
4 |
USERS = os.getenv("users")
|
5 |
+
REPOS = os.getenv("repos")
|
|
|
|
|
6 |
EMAIL = os.getenv("email")
|
7 |
SMTP = os.getenv("smtp")
|
8 |
HF_TK = os.getenv("hftk")
|