Update app.py
Browse files
app.py
CHANGED
|
@@ -11,10 +11,9 @@ from urllib.parse import urlparse, urljoin, unquote
|
|
| 11 |
from concurrent.futures import ThreadPoolExecutor
|
| 12 |
|
| 13 |
# ----------------------------------------------------------------------
|
| 14 |
-
# 1. ZEROGPU REQUIREMENT (MUST BE AT THE TOP)
|
| 15 |
# ----------------------------------------------------------------------
|
| 16 |
-
#
|
| 17 |
-
import spaces
|
| 18 |
|
| 19 |
@spaces.GPU(duration=10)
|
| 20 |
def dummy_gpu():
|
|
@@ -22,7 +21,7 @@ def dummy_gpu():
|
|
| 22 |
pass
|
| 23 |
|
| 24 |
# ----------------------------------------------------------------------
|
| 25 |
-
# 2. SYSTEM SETUP
|
| 26 |
# ----------------------------------------------------------------------
|
| 27 |
def run_cmd(cmd, desc=""):
|
| 28 |
print(f"\n[Setup] {desc}", flush=True)
|
|
@@ -112,7 +111,7 @@ from huggingface_hub import HfApi, login, CommitOperationAdd
|
|
| 112 |
|
| 113 |
session = requests.Session()
|
| 114 |
session.proxies = {
|
| 115 |
-
'http': f'socks5h://127.0.0.1:{TOR_SOCKS_PORT}',
|
| 116 |
'https': f'socks5h://127.0.0.1:{TOR_SOCKS_PORT}'
|
| 117 |
}
|
| 118 |
retries = Retry(total=10, backoff_factor=2, status_forcelist=[500, 502, 503, 504])
|
|
@@ -254,7 +253,7 @@ def crawl_onion_directory(url, rel_path=""):
|
|
| 254 |
# ----------------------------------------------------------------------
|
| 255 |
def run_mirror():
|
| 256 |
try:
|
| 257 |
-
dummy_gpu()
|
| 258 |
start_tor()
|
| 259 |
authenticate_hf()
|
| 260 |
log("✅ Hugging Face authentication successful.")
|
|
@@ -425,6 +424,10 @@ def start_web_server():
|
|
| 425 |
httpd.serve_forever()
|
| 426 |
|
| 427 |
if __name__ == "__main__":
|
|
|
|
|
|
|
|
|
|
|
|
|
| 428 |
# 1. Start the mirroring process in a background daemon thread
|
| 429 |
threading.Thread(target=run_mirror, daemon=True).start()
|
| 430 |
|
|
|
|
| 11 |
from concurrent.futures import ThreadPoolExecutor
|
| 12 |
|
| 13 |
# ----------------------------------------------------------------------
|
| 14 |
+
# 1. ZEROGPU REQUIREMENT (MUST BE AT THE VERY TOP)
|
| 15 |
# ----------------------------------------------------------------------
|
| 16 |
+
import spaces # noqa: F401
|
|
|
|
| 17 |
|
| 18 |
@spaces.GPU(duration=10)
|
| 19 |
def dummy_gpu():
|
|
|
|
| 21 |
pass
|
| 22 |
|
| 23 |
# ----------------------------------------------------------------------
|
| 24 |
+
# 2. SYSTEM SETUP
|
| 25 |
# ----------------------------------------------------------------------
|
| 26 |
def run_cmd(cmd, desc=""):
|
| 27 |
print(f"\n[Setup] {desc}", flush=True)
|
|
|
|
| 111 |
|
| 112 |
session = requests.Session()
|
| 113 |
session.proxies = {
|
| 114 |
+
'http': f'socks5h://127.0.0.1:{TOR_SOCKS_PORT}',
|
| 115 |
'https': f'socks5h://127.0.0.1:{TOR_SOCKS_PORT}'
|
| 116 |
}
|
| 117 |
retries = Retry(total=10, backoff_factor=2, status_forcelist=[500, 502, 503, 504])
|
|
|
|
| 253 |
# ----------------------------------------------------------------------
|
| 254 |
def run_mirror():
|
| 255 |
try:
|
| 256 |
+
# dummy_gpu() call removed from here; it will be called in __main__
|
| 257 |
start_tor()
|
| 258 |
authenticate_hf()
|
| 259 |
log("✅ Hugging Face authentication successful.")
|
|
|
|
| 424 |
httpd.serve_forever()
|
| 425 |
|
| 426 |
if __name__ == "__main__":
|
| 427 |
+
# ✅ Call the GPU dummy function synchronously before anything else
|
| 428 |
+
dummy_gpu()
|
| 429 |
+
print("✅ ZeroGPU dummy function executed.", flush=True)
|
| 430 |
+
|
| 431 |
# 1. Start the mirroring process in a background daemon thread
|
| 432 |
threading.Thread(target=run_mirror, daemon=True).start()
|
| 433 |
|