Spaces:
Running
Running
Restore exact b9b6ba4 snapshot without hotfixes
Browse files- restore_runner.py +2 -28
restore_runner.py
CHANGED
|
@@ -1,45 +1,19 @@
|
|
| 1 |
import os
|
| 2 |
import sys
|
| 3 |
-
import subprocess
|
| 4 |
-
import requests
|
| 5 |
from huggingface_hub import snapshot_download
|
| 6 |
|
| 7 |
-
#
|
| 8 |
-
# We run the b9b6ba4 snapshot, then hotfix only static/index.html from the last good UI branch.
|
| 9 |
REVISION = os.environ.get("VNEWS_RESTORE_REVISION", "b9b6ba4")
|
| 10 |
REPO_ID = os.environ.get("VNEWS_REPO_ID", "bep40/vnews")
|
| 11 |
-
GOOD_INDEX_URL = os.environ.get(
|
| 12 |
-
"VNEWS_GOOD_INDEX_URL",
|
| 13 |
-
"https://huggingface.co/spaces/bep40/vnews/raw/restore-33c3dda/static/index.html",
|
| 14 |
-
)
|
| 15 |
APP_MODULE = os.environ.get("VNEWS_APP_MODULE", "ai_runtime_final6:app")
|
| 16 |
|
| 17 |
snapshot_dir = snapshot_download(
|
| 18 |
repo_id=REPO_ID,
|
| 19 |
repo_type="space",
|
| 20 |
revision=REVISION,
|
| 21 |
-
local_dir="/tmp/
|
| 22 |
)
|
| 23 |
|
| 24 |
-
# Hotfix placeholder index in the runtime snapshot only.
|
| 25 |
-
index_path = os.path.join(snapshot_dir, "static", "index.html")
|
| 26 |
-
try:
|
| 27 |
-
current = ""
|
| 28 |
-
if os.path.exists(index_path):
|
| 29 |
-
with open(index_path, "r", encoding="utf-8") as f:
|
| 30 |
-
current = f.read()
|
| 31 |
-
if "<!DOCTYPE html>" not in current or '<div id="view-home"' not in current:
|
| 32 |
-
r = requests.get(GOOD_INDEX_URL, timeout=30)
|
| 33 |
-
if r.status_code == 200 and "<!DOCTYPE html>" in r.text and '<div id="view-home"' in r.text:
|
| 34 |
-
os.makedirs(os.path.dirname(index_path), exist_ok=True)
|
| 35 |
-
with open(index_path, "w", encoding="utf-8") as f:
|
| 36 |
-
f.write(r.text)
|
| 37 |
-
print("[restore_runner] Replaced placeholder static/index.html with good restored UI")
|
| 38 |
-
else:
|
| 39 |
-
print("[restore_runner] WARNING: good index fetch failed or invalid; keeping snapshot index")
|
| 40 |
-
except Exception as e:
|
| 41 |
-
print("[restore_runner] WARNING: index hotfix failed:", repr(e))
|
| 42 |
-
|
| 43 |
os.chdir(snapshot_dir)
|
| 44 |
sys.path.insert(0, snapshot_dir)
|
| 45 |
|
|
|
|
| 1 |
import os
|
| 2 |
import sys
|
|
|
|
|
|
|
| 3 |
from huggingface_hub import snapshot_download
|
| 4 |
|
| 5 |
+
# Exact restore requested: run the b9b6ba4 snapshot as-is, with no file hotfixes or patches.
|
|
|
|
| 6 |
REVISION = os.environ.get("VNEWS_RESTORE_REVISION", "b9b6ba4")
|
| 7 |
REPO_ID = os.environ.get("VNEWS_REPO_ID", "bep40/vnews")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
APP_MODULE = os.environ.get("VNEWS_APP_MODULE", "ai_runtime_final6:app")
|
| 9 |
|
| 10 |
snapshot_dir = snapshot_download(
|
| 11 |
repo_id=REPO_ID,
|
| 12 |
repo_type="space",
|
| 13 |
revision=REVISION,
|
| 14 |
+
local_dir="/tmp/vnews_restore_b9b6ba4",
|
| 15 |
)
|
| 16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
os.chdir(snapshot_dir)
|
| 18 |
sys.path.insert(0, snapshot_dir)
|
| 19 |
|