File size: 929 Bytes
50e4044
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from __future__ import annotations

import os
from dataclasses import dataclass


@dataclass(frozen=True)
class Settings:
    data_dir: str
    api_token: str
    allowed_origins: list[str]
    # Optional private data source: when HF_DATASET_REPO is set the API pulls the
    # parquet from that private HF Dataset at startup (so it need not be committed
    # to the public Space). Empty = local mode (DATA_DIR already populated).
    hf_dataset_repo: str
    hf_token: str


def get_settings() -> Settings:
    origins = os.environ.get("ALLOWED_ORIGINS", "http://localhost:5173")
    return Settings(
        data_dir=os.environ.get("DATA_DIR", "analysis/data/processed"),
        api_token=os.environ.get("API_TOKEN", ""),
        allowed_origins=[o.strip() for o in origins.split(",") if o.strip()],
        hf_dataset_repo=os.environ.get("HF_DATASET_REPO", ""),
        hf_token=os.environ.get("HF_ACCESS_TOKEN", ""),
    )