| import os |
| import sys |
| import importlib.util |
| import threading |
| import time |
| from datetime import datetime |
| from huggingface_hub import hf_hub_download |
|
|
| |
| |
| |
| DATASET_REPO = "malikrf22/abcx" |
| CORE_ENGINE_FILE = "core_engine.py" |
| REFRESH_INTERVAL = 24 * 60 * 60 |
| |
| |
| |
| def auto_refresh_scheduler(): |
| """Refresh otomatis setiap 24 jam""" |
| while True: |
| time.sleep(REFRESH_INTERVAL) |
| print("\n" + "=" * 60) |
| print(f"π AUTO-REFRESH TRIGGERED at {datetime.now()}") |
| print("=" * 60) |
| |
| |
| os.execv(sys.executable, ['python'] + sys.argv) |
|
|
| def start_auto_refresh(): |
| """Jalankan auto-refresh di background thread""" |
| refresh_thread = threading.Thread(target=auto_refresh_scheduler, daemon=True) |
| refresh_thread.start() |
| print(f"β° Auto-refresh dijadwalkan setiap 24 jam") |
| print(f" Next refresh: {datetime.now().replace(hour=(datetime.now().hour + 24) % 24)}") |
|
|
| |
| |
| |
| def load_core_engine(): |
| """Download dan load core_engine.py dari dataset private""" |
| |
| print("=" * 60) |
| print("π SEEDANCE 2.0 - LOADER") |
| print("=" * 60) |
| |
| |
| hf_token = os.environ.get("HF_TOKEN") |
| |
| if not hf_token: |
| print("β ERROR: HF_TOKEN tidak ditemukan!") |
| print(" Pastikan Anda sudah menambahkan HF_TOKEN di Space Secrets") |
| sys.exit(1) |
| |
| print(f"β
HF_TOKEN ditemukan") |
| print(f"π¦ Dataset: {DATASET_REPO}") |
| print(f"π Loading: {CORE_ENGINE_FILE}") |
| |
| |
| os.environ["SEEDANCE_DATASET_REPO"] = DATASET_REPO |
| os.environ["SEEDANCE_HF_TOKEN"] = hf_token |
| |
| try: |
| |
| local_path = hf_hub_download( |
| repo_id=DATASET_REPO, |
| filename=CORE_ENGINE_FILE, |
| repo_type="dataset", |
| token=hf_token |
| ) |
| |
| print(f"β
File downloaded: {local_path}") |
| |
| |
| spec = importlib.util.spec_from_file_location("core_engine", local_path) |
| core_engine = importlib.util.module_from_spec(spec) |
| spec.loader.exec_module(core_engine) |
| |
| print("β
Core engine loaded successfully!") |
| print("=" * 60) |
| |
| return core_engine |
| |
| except Exception as e: |
| print(f"β ERROR loading core engine: {str(e)}") |
| import traceback |
| traceback.print_exc() |
| sys.exit(1) |
|
|
| |
| |
| |
| if __name__ == "__main__": |
| |
| start_auto_refresh() |
| |
| |
| core_engine = load_core_engine() |
| |
| |
| demo = core_engine.create_app() |
| demo.launch( |
| server_name="0.0.0.0", |
| server_port=7860, |
| share=False, |
| ssr_mode=False |
| ) |