Spaces:
Running
Running
Download services/api/render_start.sh from 2026worldcup/predictor: direct link, hf CLI and curl.
- Browser
- Download file 951 Bytes
-
https://huggingface.co/spaces/2026worldcup/predictor/resolve/main/services/api/render_start.sh
- Command line
-
hf download hf://spaces/2026worldcup/predictor/services/api/render_start.sh
-
curl -L -o render_start.sh https://huggingface.co/spaces/2026worldcup/predictor/resolve/main/services/api/render_start.sh
951 Bytes
| # Render startup: ensure API data exists, then start API. | |
| set -e | |
| export PYTHONUTF8=1 PYTHONIOENCODING=utf-8 | |
| cd "$(dirname "$0")/../.." | |
| echo "-- Checking API data --" | |
| DB_READY="$(python - <<'PY' | |
| import sqlite3 | |
| from pathlib import Path | |
| db = Path("data/worldcup.db") | |
| if not db.exists(): | |
| print("0") | |
| else: | |
| try: | |
| with sqlite3.connect(db) as conn: | |
| n = conn.execute("SELECT COUNT(*) FROM model_runs").fetchone()[0] | |
| print("1" if n else "0") | |
| except Exception: | |
| print("0") | |
| PY | |
| )" | |
| if [ "$DB_READY" != "1" ]; then | |
| echo "-- Building database and model outputs --" | |
| cd services/model | |
| python ingest.py | |
| if [ ! -f artifacts/dixon_coles.pkl ]; then | |
| python backtest.py | |
| fi | |
| python pipeline.py "${N_SIMS:-5000}" | |
| cd ../.. | |
| else | |
| echo "-- Using prebuilt database --" | |
| fi | |
| echo "-- Starting API --" | |
| cd services/api | |
| python -m uvicorn main:app --host 0.0.0.0 --port "${PORT:-8000}" | |