Update utils/config.py
Browse files- utils/config.py +34 -21
utils/config.py
CHANGED
|
@@ -1,21 +1,34 @@
|
|
| 1 |
-
import os
|
| 2 |
-
from dataclasses import dataclass
|
| 3 |
-
|
| 4 |
-
@dataclass
|
| 5 |
-
class AppConfig:
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
from dataclasses import dataclass
|
| 3 |
+
|
| 4 |
+
@dataclass
|
| 5 |
+
class AppConfig:
|
| 6 |
+
"""
|
| 7 |
+
Central configuration class for the Tabular Agentic XAI app.
|
| 8 |
+
It reads all required environment variables for both BigQuery
|
| 9 |
+
and MotherDuck backends.
|
| 10 |
+
"""
|
| 11 |
+
# Common
|
| 12 |
+
hf_model_repo: str
|
| 13 |
+
sql_backend: str # "bigquery" or "motherduck"
|
| 14 |
+
|
| 15 |
+
# BigQuery
|
| 16 |
+
gcp_project: str | None = None
|
| 17 |
+
|
| 18 |
+
# MotherDuck
|
| 19 |
+
motherduck_db: str | None = None
|
| 20 |
+
motherduck_token: str | None = None
|
| 21 |
+
|
| 22 |
+
@classmethod
|
| 23 |
+
def from_env(cls):
|
| 24 |
+
"""
|
| 25 |
+
Reads environment variables from .env (local) or Hugging Face Space Secrets.
|
| 26 |
+
Returns an AppConfig instance.
|
| 27 |
+
"""
|
| 28 |
+
return cls(
|
| 29 |
+
hf_model_repo=os.getenv("HF_MODEL_REPO", "your-username/your-private-tabular-model"),
|
| 30 |
+
sql_backend=os.getenv("SQL_BACKEND", "motherduck"),
|
| 31 |
+
gcp_project=os.getenv("GCP_PROJECT"),
|
| 32 |
+
motherduck_db=os.getenv("MOTHERDUCK_DB", "default"),
|
| 33 |
+
motherduck_token=os.getenv("MOTHERDUCK_TOKEN")
|
| 34 |
+
)
|