Spaces:
Sleeping
Sleeping
| import os | |
| import sys | |
| import subprocess | |
| from huggingface_hub import snapshot_download | |
| REVISION = os.environ.get("VNEWS_RESTORE_REVISION", "bcaa2dc") | |
| REPO_ID = os.environ.get("VNEWS_REPO_ID", "bep40/vnews") | |
| # Download exact Space snapshot from Hugging Face Hub. | |
| # This avoids manually copying huge files from an old commit. | |
| snapshot_dir = snapshot_download( | |
| repo_id=REPO_ID, | |
| repo_type="space", | |
| revision=REVISION, | |
| local_dir="/tmp/vnews_restore", | |
| local_dir_use_symlinks=False, | |
| ) | |
| os.chdir(snapshot_dir) | |
| sys.path.insert(0, snapshot_dir) | |
| # Commit bcaa2dc Dockerfile ran ai_patch:app. | |
| cmd = [ | |
| "uvicorn", | |
| "ai_patch:app", | |
| "--host", | |
| "0.0.0.0", | |
| "--port", | |
| "7860", | |
| ] | |
| os.execvp(cmd[0], cmd) | |