File size: 1,787 Bytes
198ccb0
 
 
 
 
 
 
 
134ff26
 
198ccb0
4f88d1f
 
 
 
 
 
 
 
 
 
 
198ccb0
 
134ff26
 
 
 
 
198ccb0
 
 
 
 
 
 
 
 
 
134ff26
198ccb0
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
services:
  - type: web
    name: russian-news-classification-api
    runtime: python
    plan: free
    region: oregon
    healthCheckPath: /health
    buildCommand: |
      # Install a lean, API-only dependency set (faster builds + lower RAM).
      pip install -r requirements-api.txt
      # Download model weights (recommended: GitHub Release asset URL)
      if [ -z "$MODEL_URL" ]; then
        echo "ERROR: MODEL_URL is not set."
        echo "Set MODEL_URL in Render -> Service -> Environment to the direct .pt Release asset URL."
        echo "Example: https://github.com/<user>/<repo>/releases/download/<tag>/distilmbert_lora_10k_v1.pt"
        exit 1
      fi
      python scripts/download_model.py \
        --model-id distilmbert_lora_10k_v1 \
        --url "$MODEL_URL" \
        --output-path models/distilmbert_lora_10k_v1.pt \
        ${MODEL_SHA256:+--sha256 "$MODEL_SHA256"}
    startCommand: uvicorn api.main:app --host 0.0.0.0 --port $PORT
    envVars:
      # Ensure Python can import local top-level packages (api/, models/, utils/, etc.)
      - key: PYTHONPATH
        value: /opt/render/project/src
      - key: PYTHONUNBUFFERED
        value: "1"
      - key: MODEL_PATH
        value: models/distilmbert_lora_10k_v1.pt
      - key: THRESHOLDS_PATH
        value: config/thresholds.json
      - key: TOKENIZER_NAME
        value: distilbert-base-multilingual-cased
      # Set these in the Render dashboard (do not hardcode secrets here):
      # - MODEL_URL: direct URL to .pt file (e.g., GitHub Release asset)
      # - MODEL_SHA256: optional integrity check
      # - CORS_ALLOW_ORIGINS: comma-separated list of allowed origins for Streamlit Cloud
      # - MODEL_DTYPE: optional (float32|float16). Use float16 with an fp16 checkpoint to fit into 512Mi.