Update ff1.py
Browse files
ff1.py
CHANGED
|
@@ -150,7 +150,7 @@ def create_space(type,key = "", value = "",name = ""):
|
|
| 150 |
}
|
| 151 |
payload = {
|
| 152 |
"organization": HF_USER2,
|
| 153 |
-
"name":
|
| 154 |
"type": "space"
|
| 155 |
}
|
| 156 |
response = requests.delete(url, headers=headers, json=payload)
|
|
@@ -191,10 +191,10 @@ def create_space(type,key = "", value = "",name = ""):
|
|
| 191 |
with open(file_path, "wb") as f:
|
| 192 |
f.write(response.content)
|
| 193 |
print("下载完成 ✅")
|
| 194 |
-
telegram_message(BOT_TOKEN, CHAT_ID, f"{HF_ID}下载Dockerfile 结果:下载完成 ✅")
|
| 195 |
else:
|
| 196 |
print(f"下载失败,状态码: {response.status_code}")
|
| 197 |
-
telegram_message(BOT_TOKEN, CHAT_ID, f"{HF_ID}下载Dockerfile下载失败,状态码: {response.status_code}")
|
| 198 |
|
| 199 |
# os.system(f"wget -O '/data/{tmp_name}/Dockerfile' https://huggingface.co/datasets/Qilan2/ff/raw/main/Dockerfile")
|
| 200 |
repo_path = f"/data/{name}"
|
|
@@ -531,9 +531,12 @@ def github(type):
|
|
| 531 |
# 轻度清理
|
| 532 |
os.system('git gc --auto')
|
| 533 |
os.system('git lfs prune')
|
| 534 |
-
telegram_message(BOT_TOKEN, CHAT_ID, f"{HF_ID}提交仓库{HF_REPO}结果:{file_size_info}")
|
|
|
|
|
|
|
| 535 |
else:
|
| 536 |
-
telegram_message(BOT_TOKEN, CHAT_ID, f"{HF_ID}
|
|
|
|
| 537 |
print("压缩失败,无法提交")
|
| 538 |
|
| 539 |
|
|
@@ -574,7 +577,8 @@ def check_system_resources():
|
|
| 574 |
response = create_space(1)
|
| 575 |
full_name = response["name"]
|
| 576 |
tmp_name = full_name.split("/")[-1]
|
| 577 |
-
log = f"“原始创建Space返回:{response} name字段:{full_name} Space 名称{tmp_name}"
|
|
|
|
| 578 |
telegram_message(BOT_TOKEN, CHAT_ID, log)
|
| 579 |
print(log)
|
| 580 |
create_space(3,"BACKUP_TIME",BACKUP_TIME,tmp_name)
|
|
@@ -596,7 +600,7 @@ def check_system_resources():
|
|
| 596 |
time.sleep(2)
|
| 597 |
result = restart_huggingface_space(HF_USER2, tmp_name, HF_TOKON2)
|
| 598 |
print(f"{tmp_name}重启结果:",result)
|
| 599 |
-
|
| 600 |
# result = restart_huggingface_space(HF_USER2, HF_ID, HF_TOKON2)
|
| 601 |
# print(result)
|
| 602 |
else:
|
|
@@ -620,11 +624,13 @@ if os.path.exists('/data/ff/.mozilla/firefox/profiles.ini') and os.path.isfile('
|
|
| 620 |
response = create_space(2)
|
| 621 |
print(response)
|
| 622 |
time.sleep(21600)#21600 = 6小时
|
| 623 |
-
|
| 624 |
response = create_space(1)
|
|
|
|
| 625 |
full_name = response["name"]
|
| 626 |
tmp_name = full_name.split("/")[-1]
|
| 627 |
-
log = f"“原始创建Space返回:{response} name字段:{full_name} Space 名称{tmp_name}"
|
|
|
|
| 628 |
telegram_message(BOT_TOKEN, CHAT_ID, log)
|
| 629 |
print(log)
|
| 630 |
create_space(3,"BACKUP_TIME",BACKUP_TIME,tmp_name)
|
|
@@ -646,7 +652,8 @@ if os.path.exists('/data/ff/.mozilla/firefox/profiles.ini') and os.path.isfile('
|
|
| 646 |
time.sleep(2)
|
| 647 |
result = restart_huggingface_space(HF_USER2, tmp_name, HF_TOKON2)
|
| 648 |
print(f"{tmp_name}重启结果:",result)
|
| 649 |
-
telegram_message(BOT_TOKEN, CHAT_ID, f"{HF_ID}
|
|
|
|
| 650 |
# result = restart_huggingface_space(HF_USER2, HF_ID, HF_TOKON2)
|
| 651 |
# print(result)
|
| 652 |
# break
|
|
|
|
| 150 |
}
|
| 151 |
payload = {
|
| 152 |
"organization": HF_USER2,
|
| 153 |
+
"name": name,
|
| 154 |
"type": "space"
|
| 155 |
}
|
| 156 |
response = requests.delete(url, headers=headers, json=payload)
|
|
|
|
| 191 |
with open(file_path, "wb") as f:
|
| 192 |
f.write(response.content)
|
| 193 |
print("下载完成 ✅")
|
| 194 |
+
# telegram_message(BOT_TOKEN, CHAT_ID, f"{HF_ID}下载Dockerfile 结果:下载完成 ✅")
|
| 195 |
else:
|
| 196 |
print(f"下载失败,状态码: {response.status_code}")
|
| 197 |
+
# telegram_message(BOT_TOKEN, CHAT_ID, f"{HF_ID}下载Dockerfile下载失败,状态码: {response.status_code}")
|
| 198 |
|
| 199 |
# os.system(f"wget -O '/data/{tmp_name}/Dockerfile' https://huggingface.co/datasets/Qilan2/ff/raw/main/Dockerfile")
|
| 200 |
repo_path = f"/data/{name}"
|
|
|
|
| 531 |
# 轻度清理
|
| 532 |
os.system('git gc --auto')
|
| 533 |
os.system('git lfs prune')
|
| 534 |
+
# telegram_message(BOT_TOKEN, CHAT_ID, f"{HF_ID}提交仓库{HF_REPO}结果:{file_size_info}")
|
| 535 |
+
telegram_message(BOT_TOKEN, CHAT_ID, f"{HF_ID} pushed repository {HF_REPO} result: {file_size_info}")
|
| 536 |
+
|
| 537 |
else:
|
| 538 |
+
telegram_message(BOT_TOKEN, CHAT_ID, f"{HF_ID} pushed repository {HF_REPO} result: compression failed, unable to submit")
|
| 539 |
+
# telegram_message(BOT_TOKEN, CHAT_ID, f"{HF_ID}提交仓库{HF_REPO}结果:压缩失败,无法提交")
|
| 540 |
print("压缩失败,无法提交")
|
| 541 |
|
| 542 |
|
|
|
|
| 577 |
response = create_space(1)
|
| 578 |
full_name = response["name"]
|
| 579 |
tmp_name = full_name.split("/")[-1]
|
| 580 |
+
# log = f"“原始创建Space返回:{response} name字段:{full_name} Space 名称{tmp_name}"
|
| 581 |
+
log = f"Original create Space response: {response} | name field: {full_name} | Space name: {tmp_name}"
|
| 582 |
telegram_message(BOT_TOKEN, CHAT_ID, log)
|
| 583 |
print(log)
|
| 584 |
create_space(3,"BACKUP_TIME",BACKUP_TIME,tmp_name)
|
|
|
|
| 600 |
time.sleep(2)
|
| 601 |
result = restart_huggingface_space(HF_USER2, tmp_name, HF_TOKON2)
|
| 602 |
print(f"{tmp_name}重启结果:",result)
|
| 603 |
+
create_space(4,"","",CHAT_ID)
|
| 604 |
# result = restart_huggingface_space(HF_USER2, HF_ID, HF_TOKON2)
|
| 605 |
# print(result)
|
| 606 |
else:
|
|
|
|
| 624 |
response = create_space(2)
|
| 625 |
print(response)
|
| 626 |
time.sleep(21600)#21600 = 6小时
|
| 627 |
+
create_space(4,"","",HF_SPACES_NAME)
|
| 628 |
response = create_space(1)
|
| 629 |
+
url = response["url"]
|
| 630 |
full_name = response["name"]
|
| 631 |
tmp_name = full_name.split("/")[-1]
|
| 632 |
+
# log = f"“原始创建Space返回:{response} name字段:{full_name} Space 名称{tmp_name}"
|
| 633 |
+
log = f"Original create Space response: {response} | name field: {full_name} | Space name: {tmp_name}"
|
| 634 |
telegram_message(BOT_TOKEN, CHAT_ID, log)
|
| 635 |
print(log)
|
| 636 |
create_space(3,"BACKUP_TIME",BACKUP_TIME,tmp_name)
|
|
|
|
| 652 |
time.sleep(2)
|
| 653 |
result = restart_huggingface_space(HF_USER2, tmp_name, HF_TOKON2)
|
| 654 |
print(f"{tmp_name}重启结果:",result)
|
| 655 |
+
telegram_message(BOT_TOKEN, CHAT_ID, f"{HF_ID} startup finished")
|
| 656 |
+
create_space(4,"","",CHAT_ID)
|
| 657 |
# result = restart_huggingface_space(HF_USER2, HF_ID, HF_TOKON2)
|
| 658 |
# print(result)
|
| 659 |
# break
|